Skip to content

Commit

Permalink
Merge pull request #26 from FHannes/master
Browse files Browse the repository at this point in the history
[Issue #25] Updated syntax highlighting registration method.
  • Loading branch information
bjansen authored Jun 6, 2020
2 parents 0c2abe1 + 14133e1 commit d606042
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ YYYY/MM/DD, github id, Full name, email
2015/11/09, parrt, Terence Parr, [email protected]
2019/01/16, syakovlevdalet, Sergey Yakovlev, [email protected]
2019/01/17, bjansen, Bastien Jansen, [email protected]
2020/05/19, FHannes, Frédéric Hannes, [email protected]
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pluginVersion=0.7

# e.g. IC-2016.3.3, IU-2018.2.5 etc
# For a list of possible values, refer to the section 'com.jetbrains.intellij.idea' at https://www.jetbrains.com/intellij-repository/releases
ideaVersion=2019.3
ideaVersion=2020.1

# The version of ANTLR v4 that will be used to generate the parser
antlr4Version=4.7.2
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@

import com.intellij.codeHighlighting.TextEditorHighlightingPass;
import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory;
import com.intellij.codeHighlighting.TextEditorHighlightingPassFactoryRegistrar;
import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class STGroupHighlightingPassFactory
extends AbstractProjectComponent
implements TextEditorHighlightingPassFactory
implements TextEditorHighlightingPassFactory, TextEditorHighlightingPassFactoryRegistrar
{
public STGroupHighlightingPassFactory(Project project,
TextEditorHighlightingPassRegistrar registrar)
{
super(project);
registrar.registerTextEditorHighlightingPass(this, null, null, true, -1);
}
private Project project;

@Nullable
@Override
Expand All @@ -30,6 +25,13 @@ public TextEditorHighlightingPass createHighlightingPass(PsiFile file, Editor ed
Document doc = editor.getDocument();
VirtualFile vfile = FileDocumentManager.getInstance().getFile(doc);
if ( vfile==null || !vfile.getName().endsWith(".stg") ) return null;
return new STGroupHighlightingPass(myProject, editor);
return new STGroupHighlightingPass(project, editor);
}

@Override
public void registerHighlightingPassFactory(@NotNull TextEditorHighlightingPassRegistrar registrar, @NotNull Project project) {
this.project = project;
registrar.registerTextEditorHighlightingPass(this, null, null, true, -1);
}

}
4 changes: 1 addition & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
<component>
<implementation-class>org.antlr.jetbrains.st4plugin.STGroupPluginController</implementation-class>
</component>
<component>
<implementation-class>org.antlr.jetbrains.st4plugin.highlight.STGroupHighlightingPassFactory</implementation-class>
</component>
</project-components>

<actions>
Expand All @@ -50,6 +47,7 @@
<structureViewBuilder factoryClass="org.antlr.jetbrains.st4plugin.structview.STGroupStructureViewBuilderProvider"/>
<additionalTextAttributes scheme="Default" file="colorSchemes/STGroupDefault.xml"/>
<additionalTextAttributes scheme="Darcula" file="colorSchemes/STGroupDarcula.xml"/>
<highlightingPassFactory implementation="org.antlr.jetbrains.st4plugin.highlight.STGroupHighlightingPassFactory"/>

<lang.parserDefinition language="STGroup" implementationClass="org.antlr.jetbrains.st4plugin.psi.STGroupParserDefinition"/>
<lang.foldingBuilder language="STGroup" implementationClass="org.antlr.jetbrains.st4plugin.folding.STGroupFoldingBuilder"/>
Expand Down

0 comments on commit d606042

Please sign in to comment.