additionalTextAttributes cannot be resolved after build.

Answered

I developed a plugin using the GitHub template. When I run my plugin using the "runIDE" Gradle task the additional text attributes, which I specified at the com.intellij.additionalTextAttributes extension point, can be resolved without problem. However, when I build it via the "buildPlugin" task and install it from disk it always resorts to the fallback values, instead of, using the ones defined in the xml file specified at the extension point.

What could be the reason for this anomalous behavior and / or how could I debug it?

0
5 comments

Please share full sources

 

0
Avatar
Permanently deleted user

The extensions section of my plugin.xml looks like this:

<extensions defaultExtensionNs="com.intellij">
<!-- File Template specification -->
<internalFileTemplate name="LslScript"/>

<!-- Register custom file type for LSL files -->
<fileType name="LSL File" implementationClass="de.uni_mannheim.informatik.swt.lsl.language.LslFileType"
fieldName="INSTANCE" extensions="lsl"/>

<!-- Provide the specification for additional text attributes -->
<additionalTextAttributes scheme="Darcula" file="colorSchemes/LslDarcula.xml"/>
<additionalTextAttributes scheme="Default" file="colorSchemes/LslDefault.xml"/>

<!-- Annotator for LSL-specific syntax highlighting -->
<annotator language="Groovy"
implementationClass="de.uni_mannheim.informatik.swt.lsl.annotation.LslKeywordAnnotator"/>
<!-- Annotator for semantic highlighting -->
<annotator language="Groovy"
implementationClass="de.uni_mannheim.informatik.swt.lsl.annotation.LslSemanticAnnotator"/>
<!-- Annotator for highlighting LSL-specific errors -->
<annotator language="Groovy"
implementationClass="de.uni_mannheim.informatik.swt.lsl.annotation.LslErrorHighlighter"/>

<!-- Injector to enable syntax highlighting for Java code within LSL files -->
<multiHostInjector implementation="de.uni_mannheim.informatik.swt.lsl.injection.JavaLslInjector"/>

<!-- Filter for disabling error highlighting of embedded Java code -->
<daemon.highlightInfoFilter
implementation="de.uni_mannheim.informatik.swt.lsl.injection.InjectedJavaInfoFilter"/>
<!-- Filter for disabling missing package declaration warnings within LSL files -->
<daemon.highlightInfoFilter
implementation="de.uni_mannheim.informatik.swt.lsl.groovy.GroovyInfoFilter"/>

<!-- Register the color settings page -->
<colorSettingsPage implementation="de.uni_mannheim.informatik.swt.lsl.settings.LslColorSettingsPage"/>

<!-- Register the tool window for displaying dependencies of actions -->
<toolWindow id="LSL" secondary="true" icon="/icons/lasso_logo_13x13.png" anchor="right"
factoryClass="de.uni_mannheim.informatik.swt.lsl.ui.LslToolWindowFactory"/>
</extensions>

The xml files (LslDarcula.xml and LslDefault.xml) specifying the additional text attributes look like this and only differ in the color values:

<?xml version='1.0'?>
<list>
<option name="LSL_SELECT_ACTION">
<value>
<option name="FOREGROUND" value="31dea1"/>
</value>
</option>
<option name="LSL_OTHER_ACTION">
<value>
<option name="FOREGROUND" value="1c7556"/>
</value>
</option>
<option name="LSL_DEPENDS_ON_NONE">
<value>
<option name="FOREGROUND" value="3697ff"/>
</value>
</option>
<option name="LSL_DEPENDS_ON_OTHER">
<value>
<option name="FOREGROUND" value="2360a1"/>
</value>
</option>

<option name="LSL_ASSIGNMENT_IDENTIFIER">
<value>
<option name="FOREGROUND" value="fadeff"/>
</value>
</option>
<option name="LSL_METHOD_CLOSURE_IDENTIFIER">
<value>
<option name="FOREGROUND" value="ffb63d"/>
</value>
</option>
<option name="LSL_METHOD_IDENTIFIER">
<value>
<option name="FOREGROUND" value="fcf0dc"/>
</value>
</option>
</list>

An when I am trying to use one of the additional text attributes specified in the xml files I use TextAttributesKey#createTextAttributesKey like this:

TextAttributesKey SELECT_ACTION_KEY = TextAttributesKey.createTextAttributesKey("LSL_SELECT_ACTION", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION);
TextAttributesKey NON_SELECT_ACTION_KEY = TextAttributesKey.createTextAttributesKey("LSL_OTHER_ACTION", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION);
TextAttributesKey DEPENDS_ON_NONE_KEY = TextAttributesKey.createTextAttributesKey("LSL_DEPENDS_ON_NONE", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION);
TextAttributesKey DEPENDS_ON_OTHER_KEY = TextAttributesKey.createTextAttributesKey("LSL_DEPENDS_ON_OTHER", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION);
0

So far, this looks right. Please double check your Lsl*.xml files are correctly packaged in resulting plugin distribution ZIP file.

Are you sure you run and install your plugin in the exact same IDE version? Maybe another conflicting plugin?

0
Avatar
Permanently deleted user

I ran the plugin on exactly the same installation of IntelliJ as the one I used to write the plugin (2020.3.2). Furthermore, besides the plugins that come bundled with IntelliJ I only have PsiViewer installed, which should not influence the highlighting. 

For the zip file, the LslDarcula.xml and LslDefault.xml files are located in the lib/LSL IntelliJ Plugin-1.0.0.jar/colorSchemes folder.

 

Edit 1: I uninstalled the PsiViewer plugin, yet as assumed this did nothing. Furthermore, no other component of my plugin can be the cause given that the error persists even with nearly all of them removed. In addition, in the build.gradle.kts file the IntelliJ version is specified as 2020.2.4. However, a change to 2020.3.2 did not solve the problem either.

Edit 2: Turns out, that if I restart the IDE manually after installing the plugin, the additional text attributes can be resolved. Therefore, only directly after the initial installation, the problem persists. Nonethless, the cause for this irritating problem is still unknown to me.

0

So to summarize, it works as expected after forcing additional restart of IDE, but not directly after "dynamic" installation?

0

Please sign in to leave a comment.