multilanguage kdevelop

David Nolden zwabel at googlemail.com
Wed Jul 28 23:09:09 UTC 2010


>From what I see, the context doesn't have any members. You could add
an "IndexedString language()" member, and then put that thing into
kdevplatform as "LanguageTopDUContext" or something like that (after
all it's the top-context of the language).

Regarding updating: The "setEncountered" thing doesn't look nice.
Couldn't you just share the same "encountered" cache across all
context-builders? You could create a class like

namespace KDevelop {
struct ParseSession {
  bool m_valid;
  SimpleRange m_range;
  QSet<DUChainBase*> m_encountered;  // or whatever other
data-structure we use currently
  ParseJob::Contents m_contents;
  DUContext* m_updating;
  // Add here whatever else would be needed across different languages
};
};

And then, you could do something like this:

// We encounter a something that contains a different language than
what we're parsing now

void parseSubLanguageContext(AST* subLanguageAST)
{
ParseSession subSession;
subSession.m_valid = true;
subSession.m_range = rangeFromAST(subLanguageAST);
subSession.m_contents = m_contents;
subSession.m_encountered = m_encountered;
subSession.m_updating = createContext(subLanguageAST);

ILanguageSupport* langSupport = languageFromAST(subLanguageAST);

if(langSupport)
 {
  ParseJob* job = langSupport->createParseJob(subSession);
  job->parseForeground();
  m_encountered = subSession.m_encountered;
 }
}

Greetings, David




More information about the KDevelop-devel mailing list