backport: 20.1.0
This commit is contained in:
parent
808d82b44f
commit
323ba12fbc
7 changed files with 62 additions and 7 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -17,6 +17,18 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [20.1.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Zig
|
||||||
|
- String, character literal, and `@"identifier"` quote matching
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Zon
|
||||||
|
- Broken string quote handling
|
||||||
|
|
||||||
## [20.0.4]
|
## [20.0.4]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -165,6 +165,8 @@
|
||||||
|
|
||||||
STRING_LITERAL_SINGLE='quoted string literal'
|
STRING_LITERAL_SINGLE='quoted string literal'
|
||||||
STRING_LITERAL_MULTI='multiline string literal'
|
STRING_LITERAL_MULTI='multiline string literal'
|
||||||
|
BAD_SQUOT='unterminated character literal'
|
||||||
|
BAD_DQUOT='unterminated string'
|
||||||
|
|
||||||
IDENTIFIER='identifier'
|
IDENTIFIER='identifier'
|
||||||
BUILTINIDENTIFIER='builtin identifier'
|
BUILTINIDENTIFIER='builtin identifier'
|
||||||
|
|
|
@ -80,7 +80,8 @@ BUILTINIDENTIFIER="@"[A-Za-z_][A-Za-z0-9_]*
|
||||||
%state CHAR_LIT
|
%state CHAR_LIT
|
||||||
|
|
||||||
%state ID_QUOT
|
%state ID_QUOT
|
||||||
%state UNT_QUOT
|
%state UNT_SQUOT
|
||||||
|
%state UNT_DQUOT
|
||||||
|
|
||||||
%state CDOC_CMT
|
%state CDOC_CMT
|
||||||
%state DOC_CMT
|
%state DOC_CMT
|
||||||
|
@ -221,14 +222,14 @@ BUILTINIDENTIFIER="@"[A-Za-z_][A-Za-z0-9_]*
|
||||||
|
|
||||||
<YYINITIAL> "'" { yybegin(CHAR_LIT); }
|
<YYINITIAL> "'" { yybegin(CHAR_LIT); }
|
||||||
<CHAR_LIT> {char_char}*"'" { yybegin(YYINITIAL); return CHAR_LITERAL; }
|
<CHAR_LIT> {char_char}*"'" { yybegin(YYINITIAL); return CHAR_LITERAL; }
|
||||||
<CHAR_LIT> [^] { yypushback(1); yybegin(UNT_QUOT); }
|
<CHAR_LIT> [^] { yypushback(1); yybegin(UNT_SQUOT); }
|
||||||
|
|
||||||
<YYINITIAL> {FLOAT} { return FLOAT; }
|
<YYINITIAL> {FLOAT} { return FLOAT; }
|
||||||
<YYINITIAL> {INTEGER} { return INTEGER; }
|
<YYINITIAL> {INTEGER} { return INTEGER; }
|
||||||
|
|
||||||
<YYINITIAL> "\"" { yybegin(STR_LIT); }
|
<YYINITIAL> "\"" { yybegin(STR_LIT); }
|
||||||
<STR_LIT> {string_char}*"\"" { yybegin(YYINITIAL); return STRING_LITERAL_SINGLE; }
|
<STR_LIT> {string_char}*"\"" { yybegin(YYINITIAL); return STRING_LITERAL_SINGLE; }
|
||||||
<STR_LIT> [^] { yypushback(1); yybegin(UNT_QUOT); }
|
<STR_LIT> [^] { yypushback(1); yybegin(UNT_DQUOT); }
|
||||||
<YYINITIAL> "\\\\" { yybegin(STR_MULT_LINE); }
|
<YYINITIAL> "\\\\" { yybegin(STR_MULT_LINE); }
|
||||||
<STR_MULT_LINE> {all_nl_wrap} "\\\\" { }
|
<STR_MULT_LINE> {all_nl_wrap} "\\\\" { }
|
||||||
<STR_MULT_LINE> {all_nl_nowrap} { yybegin(YYINITIAL); return STRING_LITERAL_MULTI; }
|
<STR_MULT_LINE> {all_nl_nowrap} { yybegin(YYINITIAL); return STRING_LITERAL_MULTI; }
|
||||||
|
@ -236,11 +237,12 @@ BUILTINIDENTIFIER="@"[A-Za-z_][A-Za-z0-9_]*
|
||||||
<YYINITIAL> {IDENTIFIER_PLAIN} { return IDENTIFIER; }
|
<YYINITIAL> {IDENTIFIER_PLAIN} { return IDENTIFIER; }
|
||||||
<YYINITIAL> "@\"" { yybegin(ID_QUOT); }
|
<YYINITIAL> "@\"" { yybegin(ID_QUOT); }
|
||||||
<ID_QUOT> {string_char}*"\"" { yybegin(YYINITIAL); return IDENTIFIER; }
|
<ID_QUOT> {string_char}*"\"" { yybegin(YYINITIAL); return IDENTIFIER; }
|
||||||
<ID_QUOT> [^] { yypushback(1); yybegin(UNT_QUOT); }
|
<ID_QUOT> [^] { yypushback(1); yybegin(UNT_DQUOT); }
|
||||||
|
|
||||||
<YYINITIAL> {BUILTINIDENTIFIER} { return BUILTINIDENTIFIER; }
|
<YYINITIAL> {BUILTINIDENTIFIER} { return BUILTINIDENTIFIER; }
|
||||||
|
|
||||||
<UNT_QUOT> [^\n]*{CRLF} { yybegin(YYINITIAL); return BAD_CHARACTER; }
|
<UNT_SQUOT> [^\n]*{CRLF} { yybegin(YYINITIAL); return BAD_SQUOT; }
|
||||||
|
<UNT_DQUOT> [^\n]*{CRLF} { yybegin(YYINITIAL); return BAD_DQUOT; }
|
||||||
|
|
||||||
<YYINITIAL> {WHITE_SPACE} { return WHITE_SPACE; }
|
<YYINITIAL> {WHITE_SPACE} { return WHITE_SPACE; }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ZigBrains.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023-2024 FalsePattern
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* ZigBrains is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, only version 3 of the License.
|
||||||
|
*
|
||||||
|
* ZigBrains is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with ZigBrains. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.falsepattern.zigbrains.zig.pairing
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.zig.psi.ZigTypes
|
||||||
|
import com.intellij.codeInsight.editorActions.MultiCharQuoteHandler
|
||||||
|
import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler
|
||||||
|
import com.intellij.openapi.editor.highlighter.HighlighterIterator
|
||||||
|
|
||||||
|
class ZigQuoteHandler: SimpleTokenSetQuoteHandler(ZigTypes.STRING_LITERAL_SINGLE, ZigTypes.IDENTIFIER, ZigTypes.BAD_DQUOT, ZigTypes.CHAR_LITERAL, ZigTypes.BAD_SQUOT), MultiCharQuoteHandler {
|
||||||
|
override fun getClosingQuote(iterator: HighlighterIterator, offset: Int) = when(iterator.tokenType) {
|
||||||
|
ZigTypes.STRING_LITERAL_SINGLE, ZigTypes.IDENTIFIER, ZigTypes.BAD_DQUOT -> "\""
|
||||||
|
ZigTypes.CHAR_LITERAL, ZigTypes.BAD_SQUOT -> "'"
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ import com.intellij.codeInsight.editorActions.MultiCharQuoteHandler
|
||||||
import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler
|
import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler
|
||||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator
|
import com.intellij.openapi.editor.highlighter.HighlighterIterator
|
||||||
|
|
||||||
class ZonQuoteHandler: SimpleTokenSetQuoteHandler(ZonTypes.STRING_LITERAL, ZonTypes.BAD_STRING), MultiCharQuoteHandler {
|
class ZonQuoteHandler: SimpleTokenSetQuoteHandler(ZonTypes.STRING_LITERAL_SINGLE, ZonTypes.BAD_STRING), MultiCharQuoteHandler {
|
||||||
override fun getClosingQuote(iterator: HighlighterIterator, offset: Int) =
|
override fun getClosingQuote(iterator: HighlighterIterator, offset: Int) =
|
||||||
"\""
|
"\""
|
||||||
}
|
}
|
|
@ -22,6 +22,9 @@
|
||||||
<lang.parserDefinition
|
<lang.parserDefinition
|
||||||
language="Zig"
|
language="Zig"
|
||||||
implementationClass="com.falsepattern.zigbrains.zig.parser.ZigParserDefinition"/>
|
implementationClass="com.falsepattern.zigbrains.zig.parser.ZigParserDefinition"/>
|
||||||
|
<lang.quoteHandler
|
||||||
|
language="Zig"
|
||||||
|
implementationClass="com.falsepattern.zigbrains.zig.pairing.ZigQuoteHandler"/>
|
||||||
<lang.syntaxHighlighterFactory
|
<lang.syntaxHighlighterFactory
|
||||||
language="Zig"
|
language="Zig"
|
||||||
implementationClass="com.falsepattern.zigbrains.zig.highlighter.ZigSyntaxHighlighterFactory"/>
|
implementationClass="com.falsepattern.zigbrains.zig.highlighter.ZigSyntaxHighlighterFactory"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
pluginName=ZigBrains
|
pluginName=ZigBrains
|
||||||
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
|
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
|
||||||
|
|
||||||
pluginVersion=20.0.4
|
pluginVersion=20.1.0
|
||||||
|
|
||||||
pluginSinceBuild=241
|
pluginSinceBuild=241
|
||||||
pluginUntilBuild=241.*
|
pluginUntilBuild=241.*
|
||||||
|
|
Loading…
Add table
Reference in a new issue