diff --git a/headless-services/commons/java-properties/generate-parser.sh b/headless-services/commons/java-properties/generate-parser.sh index 7743c0583..2a18e3d49 100755 --- a/headless-services/commons/java-properties/generate-parser.sh +++ b/headless-services/commons/java-properties/generate-parser.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -ANTLR_VERSION=4.5.3 +ANTLR_VERSION=4.9.3 if [ ! -f antlr-${ANTLR_VERSION}.jar ]; then curl https://www.antlr.org/download/antlr-${ANTLR_VERSION}-complete.jar --output antlr-${ANTLR_VERSION}.jar fi diff --git a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens deleted file mode 100644 index 10b03ebab..000000000 --- a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens +++ /dev/null @@ -1,13 +0,0 @@ -Backslash=1 -Colon=2 -Equals=3 -Exclamation=4 -Number=5 -LineBreak=6 -Space=7 -IdentifierChar=8 -'\\'=1 -':'=2 -'='=3 -'!'=4 -'#'=5 diff --git a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesBaseListener.java b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesBaseListener.java index f114acbe6..9548b6c12 100644 --- a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesBaseListener.java +++ b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesBaseListener.java @@ -1,4 +1,4 @@ -// Generated from JavaProperties.g4 by ANTLR 4.5.3 +// Generated from JavaProperties.g4 by ANTLR 4.9.3 package org.springframework.ide.vscode.java.properties.antlr.parser; import org.antlr.v4.runtime.ParserRuleContext; diff --git a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java index 984564aff..ac286875f 100644 --- a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java +++ b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java @@ -1,4 +1,4 @@ -// Generated from JavaProperties.g4 by ANTLR 4.5.3 +// Generated from JavaProperties.g4 by ANTLR 4.9.3 package org.springframework.ide.vscode.java.properties.antlr.parser; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; @@ -11,7 +11,7 @@ import org.antlr.v4.runtime.misc.*; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class JavaPropertiesLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); } + static { RuntimeMetaData.checkVersion("4.9.3", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = @@ -19,22 +19,35 @@ public class JavaPropertiesLexer extends Lexer { public static final int Backslash=1, Colon=2, Equals=3, Exclamation=4, Number=5, LineBreak=6, Space=7, IdentifierChar=8; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + public static String[] modeNames = { "DEFAULT_MODE" }; - public static final String[] ruleNames = { - "Backslash", "Colon", "Equals", "Exclamation", "Number", "LineBreak", - "Space", "IdentifierChar" - }; + private static String[] makeRuleNames() { + return new String[] { + "Backslash", "Colon", "Equals", "Exclamation", "Number", "LineBreak", + "Space", "IdentifierChar" + }; + } + public static final String[] ruleNames = makeRuleNames(); - private static final String[] _LITERAL_NAMES = { - null, "'\\'", "':'", "'='", "'!'", "'#'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, "Backslash", "Colon", "Equals", "Exclamation", "Number", "LineBreak", - "Space", "IdentifierChar" - }; + private static String[] makeLiteralNames() { + return new String[] { + null, "'\\'", "':'", "'='", "'!'", "'#'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "Backslash", "Colon", "Equals", "Exclamation", "Number", "LineBreak", + "Space", "IdentifierChar" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** @@ -83,6 +96,9 @@ public class JavaPropertiesLexer extends Lexer { @Override public String getSerializedATN() { return _serializedATN; } + @Override + public String[] getChannelNames() { return channelNames; } + @Override public String[] getModeNames() { return modeNames; } @@ -90,18 +106,18 @@ public class JavaPropertiesLexer extends Lexer { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2\n(\b\1\4\2\t\2\4"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\n(\b\1\4\2\t\2\4"+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\3\2\3\2\3\3\3\3"+ "\3\4\3\4\3\5\3\5\3\6\3\6\3\7\5\7\37\n\7\3\7\3\7\5\7#\n\7\3\b\3\b\3\t\3"+ "\t\2\2\n\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\3\2\4\5\2\13\13\16\16\"\""+ - "\7\2\f\f\17\17\"\"< line() { @@ -316,7 +326,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( !(_la==Exclamation || _la==Number) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } setState(53); @@ -329,7 +342,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( _la <= 0 || (_la==LineBreak) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } } @@ -342,7 +358,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( !(_la==EOF || _la==LineBreak) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } } @@ -452,7 +471,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( !(_la==EOF || _la==LineBreak) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } } @@ -548,6 +570,7 @@ public class JavaPropertiesParser extends Parser { int _la; try { setState(78); + _errHandler.sync(this); switch (_input.LA(1)) { case IdentifierChar: enterOuterAlt(_localctx, 1); @@ -565,7 +588,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( !(_la==Colon || _la==Equals) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } } @@ -620,7 +646,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Colon) | (1L << Equals) | (1L << Space))) != 0)) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } setState(84); @@ -680,6 +709,7 @@ public class JavaPropertiesParser extends Parser { enterRule(_localctx, 18, RULE_valueChar); try { setState(95); + _errHandler.sync(this); switch (_input.LA(1)) { case IdentifierChar: enterOuterAlt(_localctx, 1); @@ -781,7 +811,10 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Backslash) | (1L << Colon) | (1L << Equals) | (1L << Exclamation) | (1L << Number) | (1L << LineBreak) | (1L << Space) | (1L << IdentifierChar))) != 0)) ) { _errHandler.recoverInline(this); - } else { + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } } @@ -798,7 +831,7 @@ public class JavaPropertiesParser extends Parser { } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\nf\4\2\t\2\4\3\t"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\nf\4\2\t\2\4\3\t"+ "\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4"+ "\f\t\f\3\2\7\2\32\n\2\f\2\16\2\35\13\2\3\2\3\2\3\3\3\3\3\3\5\3$\n\3\3"+ "\4\7\4\'\n\4\f\4\16\4*\13\4\3\4\3\4\3\5\7\5/\n\5\f\5\16\5\62\13\5\3\5"+ @@ -806,24 +839,24 @@ public class JavaPropertiesParser extends Parser { "\3\6\3\7\3\7\3\7\3\7\3\b\6\bJ\n\b\r\b\16\bK\3\t\3\t\3\t\5\tQ\n\t\3\n\3"+ "\n\7\nU\n\n\f\n\16\nX\13\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\5\13"+ "b\n\13\3\f\3\f\3\f\2\2\r\2\4\6\b\n\f\16\20\22\24\26\2\b\3\2\6\7\3\2\b"+ - "\b\3\3\b\b\3\2\4\5\4\2\4\5\t\t\3\2\3\nj\2\33\3\2\2\2\4#\3\2\2\2\6(\3\2"+ - "\2\2\b\60\3\2\2\2\n?\3\2\2\2\fD\3\2\2\2\16I\3\2\2\2\20P\3\2\2\2\22R\3"+ - "\2\2\2\24a\3\2\2\2\26c\3\2\2\2\30\32\5\4\3\2\31\30\3\2\2\2\32\35\3\2\2"+ - "\2\33\31\3\2\2\2\33\34\3\2\2\2\34\36\3\2\2\2\35\33\3\2\2\2\36\37\7\2\2"+ - "\3\37\3\3\2\2\2 $\5\6\4\2!$\5\b\5\2\"$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\7\4\2\2aY\3\2\2\2aZ\3\2"+ + "\2\2a[\3\2\2\2a\\\3\2\2\2a]\3\2\2\2a_\3\2\2\2a`\3\2\2\2b\25\3\2\2\2cd"+ + "\t\7\2\2d\27\3\2\2\2\f\33#(\60\67?KPVa"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/headless-services/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java b/headless-services/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java index c01b39159..79cf5b3f8 100644 --- a/headless-services/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java +++ b/headless-services/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java @@ -39,7 +39,7 @@ public class PropertiesAntlrParserTest { assertEquals(1, commentLines.size()); Comment comment = commentLines.get(0); - assertEquals(expectedComment, text.substring(comment.getOffset(), comment.getOffset() + comment.getLength())); + assertEquals(expectedComment, text.substring(comment.getOffset(), comment.getOffset() + comment.getLength() - 1)); } private void testPropertyLine(String text,