• Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    Java
  • License
    BSD 2-Clause "Sim...
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A sample plugin for jetbrains IDEs that uses an ANTLR grammar for a nontrivial custom language.

Sample IntelliJ plugin using ANTLR grammar

This is a demonstration of ANTLRv4 library for IntelliJ plugins, which makes it easy to create plugins for IntelliJ-based IDEs based on an ANTLRv4 grammar.

Running the plugin for the first time

Make sure the Gradle plugin is installed in your IDE, go to File -> Open, select the build.gradle file and choose Open as Project.

If you already imported the project when it was not based on Gradle, then choose the option to delete the existing project and reimport it.

Once the IDE is done downloading dependencies and refreshing the project, you can use the Gradle tool window and use the following Tasks:

  • build > assemble to build the project
  • intellij > runIde to run the plugin in a sandboxed instance

Noteworthy things

Gradle build

The build is based on Gradle, and uses the gradle-intellij-plugin, which makes it easy to:

  • pull dependencies, especially the IntelliJ SDK and antlr4-intellij-adaptor
  • build and run tests in a CI environment on different versions of the SDK
  • generate lexers & parsers from your grammars, thanks to the ANTLR plugin for Gradle
  • publish plugins to the JetBrains Plugins Repository
  • configure the project for occasional contributors πŸ™‚

ANTLRPsiNode

PSI nodes defined in the plugin extend ANTLRPsiNode and IdentifierDefSubtree, which automatically makes them PsiNameIdentifierOwners.

Error highlighting

Errors are shown by SampleExternalAnnotator, which makes use of org.antlr.intellij.adaptor.xpath.XPath to detect references to unknown functions.

ParserDefinition

SampleParserDefinition uses several handy classes from the adaptor library:

  • PSIElementTypeFactory to generate IElementTypes from tokens and rules defined in your ANTLRv4 grammar
  • ANTLRLexerAdaptor to bind generated lexers to a com.intellij.lexer.Lexer
  • ANTLRParserAdaptor to bind generated parsers to a com.intellij.lang.PsiParser

Misc

WARNING. Turn on Dragon speech recognition for Mac and do a rename. GUI deadlocks. Every time. Turn off dragon. No problem ever. See JetBrains forum.

More Repositories

1

antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
Java
17,043
star
2

grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.
ANTLR
10,114
star
3

stringtemplate4

StringTemplate 4
Java
943
star
4

intellij-plugin-v4

An IntelliJ plugin for ANTLR v4
Java
467
star
5

codebuff

Language-agnostic pretty-printing through machine learning (uh, like, is this possible? YES, apparently).
Java
440
star
6

antlrcs

The C# port of ANTLR 3, StringTemplate 3, and StringTemplate 4
C#
281
star
7

antlr3

antlr v3 repository (pulled from p4 with history from //depot/code/antlr/antlr3-main
Java
241
star
8

antlr4-intellij-adaptor

A library to support the use of ANTLR grammars in jetbrains IDE plugins for building custom languages.
Java
209
star
9

antlrworks

AntlrWorks tool for ANTLR
Java
97
star
10

antlr4-tools

Tools to run antlr4 w/o needing to install java or antlr4!
Python
83
star
11

antlr-php-runtime

PHP Runtime for ANTLR4
PHP
81
star
12

antlr4-cpp

C++ target for ANTLR 4, including templates and runtime
C++
75
star
13

examples-v3

Java
59
star
14

antlr5

Java
52
star
15

symtab

Generic symbol table for lexically/statically scoped languages
Java
48
star
16

Antlr4Formatter

Formatter for ANTLR 4 grammars
ANTLR
40
star
17

antlr4-lab

A client/server for trying out and learning about ANTLR
Java
35
star
18

grammars-v3

Grammars written for ANTLR v3; expectation that the grammars are free of actions but it's not a hard and fast rule. there is no common license!
GAP
24
star
19

jetbrains-plugin-st4

An intellij/jetbrains plugin for StringTemplate .st and .stg files
Java
23
star
20

antlr4test-maven-plugin

A maven plugin used to test the grammars-v4 repo grammars
Java
17
star
21

stringtemplate3

StringTemplate v3
Java
15
star
22

website-antlr3

The ANTLR 3 Website
HTML
13
star
23

website-antlr4

The ANTLR 4 Website
HTML
11
star
24

antlr-php-runtime-phpstan

Static analysis for ANTLR4 PHP Runtime.
PHP
6
star
25

antlr5-specs

Specs for antlr5
4
star
26

grammars-v5

3
star
27

_grammar-test

Historical files from grammars-v4 repo
Java
2
star
28

performance

Test the performance of ANTLR parsers (initially just Java target)
Java
2
star
29

website-antlr2

The ANTLR 2 Website
Java
1
star
30

website-st4

stringtemplate.org content
HTML
1
star
31

antlr5-lab

TypeScript
1
star