We fix a number of bugs and frustrating sides of the plugin's logic and UX. Namely:
Plugin uses official TypeQL grammar source as a dependency.
Default syntax highlighting and coloring now make more sense.
Opportunity to import TypeDB Studio's color scheme via several clicks.
Overall parsing works better and does not excessively highlight correct code as errors.
Referencing is improved, including override constraints like "owns as", "plays as", "relates as".
Find Definition and Find Usages work much better and in wider set of cases.
Rename feature does not throw exceptions and basically work in most of the cases (still does not work with relations when it is mentioned in "plays": details).
Inspection features are disabled until they are stabilized.
Implementation
Details are in the comments, but the overall structure is:
High-level TypeQL* files (TypeQLLanguage, TypeQLTokenSets...) describe the language itself. The most interesting and loaded one is TypeQLParserDefinition: it contains logic for creating specific PSI-elements based on the ANTLR output.
PSI-elements are declared in the psi package. The entrance here is the base PsiTypeQLElement (basically to distinguish TypeQL tokens from other languages in the tree). Then we have PsiTypeQLStatementType (doesn't have any needed logic for now, so you can ignore it) and two groups of Constraints (implementations are in the constraint package): Named and Referencing elements, which are the basis for Declarations and Usages (read the comments in the Named and Referencing elements' files).
Highlighting works with tokens from the parser and is not interested in our PSI-elements. Its details are in the highlighter package.
reference package is a continuation of the Named/Referenced elements ballad. Here we specify which elements will work with referencing (TypeQLReferenceContributor) and how our Reference work with some features in details (TypeQLReference).
Based on these references, Find Usages/Declarations feature can be activated (usage package). The feature itself is activated in TypeQLFindUsagesProvider, but the main method, which describes the logic behind these buttons, is a part of TypeQLDeclarationFinder (we only need to specify how to find declarations: Find Usages is a derivative operation for us).
Refactoring support (refactor package) doesn't contain much logic as it is based on the previous points.
Completion (completion package) works good enough, so I leave it as is for now, but I'd like to refactor it in the future, because it's of course not ideal.
In addition to the product changes:
A bunch of hardcode has been removed, more to come.
There are more parsing test cases in the parsing test for better future control (other tests have not been implemented, we can think about them within the next iteration).
Usage and product changes
We fix a number of bugs and frustrating sides of the plugin's logic and UX. Namely:
Implementation
Details are in the comments, but the overall structure is:
TypeQL*
files (TypeQLLanguage
,TypeQLTokenSets
...) describe the language itself. The most interesting and loaded one isTypeQLParserDefinition
: it contains logic for creating specificPSI
-elements based on theANTLR
output.PSI
-elements are declared in thepsi
package. The entrance here is the basePsiTypeQLElement
(basically to distinguishTypeQL
tokens from other languages in the tree). Then we havePsiTypeQLStatementType
(doesn't have any needed logic for now, so you can ignore it) and two groups ofConstraints
(implementations are in the constraint package):Named
andReferencing
elements, which are the basis forDeclarations
andUsages
(read the comments in theNamed
andReferencing
elements' files).PSI
-elements. Its details are in thehighlighter
package.reference
package is a continuation of the Named/Referenced elements ballad. Here we specify which elements will work with referencing (TypeQLReferenceContributor
) and how our Reference work with some features in details (TypeQLReference
).usage
package). The feature itself is activated inTypeQLFindUsagesProvider
, but the main method, which describes the logic behind these buttons, is a part ofTypeQLDeclarationFinder
(we only need to specify how to find declarations: Find Usages is a derivative operation for us).refactor
package) doesn't contain much logic as it is based on the previous points.completion
package) works good enough, so I leave it as is for now, but I'd like to refactor it in the future, because it's of course not ideal.In addition to the product changes: