Skip to content

Commit

Permalink
Fix auto suggest of property
Browse files Browse the repository at this point in the history
  • Loading branch information
kizeevov committed Feb 21, 2025
1 parent 6b21af7 commit d467ae9
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## [Unreleased]

### Fixed

- Fixed auto suggest of property ([issue 72](https://github.com/kizeevov/slint-idea-plugin/issues/72))

## [1.4.1] - 2025-01-18

### Features
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginRepositoryUrl = https://github.com/kizeevov/slint-idea-plugin

pluginGroup = dev.slint
pluginName = SlintPlugin
pluginVersion = 1.4.1
pluginVersion = 1.4.2
platformType = IU
platformVersion = 2024.1
pluginSinceBuild = 241
Expand Down
1 change: 0 additions & 1 deletion src/main/grammars/SlintLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ DOC_COMMENT="/"\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+"/"
{NUMERIC_LITERAL} { return NUMERIC_LITERAL; }
{COLOR_LITERAL} { return COLOR_LITERAL; }
{IDENTIFIER} { return IDENTIFIER; }
{PROPERTY_IDENTIFIER} { return PROPERTY_IDENTIFIER; }
{WHITE_SPACE} { return WHITE_SPACE; }
{LINE_COMMENT} { return LINE_COMMENT; }
{DOC_COMMENT} { return DOC_COMMENT; }
Expand Down
5 changes: 3 additions & 2 deletions src/main/grammars/SlintParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
NUMERIC_LITERAL = 'regexp:-?\d+(\.\d+)?'
COLOR_LITERAL = 'regexp:#([A-Fa-f0-9]{6,8}|[A-Fa-f0-9]{3,4})'
IDENTIFIER = 'regexp:[a-zA-Z][a-zA-Z0-9\-_]*'
PROPERTY_IDENTIFIER = 'regexp:([a-zA-Z][a-zA-Z0-9\-_]*[\\.])+[a-zA-Z0-9\-_]*'
WHITE_SPACE = 'regexp:\s+'

LINE_COMMENT = 'regexp://.*'
Expand Down Expand Up @@ -446,7 +445,9 @@ TernaryExpression ::= Expression '?' TernaryExpressionThen { pin=2 }
private TernaryExpressionThen ::= Expression ':' TernaryExpressionElse
private TernaryExpressionElse ::= Expression

PropertyExpression ::= IDENTIFIER | PROPERTY_IDENTIFIER
PropertyExpression ::= PropertyExpressionComposite | Identifier
PropertyExpressionComposite ::= Identifier '.' Identifier { pin=3 }

LiteralExpression ::=
LengthLiteral
| PhysicalLengthLiteral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class SlintSyntaxHighlighter : SyntaxHighlighterBase() {
put(SlintElementTypes.STRING_LITERAL, SlintColors.STRING_LITERAL)
put(SlintElementTypes.COLOR_LITERAL, SlintColors.NUMBER)

// put(SlintElementTypes.COLONEQ, SlintColors.OPERATION_SIGN)
put(SlintElementTypes.EQ, SlintColors.OPERATION_SIGN)

fillMap(this, SLINT_KEYWORDS, SlintColors.KEYWORD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,4 @@ class SlintLspCompletionSupport : LspCompletionSupport() {
override fun getIcon(item: CompletionItem): Icon {
return super.getIcon(item) ?: SlintIcons.SLINT
}

override fun createLookupElement(parameters: CompletionParameters, item: CompletionItem): LookupElement? {
val lookupElement = super.createLookupElement(parameters, item) as LookupElementBuilder

if (item.kind == CompletionItemKind.Property) {
return lookupElement.withInsertHandler { context, _ ->
EditorModificationUtil.insertStringAtCaret(context.editor, ": ;", false, 2)
}
}

return lookupElement
}
}

0 comments on commit d467ae9

Please sign in to comment.