Skip to content

Commit

Permalink
Cleaning and rework for fixing Referencing, Declarations & Usages Sea…
Browse files Browse the repository at this point in the history
…rch, Renaming, and Syntax Highlighting. (#16)

* Change grammar file to the official typeql dependency. Initial refactoring

* Comment out everything overcomplicated and non-working. Finish a simple version of the parser. Add simple tests for the parser

* Add and fix highlight + colouring

* Finish highlighting, adding icls files and fixing original coloring

* Refactor to make better referencing

* Add distinguished 'as' classes for 'relates', 'owns' and 'plays'. Fix crashes + referencing

* Fix crashes while referencing

* Add an overkill declaration-usages search version. Finish referencing architecture. Refactoring WIP

* Fix elements' names getter's hell

* Refactor old code with small changes, no real logic changes

* Refactor text ranges. Return commenter. Start renaming's fix

* Return completion in some way. Finish renamings (have bugs, presumably because of the referencing bug)

* Add caching to fix some of the bugs

* Fix referencing bugs for types and 'as' overrides

* Fix parsing tests. Fix code style. Fix invalid renaming error

* Rename color schemes. Add highlighting readme

* Comment out NamesValidator

* Add Apache license and some comments

* Fix changelog

* Fix changelog for a tiny bit

* Add [Unreleased] to the changelog
  • Loading branch information
farost authored Feb 27, 2024
1 parent c85f30a commit 3360d8d
Show file tree
Hide file tree
Showing 86 changed files with 26,529 additions and 2,371 deletions.
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
# typeql-plugin-jetbrains Changelog

## [Unreleased]
### Fixed
- Added `.typeql` extension to supported file types
- [Usage highlighting off](https://github.com/typedb-osi/typeql-plugin-jetbrains/issues/8)

## [0.1.1]
### Added
- Basic TypeQL support
## [0.2.0]
- Add `.typeql` to supported extensions.
- Update TypeQL grammar based on the recent official releases.
- Improve syntax highlighting, coloring, and referencing.
- Add TypeDB Studio's color schemes available for import (check out the [official GitHub repo](https://github.com/typedb-osi/typeql-plugin-jetbrains)).
- Fix incorrect syntax error highlighting.
- Enhance referencing, including override constraints like `owns as`, `plays as`, `relates as`.
- Improve `Go To Declaration` and `Find Usages` features work.
- Fix `Rename` feature and a set of errors connected to it.

## [0.1.1]
- Add basic TypeQL support for `.tql` files.
139 changes: 10 additions & 129 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- Plugin description -->

Basic support for the [TypeQL language](https://github.com/vaticle/typeql) on JetBrains-based IDEs
Basic support for the [TypeQL language](https://github.com/vaticle/typeql) on JetBrains-based IDEs.

<!-- Plugin description end -->

Expand Down Expand Up @@ -44,139 +44,20 @@ Run the tests:
$ ./gradlew test
```

## Suggested Colouring
## Supported features

The following colours are suggested for the best experience, but are not required.
- Syntax highlighting and colouring (JetBrains and TypeDB color schemes) based on the official TypeQL grammar.
- Find Usages, Go To Declaration.
- Rename (currently excluding [references to relations in "plays" constraints](https://github.com/typedb-osi/typeql-plugin-jetbrains/issues/15)).
- Code completion.

You can add these colours to your IDE colour scheme by going to `Preferences → Editor → Color Scheme`, downloading your current scheme. Then, add the following to the `attributes` section of the downloaded scheme:
### Temporarily disabled features

- Dark Theme
- Unused, Invalid and Duplicated items inspections.

```
<option name="TYPEQL_AGGREGATE">
<value>
<option name="FOREGROUND" value="ff7abd" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
<option name="TYPEQL_BOOLEAN">
<value>
<option name="FOREGROUND" value="ffa187" />
</value>
</option>
<option name="TYPEQL_IDENTIFIER">
<value>
<option name="FOREGROUND" value="d5ccff" />
</value>
</option>
<option name="TYPEQL_KEYWORD">
<value>
<option name="FOREGROUND" value="ff7abd" />
</value>
</option>
<option name="TYPEQL_ANNOTATION">
<value>
<option name="FOREGROUND" value="ffa187" />
</value>
</option>
<option name="TYPEQL_LINE_COMMENT">
<value>
<option name="FOREGROUND" value="4dc97c" />
</value>
</option>
<option name="TYPEQL_NUMBER">
<value>
<option name="FOREGROUND" value="82b6ff" />
</value>
</option>
<option name="TYPEQL_STRING">
<value>
<option name="FOREGROUND" value="ffe4a7" />
</value>
</option>
<option name="TYPEQL_THING">
<value>
<option name="FOREGROUND" value="55eae2" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
<option name="TYPEQL_TYPE">
<value>
<option name="FOREGROUND" value="82b6ff" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
<option name="TYPEQL_VAR">
<value>
<option name="FOREGROUND" value="55eae2" />
</value>
</option>
</attributes>
```

- Light Theme
## Syntax highlighting and colouring

```
<option name="TYPEQL_AGGREGATE">
<value>
<option name="FOREGROUND" value="fb3196" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
<option name="TYPEQL_BOOLEAN">
<value>
<option name="FOREGROUND" value="ff6b00" />
</value>
</option>
<option name="TYPEQL_IDENTIFIER">
<value>
<option name="FOREGROUND" value="392d67" />
</value>
</option>
<option name="TYPEQL_KEYWORD">
<value>
<option name="FOREGROUND" value="fb3196" />
</value>
</option>
<option name="TYPEQL_ANNOTATION">
<value>
<option name="FOREGROUND" value="ff6b00" />
</value>
</option>
<option name="TYPEQL_LINE_COMMENT">
<value>
<option name="FOREGROUND" value="309c59" />
</value>
</option>
<option name="TYPEQL_NUMBER">
<value>
<option name="FOREGROUND" value="82b6ff" />
</value>
</option>
<option name="TYPEQL_STRING">
<value>
<option name="FOREGROUND" value="f1be05" />
</value>
</option>
<option name="TYPEQL_THING">
<value>
<option name="FOREGROUND" value="28c9c0" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
<option name="TYPEQL_TYPE">
<value>
<option name="FOREGROUND" value="82b6ff" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
<option name="TYPEQL_VAR">
<value>
<option name="FOREGROUND" value="28c9c0" />
</value>
</option>
</attributes>
```
JetBrains Color Scheme-based syntax highlighting automatically works out of the box. However, it is possible to import TypeDB-specific color schemes used in [TypeDB Studio](https://typedb.com/docs/typedb/connecting/studio) by downloading the needed color scheme files from the corresponding [resource directory](https://github.com/typedb-osi/typeql-plugin-jetbrains/tree/master/src/main/resources) and importing it in the IDE via `Preferences → Editor → Color Scheme → Import Scheme`.

## Information

Expand Down
11 changes: 2 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
fun properties(key: String) = project.findProperty(key).toString()

plugins {
id("antlr")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.9.10"
// Gradle IntelliJ Plugin
Expand All @@ -21,11 +20,12 @@ version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
maven(url = "https://repo.typedb.com/public/public-release/maven/")
}

dependencies {
antlr("org.antlr:antlr4:4.7.1")
implementation("org.antlr:antlr4-intellij-adaptor:0.1")
implementation("com.vaticle.typeql:typeql-grammar:2.26.6")
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
Expand Down Expand Up @@ -122,11 +122,4 @@ tasks {
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
}

generateGrammarSource {
outputDirectory = file("build/generated-src/antlr/main/org/typedb/typeql/plugin/jetbrains")
arguments = mutableListOf("-package", "org.typedb.typeql.plugin.jetbrains", "-visitor")
}
getByName("compileKotlin").dependsOn("generateGrammarSource")
getByName("compileTestKotlin").dependsOn("generateTestGrammarSource")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = org.typedb.typeql.plugin.jetbrains
pluginName = typeql-plugin-jetbrains
pluginVersion = 0.1.2
pluginVersion = 0.2.0

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
Loading

0 comments on commit 3360d8d

Please sign in to comment.