Skip to content

Commit

Permalink
Support the extern keyword (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks authored May 23, 2023
1 parent a107041 commit c5915b6
Show file tree
Hide file tree
Showing 36 changed files with 937 additions and 774 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:

# Run Qodana inspections
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@v2022.2.1
uses: JetBrains/qodana-action@v2023.1.0

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# FacilityIntellij Changelog

## [Unreleased]
- Added support for the 2023.1 Intellij platform
- Added support for the `extern` keyword

## [1.1.2]
- Added support for the 2023.1 Intellij platform
Expand Down
14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.7.10"
id("org.jetbrains.kotlin.jvm") version "1.8.21"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.9.0"
id("org.jetbrains.intellij") version "1.13.3"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
id("org.jetbrains.changelog") version "2.0.0"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
// Gradle GrammarKit Plugin
id("org.jetbrains.grammarkit") version "2021.2.2"
// ktlint Plugin
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
}

group = properties("pluginGroup")
Expand Down Expand Up @@ -100,7 +100,7 @@ tasks {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
}.joinToString("\n").run { markdownToHTML(this) },
)

// Get the latest available change notes from the changelog file
Expand All @@ -109,7 +109,7 @@ tasks {
changelog.run {
getOrNull(properties("pluginVersion")) ?: getLatest()
}.toHTML()
}
},
)
}

Expand Down Expand Up @@ -143,5 +143,5 @@ tasks {
}

ktlint {
version.set("0.45.2")
version.set("0.48.1")
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = io.github.facilityapi
pluginName = FacilityIntellij
pluginVersion = 1.1.2
pluginVersion = 1.2.0

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand All @@ -26,7 +26,7 @@ platformPlugins =
# Java 17 will be required when targeting 2022.2
javaVersion = 11

gradleVersion = 7.5.1
gradleVersion = 8.1.1

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
Expand Down
1,439 changes: 743 additions & 696 deletions src/main/gen/io/github/facilityapi/intellij/lexer/_FsdLexer.java

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions src/main/gen/io/github/facilityapi/intellij/parser/FsdParser.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/main/gen/io/github/facilityapi/intellij/psi/FsdExternDecl.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/main/gen/io/github/facilityapi/intellij/psi/FsdTypes.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ class FsdColorSettingsPage : ColorSettingsPage {
private val DESCRIPTORS = arrayOf(
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.markup"),
FsdSyntaxHighlighter.MARKUP_HEADING_KEYS[0]
FsdSyntaxHighlighter.MARKUP_HEADING_KEYS[0],
),
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.comment"),
FsdSyntaxHighlighter.COMMENT_KEYS[0]
FsdSyntaxHighlighter.COMMENT_KEYS[0],
),
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.keyword"),
FsdSyntaxHighlighter.KEYWORD_KEYS[0]
FsdSyntaxHighlighter.KEYWORD_KEYS[0],
),
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.primitive"),
FsdSyntaxHighlighter.PRIMITIVE_TYPE_KEYS[0]
FsdSyntaxHighlighter.PRIMITIVE_TYPE_KEYS[0],
),
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.typeref"),
FsdSyntaxHighlighter.TYPE_REFERENCE_KEYS[0]
FsdSyntaxHighlighter.TYPE_REFERENCE_KEYS[0],
),
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.attribute"),
FsdSyntaxHighlighter.ATTRIBUTE_NAME_KEYS[0]
FsdSyntaxHighlighter.ATTRIBUTE_NAME_KEYS[0],
),
AttributesDescriptor(
FsdBundle.getMessage("settings.color.displayname.attributeparametervalue"),
FsdSyntaxHighlighter.ATTRIBUTE_ARGUMENT_KEYS[0]
FsdSyntaxHighlighter.ATTRIBUTE_ARGUMENT_KEYS[0],
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FsdCompletionContributor : CompletionContributor() {
override fun addCompletions(
parameters: CompletionParameters,
context: ProcessingContext,
resultSet: CompletionResultSet
resultSet: CompletionResultSet,
) {
resultSet.addElement(LookupElementBuilder.create("string"))
resultSet.addElement(LookupElementBuilder.create("boolean"))
Expand All @@ -35,7 +35,7 @@ class FsdCompletionContributor : CompletionContributor() {
resultSet.addElement(LookupElementBuilder.create("nullable"))
resultSet.addElement(LookupElementBuilder.create("error"))
}
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ class FsdSyntaxHighlighter : SyntaxHighlighterBase() {
FsdTypes.MAP,
FsdTypes.RESULT,
FsdTypes.NULLABLE,
FsdTypes.ERROR -> PRIMITIVE_TYPE_KEYS
FsdTypes.ERROR,
-> PRIMITIVE_TYPE_KEYS

FsdTypes.TYPENAME -> TYPE_REFERENCE_KEYS

FsdTypes.SERVICE,
FsdTypes.DATA,
FsdTypes.METHOD,
FsdTypes.ENUM,
FsdTypes.ERRORS -> KEYWORD_KEYS
FsdTypes.ERRORS,
FsdTypes.EXTERN,
-> KEYWORD_KEYS

else -> emptyArray()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FsdBlock(
node: ASTNode,
wrap: Wrap?,
alignment: Alignment?,
private val codeStyleSettings: CodeStyleSettings
private val codeStyleSettings: CodeStyleSettings,
) : AbstractBlock(node, wrap, alignment), BlockWithParent {

private var parent: BlockWithParent? = null
Expand Down Expand Up @@ -72,7 +72,9 @@ class FsdBlock(
return if (reversedBlocks.any { (it as ASTBlock).node?.elementType == FsdTypes.LEFT_BRACE }) {
val f = if (previousBlock?.node?.elementType == FsdTypes.RIGHT_BRACKET) {
reversedBlocks.firstOrNull { (it as ASTBlock).node?.elementType == FsdTypes.LEFT_BRACKET }
} else null
} else {
null
}
ChildAttributes(Indent.getNormalIndent(), f?.alignment)
} else {
ChildAttributes(Indent.getNoneIndent(), alignment)
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/io/github/facilityapi/intellij/fsd.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ definition ::= (attribute_list* service_spec) markdown_remarks*
service_spec ::= service identifier service_items { pin=1 }
service_items ::= ('{' decorated_service_item* '}') | decorated_service_item
decorated_service_item ::= attribute_list* service_item
private service_item ::= (enum_spec | data_spec | method_spec | error_set_spec) { recoverWhile=service_item_recover }
private service_item_recover ::= !('[' | '}' | enum | data | errors | method)
private service_item ::= (extern_decl | enum_spec | data_spec | method_spec | error_set_spec) { recoverWhile=service_item_recover }
private service_item_recover ::= !('[' | '}' | extern | enum | data | errors | method)

private field_list ::= '{' (comment+ | decorated_field)* '}' { pin=1 }

Expand Down Expand Up @@ -79,6 +79,8 @@ attribute_parameters ::= '(' attribute_parameter (',' attribute_parameter)* ')'
attribute_parameter ::= identifier ':' attribute_parameter_value
private attribute_parameter_value ::= attributeparametervalue { name="attribute parameter value" }

extern_decl ::= extern (data | enum) identifier ';'

decorated_field ::= attribute_list* field { pin=2 }
field ::= identifier ':' type [ '!' ] ';' { pin=3 }
type ::= (string | boolean | int32 | int64 | double | decimal | bytes | object | map | result | error | nullable | reference_type) [ type_parameter ] [ ('['']')* ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DuplicateAttributeInspection : LocalInspectionTool() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
session: LocalInspectionToolSession,
): PsiElementVisitor = object : PsiElementVisitor() {
private val deleteAttributeFix = DeleteAttributeFix()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DuplicateMemberInspection : LocalInspectionTool() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
session: LocalInspectionToolSession,
): PsiElementVisitor = object : PsiElementVisitor() {
private val fix = Fix()

Expand Down
Loading

0 comments on commit c5915b6

Please sign in to comment.