Creating Language Plugin not used for new language
Roland Plüss
roland at rptd.ch
Fri Sep 14 17:41:05 BST 2018
Seems some caching got me. I had test files open before installing the
Kate XML file and it seems KDevelop remembered the "no highlighting"
setting and did not automatically adjust. When I opened a new file I
never opened it worked with auto-selection.
Now something else. I've got quite a problem with this configuration
here and I'm at a loss on how I do it correctly.
My language plugin has a bunch of documentary source files it installs
into the shared directly alongside the plugin library. These are
syntactically valid files only serving to parse the basic language
classes available. I based this concept on the python plugin. So far
this works with one major problem. When I open KDevelop and it opens a
previously opened source file all the uses are broken. It seems the
language plugin provided documentary source files are not automatically
loaded and/or the source files are not re-processed if these basic
language files are parsed.
I tried fixing the problem with "context imports" like this:
const QVector<ReferencedTopDUContext> contexts(
Helpers::getDocumentationFileContexts() );
QList<QPair<TopDUContext*, CursorInRevision>> imports;
foreach( const ReferencedTopDUContext &each, contexts ){
imports.append( qMakePair( each, CursorInRevision( 1, 0 ) ) );
}
top->addImportedParentContexts( imports );
This is called from the ContextBuilder whener a top context is created:
TopDUContext *ContextBuilder::newTopContext( const RangeInRevision
&range, ParsingEnvironmentFile *file ) { ... }
In my understanding this should be like an implicit "import/include" of
all the basic language files in every source file parsed. Nevertheless
the uses are broken when I open KDevelop with a previously opened file.
What am I not understanding here?
NOTE: To be complete here the implementation of
getDocumentationFileContexts()
QVector<ReferencedTopDUContext> Helpers::getDocumentationFileContexts(){
if( ! documentationFileContextsReady ){
const QVector<IndexedString> &files = getDocumentationFiles();
if( documentationFileContexts.isEmpty() ){
foreach( const IndexedString &file, files ){
documentationFileContexts.append(
ReferencedTopDUContext() );
}
}
documentationFileContextsReady = true;
for( int i=0; i<documentationFileContexts.size(); i++ ){
if( documentationFileContexts.at( i ) ){
continue;
}
documentationFileContexts.replace( i,
ReferencedTopDUContext(
DUChain::self()->chainForDocument( files.at( i ) ) ) );
if( ! documentationFileContexts.at( i ) ){
// basic language information not parse yet. parse
it at high priority
documentationFileContextsReady = false;
ICore::self()->languageController()->backgroundParser()->addDocument(
files.at( i ),
KDevelop::TopDUContext::ForceUpdate,
BackgroundParser::BestPriority,
0, ParseJob::FullSequentialProcessing );
}
}
}
QVector<ReferencedTopDUContext> contexts;
foreach( const ReferencedTopDUContext &context,
documentationFileContexts ){
if( context ){
contexts.append( context );
}
}
return contexts;
}
I experiment a lot with this stuff looking at the python plugin to
figure out how this is supposed to work. As I understand it I need to
parse the files with the background parser. What I don't get though is
how I can link this "in the process of being parsed" source files to
actual source files opened in KDevelop. I think I am missing here
something but without proper documentation I'm guessing around left and
right.
--
Mit freundlichen Grüssen
Plüss Roland
Leader und Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Sowie verschiedene Blender Export-Skripts und Game-Tools
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180914/5a0c84fb/attachment-0001.sig>
More information about the KDevelop-devel
mailing list