diff --git a/.gitignore b/.gitignore index b52ad7292..4d366f7ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,24 @@ -*.class -**/.classpath - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear -# Exceptions -!**/.mvn/wrapper/maven-wrapper.jar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -target/ -*.log - -# Mac OSX aux files -.DS_Store +*.class +**/.classpath +**/.idea +**/*.iml + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +# Exceptions +!**/.mvn/wrapper/maven-wrapper.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +target/ +*.log + +# Mac OSX aux files +.DS_Store **/.DS_Store \ No newline at end of file diff --git a/vscode-extensions/commons/java-properties/resources/JavaProperties.g4 b/vscode-extensions/commons/java-properties/resources/JavaProperties.g4 index 5c075b355..3ebd00c38 100644 --- a/vscode-extensions/commons/java-properties/resources/JavaProperties.g4 +++ b/vscode-extensions/commons/java-properties/resources/JavaProperties.g4 @@ -31,7 +31,7 @@ propertyLine ; commentLine - : Space* Comment (LineBreak | EOF) + : Space* (Exclamation | Number) ~(LineBreak)* (LineBreak | EOF) ; emptyLine @@ -57,7 +57,9 @@ separatorAndValue valueChar : IdentifierChar - | Space + | Exclamation + | Number + | Space | Backslash LineBreak | Equals | Colon @@ -66,10 +68,8 @@ valueChar Backslash : '\\'; Colon : ':'; Equals : '='; - -Comment - : ('!' | '#') ~('\r' | '\n')* - ; +Exclamation: '!'; +Number : '#'; LineBreak : '\r'? '\n' @@ -83,6 +83,5 @@ Space ; IdentifierChar - : ~([ :=\\\r('\r'? '\n')]) + : ~(' ' | ':' | '=' | '\r' | '\n' ) ; - \ No newline at end of file diff --git a/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java b/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java index c380c636d..579eb0772 100644 --- a/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java +++ b/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java @@ -177,15 +177,18 @@ public class AntlrParser implements Parser { public Comment(CommentLineContext context) { this.context = context; } - + @Override public int getOffset() { - return context.Comment().getSymbol().getStartIndex(); + int i = 0; + String text = context.getText(); + for (; i < context.getText().length() && Character.isWhitespace(text.charAt(i)); i++); + return context.getStart().getStartIndex() + i; } @Override public int getLength() { - return context.Comment().getSymbol().getStopIndex() - getOffset() + 1; + return context.getStop().getStartIndex() - getOffset() + 1; } } diff --git a/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens b/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens index fe8593417..10b03ebab 100644 --- a/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens +++ b/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaProperties.tokens @@ -1,10 +1,13 @@ Backslash=1 Colon=2 Equals=3 -Comment=4 -LineBreak=5 -Space=6 -IdentifierChar=7 +Exclamation=4 +Number=5 +LineBreak=6 +Space=7 +IdentifierChar=8 '\\'=1 ':'=2 '='=3 +'!'=4 +'#'=5 diff --git a/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java b/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java index 018a1478d..984564aff 100644 --- a/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java +++ b/vscode-extensions/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesLexer.java @@ -17,21 +17,23 @@ public class JavaPropertiesLexer extends Lexer { protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int - Backslash=1, Colon=2, Equals=3, Comment=4, LineBreak=5, Space=6, IdentifierChar=7; + Backslash=1, Colon=2, Equals=3, Exclamation=4, Number=5, LineBreak=6, + Space=7, IdentifierChar=8; public static String[] modeNames = { "DEFAULT_MODE" }; public static final String[] ruleNames = { - "Backslash", "Colon", "Equals", "Comment", "LineBreak", "Space", "IdentifierChar" + "Backslash", "Colon", "Equals", "Exclamation", "Number", "LineBreak", + "Space", "IdentifierChar" }; private static final String[] _LITERAL_NAMES = { - null, "'\\'", "':'", "'='" + null, "'\\'", "':'", "'='", "'!'", "'#'" }; private static final String[] _SYMBOLIC_NAMES = { - null, "Backslash", "Colon", "Equals", "Comment", "LineBreak", "Space", - "IdentifierChar" + null, "Backslash", "Colon", "Equals", "Exclamation", "Number", "LineBreak", + "Space", "IdentifierChar" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -88,19 +90,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\t)\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\3\2\3\2\3\3\3\3\3\4\3\4"+ - "\3\5\3\5\7\5\32\n\5\f\5\16\5\35\13\5\3\6\5\6 \n\6\3\6\3\6\5\6$\n\6\3\7"+ - "\3\7\3\b\3\b\2\2\t\3\3\5\4\7\5\t\6\13\7\r\b\17\t\3\2\6\4\2##%%\4\2\f\f"+ - "\17\17\5\2\13\13\16\16\"\"\n\2\f\f\17\17\"\")+< LineBreak() { return getTokens(JavaPropertiesParser.LineBreak); } + public TerminalNode LineBreak(int i) { + return getToken(JavaPropertiesParser.LineBreak, i); + } public TerminalNode EOF() { return getToken(JavaPropertiesParser.EOF, 0); } public List Space() { return getTokens(JavaPropertiesParser.Space); } public TerminalNode Space(int i) { @@ -308,8 +313,32 @@ public class JavaPropertiesParser extends Parser { _la = _input.LA(1); } setState(47); - match(Comment); - setState(48); + _la = _input.LA(1); + if ( !(_la==Exclamation || _la==Number) ) { + _errHandler.recoverInline(this); + } else { + consume(); + } + setState(51); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Backslash) | (1L << Colon) | (1L << Equals) | (1L << Exclamation) | (1L << Number) | (1L << Space) | (1L << IdentifierChar))) != 0)) { + { + { + setState(48); + _la = _input.LA(1); + if ( _la <= 0 || (_la==LineBreak) ) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } + setState(53); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(54); _la = _input.LA(1); if ( !(_la==EOF || _la==LineBreak) ) { _errHandler.recoverInline(this); @@ -356,21 +385,21 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(53); + setState(59); _errHandler.sync(this); _la = _input.LA(1); while (_la==Space) { { { - setState(50); + setState(56); match(Space); } } - setState(55); + setState(61); _errHandler.sync(this); _la = _input.LA(1); } - setState(56); + setState(62); match(LineBreak); } } @@ -415,11 +444,11 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(58); + setState(64); key(); - setState(59); + setState(65); separatorAndValue(); - setState(60); + setState(66); _la = _input.LA(1); if ( !(_la==EOF || _la==LineBreak) ) { _errHandler.recoverInline(this); @@ -467,17 +496,17 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(63); + setState(69); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(62); + setState(68); keyChar(); } } - setState(65); + setState(71); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Backslash || _la==IdentifierChar ); @@ -518,21 +547,21 @@ public class JavaPropertiesParser extends Parser { enterRule(_localctx, 14, RULE_keyChar); int _la; try { - setState(70); + setState(76); switch (_input.LA(1)) { case IdentifierChar: enterOuterAlt(_localctx, 1); { - setState(67); + setState(73); match(IdentifierChar); } break; case Backslash: enterOuterAlt(_localctx, 2); { - setState(68); + setState(74); match(Backslash); - setState(69); + setState(75); _la = _input.LA(1); if ( !(_la==Colon || _la==Equals) ) { _errHandler.recoverInline(this); @@ -587,27 +616,27 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(72); + setState(78); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Colon) | (1L << Equals) | (1L << Space))) != 0)) ) { _errHandler.recoverInline(this); } else { consume(); } - setState(74); + setState(80); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(73); + setState(79); valueChar(); } } - setState(76); + setState(82); _errHandler.sync(this); _la = _input.LA(1); - } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Backslash) | (1L << Colon) | (1L << Equals) | (1L << Space) | (1L << IdentifierChar))) != 0) ); + } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Backslash) | (1L << Colon) | (1L << Equals) | (1L << Exclamation) | (1L << Number) | (1L << Space) | (1L << IdentifierChar))) != 0) ); } } catch (RecognitionException re) { @@ -623,6 +652,8 @@ public class JavaPropertiesParser extends Parser { public static class ValueCharContext extends ParserRuleContext { public TerminalNode IdentifierChar() { return getToken(JavaPropertiesParser.IdentifierChar, 0); } + public TerminalNode Exclamation() { return getToken(JavaPropertiesParser.Exclamation, 0); } + public TerminalNode Number() { return getToken(JavaPropertiesParser.Number, 0); } public TerminalNode Space() { return getToken(JavaPropertiesParser.Space, 0); } public TerminalNode Backslash() { return getToken(JavaPropertiesParser.Backslash, 0); } public TerminalNode LineBreak() { return getToken(JavaPropertiesParser.LineBreak, 0); } @@ -646,42 +677,56 @@ public class JavaPropertiesParser extends Parser { ValueCharContext _localctx = new ValueCharContext(_ctx, getState()); enterRule(_localctx, 18, RULE_valueChar); try { - setState(84); + setState(92); switch (_input.LA(1)) { case IdentifierChar: enterOuterAlt(_localctx, 1); { - setState(78); + setState(84); match(IdentifierChar); } break; - case Space: + case Exclamation: enterOuterAlt(_localctx, 2); { - setState(79); + setState(85); + match(Exclamation); + } + break; + case Number: + enterOuterAlt(_localctx, 3); + { + setState(86); + match(Number); + } + break; + case Space: + enterOuterAlt(_localctx, 4); + { + setState(87); match(Space); } break; case Backslash: - enterOuterAlt(_localctx, 3); + enterOuterAlt(_localctx, 5); { - setState(80); + setState(88); match(Backslash); - setState(81); + setState(89); match(LineBreak); } break; case Equals: - enterOuterAlt(_localctx, 4); + enterOuterAlt(_localctx, 6); { - setState(82); + setState(90); match(Equals); } break; case Colon: - enterOuterAlt(_localctx, 5); + enterOuterAlt(_localctx, 7); { - setState(83); + setState(91); match(Colon); } break; @@ -701,29 +746,31 @@ public class JavaPropertiesParser extends Parser { } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\tY\4\2\t\2\4\3\t"+ + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\na\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\3"+ "\2\7\2\30\n\2\f\2\16\2\33\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\60\13\5\3\5\3\5\3\5"+ - "\3\6\7\6\66\n\6\f\6\16\69\13\6\3\6\3\6\3\7\3\7\3\7\3\7\3\b\6\bB\n\b\r"+ - "\b\16\bC\3\t\3\t\3\t\5\tI\n\t\3\n\3\n\6\nM\n\n\r\n\16\nN\3\13\3\13\3\13"+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2\2\65\66\3\2\2\2\668\3\2\2\2\67\65\3\2\2\289\t\4\2\29\t\3"+ + "\2\2\2:<\7\t\2\2;:\3\2\2\2\3\2\2\2>@\3\2\2\2?=\3"+ + "\2\2\2@A\7\b\2\2A\13\3\2\2\2BC\5\16\b\2CD\5\22\n\2DE\t\4\2\2E\r\3\2\2"+ + "\2FH\5\20\t\2GF\3\2\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2\2\2J\17\3\2\2\2KO\7"+ + "\n\2\2LM\7\3\2\2MO\t\5\2\2NK\3\2\2\2NL\3\2\2\2O\21\3\2\2\2PR\t\6\2\2Q"+ + "S\5\24\13\2RQ\3\2\2\2ST\3\2\2\2TR\3\2\2\2TU\3\2\2\2U\23\3\2\2\2V_\7\n"+ + "\2\2W_\7\6\2\2X_\7\7\2\2Y_\7\t\2\2Z[\7\3\2\2[_\7\b\2\2\\_\7\5\2\2]_\7"+ + "\4\2\2^V\3\2\2\2^W\3\2\2\2^X\3\2\2\2^Y\3\2\2\2^Z\3\2\2\2^\\\3\2\2\2^]"+ + "\3\2\2\2_\25\3\2\2\2\f\31!&.\65=INT^"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/vscode-extensions/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java b/vscode-extensions/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java index 6ff520b69..18ceb84e5 100644 --- a/vscode-extensions/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java +++ b/vscode-extensions/commons/java-properties/src/test/java/org/springframework/ide/vscode/java/properties/parser/test/PropertiesAntlrParserTest.java @@ -181,6 +181,13 @@ public class PropertiesAntlrParserTest { testPropertyLine("k\u2b22ey\u2b28 = val\u2b24ue 1\u2b24 ", "k\u2b22ey\u2b28", "k\u2b22ey\u2b28", "val\u2b24ue 1\u2b24 ", "val\u2b24ue 1\u2b24 "); } + @Test + public void testVariousCharsInValue() throws Exception { + for (char c = '!'; c < '@'; c++) { + testPropertyLine("key=va" + c + "lue", "key", "key", "va" + c + "lue", "va" + c + "lue"); + } + } + @Test public void testSyntaxError() throws Exception { String text = "abrakadabra";