-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleaning and rework for fixing Referencing, Declarations & Usages Search, Renaming, and Syntax Highlighting. #16
Conversation
…le version of the parser. Add simple tests for the parser
… crashes + referencing
… architecture. Refactoring WIP
…y because of the referencing bug)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review finished
companion object { | ||
val INSTANCE: TypeQLLanguage = TypeQLLanguage() | ||
val GRAQL_TYPES: Set<String?> = ImmutableSet.of("attribute", "entity", "relation", "rule", "role", "thing") | ||
|
||
// TODO: Move to ParserDefinition and connect with the Parser's tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned refactoring todos here.
src/main/kotlin/org/typedb/typeql/plugin/jetbrains/TypeQLParserDefinition.kt
Show resolved
Hide resolved
src/main/kotlin/org/typedb/typeql/plugin/jetbrains/completion/TypeQLCompletionContributor.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/typedb/typeql/plugin/jetbrains/psi/PsiTypeQLStatementType.kt
Show resolved
Hide resolved
src/main/kotlin/org/typedb/typeql/plugin/jetbrains/psi/PsiTypeQLUtils.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming, all the following "Constraints" are renaming as well.
src/main/kotlin/org/typedb/typeql/plugin/jetbrains/refactor/TypeQLNamesValidator.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
fun findDeclarations( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the whole logic behind finding declarations because of the class structure. I do want to enhance this logic to be smarter (the second part of the issue), but it does work quite well right now.
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: