diff --git a/headless-services/commons/java-properties/.gitignore b/headless-services/commons/java-properties/.gitignore index 612c5bc96..0e22d8a64 100644 --- a/headless-services/commons/java-properties/.gitignore +++ b/headless-services/commons/java-properties/.gitignore @@ -1,3 +1,4 @@ target .idea *.iml +antlr-*.jar diff --git a/headless-services/commons/java-properties/generate-parser.sh b/headless-services/commons/java-properties/generate-parser.sh new file mode 100755 index 000000000..7743c0583 --- /dev/null +++ b/headless-services/commons/java-properties/generate-parser.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e +ANTLR_VERSION=4.5.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 +workdir=$(pwd) +cd resources +java -jar ${workdir}/antlr-${ANTLR_VERSION}.jar JavaProperties.g4 -o ${workdir}/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser -package org.springframework.ide.vscode.java.properties.antlr.parser + diff --git a/headless-services/commons/java-properties/resources/JavaProperties.g4 b/headless-services/commons/java-properties/resources/JavaProperties.g4 index 1a2c6e2ae..741f04f8c 100644 --- a/headless-services/commons/java-properties/resources/JavaProperties.g4 +++ b/headless-services/commons/java-properties/resources/JavaProperties.g4 @@ -60,11 +60,22 @@ valueChar | Exclamation | Number | Space - | Backslash LineBreak + | Backslash anyChar | Equals | Colon ; +anyChar + : LineBreak + | IdentifierChar + | Backslash + | Colon + | Equals + | Space + | Exclamation + | Number + ; + Backslash : '\\'; Colon : ':'; Equals : '='; diff --git a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java index 9a0f840d0..3501ccad8 100644 --- a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java +++ b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/AntlrParser.java @@ -40,9 +40,11 @@ import com.google.common.collect.ImmutableList; /** * ANTLR based parser implementation + *
+ * To regenerate the parser from Antlr4 grammar, see the + * generate-parser.sh bash script in this project's root. * * @author Alex Boyko - * */ public class AntlrParser implements Parser { 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 125564538..f114acbe6 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,14 +1,3 @@ -/******************************************************************************* - * Copyright (c) 2016-2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ - // Generated from JavaProperties.g4 by ANTLR 4.5.3 package org.springframework.ide.vscode.java.properties.antlr.parser; @@ -142,6 +131,18 @@ public class JavaPropertiesBaseListener implements JavaPropertiesListener { *
The default implementation does nothing.
*/ @Override public void exitValueChar(JavaPropertiesParser.ValueCharContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void enterAnyChar(JavaPropertiesParser.AnyCharContext ctx) { } + /** + * {@inheritDoc} + * + *The default implementation does nothing.
+ */ + @Override public void exitAnyChar(JavaPropertiesParser.AnyCharContext ctx) { } /** * {@inheritDoc} 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 0d85f9f9a..984564aff 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,14 +1,3 @@ -/******************************************************************************* - * Copyright (c) 2016-2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ - // Generated from JavaProperties.g4 by ANTLR 4.5.3 package org.springframework.ide.vscode.java.properties.antlr.parser; import org.antlr.v4.runtime.Lexer; diff --git a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesListener.java b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesListener.java index f8b62f15c..4ac4c5496 100644 --- a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesListener.java +++ b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesListener.java @@ -1,14 +1,3 @@ -/******************************************************************************* - * Copyright (c) 2016-2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ - // Generated from JavaProperties.g4 by ANTLR 4.5.3 package org.springframework.ide.vscode.java.properties.antlr.parser; import org.antlr.v4.runtime.tree.ParseTreeListener; @@ -118,4 +107,14 @@ public interface JavaPropertiesListener extends ParseTreeListener { * @param ctx the parse tree */ void exitValueChar(JavaPropertiesParser.ValueCharContext ctx); + /** + * Enter a parse tree produced by {@link JavaPropertiesParser#anyChar}. + * @param ctx the parse tree + */ + void enterAnyChar(JavaPropertiesParser.AnyCharContext ctx); + /** + * Exit a parse tree produced by {@link JavaPropertiesParser#anyChar}. + * @param ctx the parse tree + */ + void exitAnyChar(JavaPropertiesParser.AnyCharContext ctx); } \ No newline at end of file diff --git a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesParser.java b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesParser.java index 43b3bf4e7..f05e655ef 100644 --- a/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesParser.java +++ b/headless-services/commons/java-properties/src/main/java/org/springframework/ide/vscode/java/properties/antlr/parser/JavaPropertiesParser.java @@ -1,14 +1,3 @@ -/******************************************************************************* - * Copyright (c) 2016-2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ - // Generated from JavaProperties.g4 by ANTLR 4.5.3 package org.springframework.ide.vscode.java.properties.antlr.parser; import org.antlr.v4.runtime.atn.*; @@ -33,10 +22,10 @@ public class JavaPropertiesParser extends Parser { public static final int RULE_parse = 0, RULE_line = 1, RULE_propertyLine = 2, RULE_commentLine = 3, RULE_emptyLine = 4, RULE_keyValuePair = 5, RULE_key = 6, RULE_keyChar = 7, - RULE_separatorAndValue = 8, RULE_valueChar = 9; + RULE_separatorAndValue = 8, RULE_valueChar = 9, RULE_anyChar = 10; public static final String[] ruleNames = { "parse", "line", "propertyLine", "commentLine", "emptyLine", "keyValuePair", - "key", "keyChar", "separatorAndValue", "valueChar" + "key", "keyChar", "separatorAndValue", "valueChar", "anyChar" }; private static final String[] _LITERAL_NAMES = { @@ -124,21 +113,21 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(23); + setState(25); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Backslash) | (1L << Exclamation) | (1L << Number) | (1L << LineBreak) | (1L << Space) | (1L << IdentifierChar))) != 0)) { { { - setState(20); + setState(22); line(); } } - setState(25); + setState(27); _errHandler.sync(this); _la = _input.LA(1); } - setState(26); + setState(28); match(EOF); } } @@ -181,27 +170,27 @@ public class JavaPropertiesParser extends Parser { LineContext _localctx = new LineContext(_ctx, getState()); enterRule(_localctx, 2, RULE_line); try { - setState(31); + setState(33); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(28); + setState(30); propertyLine(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(29); + setState(31); commentLine(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(30); + setState(32); emptyLine(); } break; @@ -247,21 +236,21 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(36); + setState(38); _errHandler.sync(this); _la = _input.LA(1); while (_la==Space) { { { - setState(33); + setState(35); match(Space); } } - setState(38); + setState(40); _errHandler.sync(this); _la = _input.LA(1); } - setState(39); + setState(41); keyValuePair(); } } @@ -309,34 +298,34 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(44); + setState(46); _errHandler.sync(this); _la = _input.LA(1); while (_la==Space) { { { - setState(41); + setState(43); match(Space); } } - setState(46); + setState(48); _errHandler.sync(this); _la = _input.LA(1); } - setState(47); + setState(49); _la = _input.LA(1); if ( !(_la==Exclamation || _la==Number) ) { _errHandler.recoverInline(this); } else { consume(); } - setState(51); + setState(53); _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); + setState(50); _la = _input.LA(1); if ( _la <= 0 || (_la==LineBreak) ) { _errHandler.recoverInline(this); @@ -345,11 +334,11 @@ public class JavaPropertiesParser extends Parser { } } } - setState(53); + setState(55); _errHandler.sync(this); _la = _input.LA(1); } - setState(54); + setState(56); _la = _input.LA(1); if ( !(_la==EOF || _la==LineBreak) ) { _errHandler.recoverInline(this); @@ -396,21 +385,21 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(59); + setState(61); _errHandler.sync(this); _la = _input.LA(1); while (_la==Space) { { { - setState(56); + setState(58); match(Space); } } - setState(61); + setState(63); _errHandler.sync(this); _la = _input.LA(1); } - setState(62); + setState(64); match(LineBreak); } } @@ -455,11 +444,11 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(64); - key(); - setState(65); - separatorAndValue(); setState(66); + key(); + setState(67); + separatorAndValue(); + setState(68); _la = _input.LA(1); if ( !(_la==EOF || _la==LineBreak) ) { _errHandler.recoverInline(this); @@ -507,17 +496,17 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(69); + setState(71); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(68); + setState(70); keyChar(); } } - setState(71); + setState(73); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Backslash || _la==IdentifierChar ); @@ -558,21 +547,21 @@ public class JavaPropertiesParser extends Parser { enterRule(_localctx, 14, RULE_keyChar); int _la; try { - setState(76); + setState(78); switch (_input.LA(1)) { case IdentifierChar: enterOuterAlt(_localctx, 1); { - setState(73); + setState(75); match(IdentifierChar); } break; case Backslash: enterOuterAlt(_localctx, 2); { - setState(74); + setState(76); match(Backslash); - setState(75); + setState(77); _la = _input.LA(1); if ( !(_la==Colon || _la==Equals) ) { _errHandler.recoverInline(this); @@ -627,24 +616,24 @@ public class JavaPropertiesParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(78); + setState(80); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << Colon) | (1L << Equals) | (1L << Space))) != 0)) ) { _errHandler.recoverInline(this); } else { consume(); } - setState(82); + setState(84); _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(79); + setState(81); valueChar(); } } - setState(84); + setState(86); _errHandler.sync(this); _la = _input.LA(1); } @@ -667,7 +656,9 @@ public class JavaPropertiesParser extends Parser { 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); } + public AnyCharContext anyChar() { + return getRuleContext(AnyCharContext.class,0); + } public TerminalNode Equals() { return getToken(JavaPropertiesParser.Equals, 0); } public TerminalNode Colon() { return getToken(JavaPropertiesParser.Colon, 0); } public ValueCharContext(ParserRuleContext parent, int invokingState) { @@ -688,56 +679,56 @@ public class JavaPropertiesParser extends Parser { ValueCharContext _localctx = new ValueCharContext(_ctx, getState()); enterRule(_localctx, 18, RULE_valueChar); try { - setState(93); + setState(95); switch (_input.LA(1)) { case IdentifierChar: enterOuterAlt(_localctx, 1); { - setState(85); + setState(87); match(IdentifierChar); } break; case Exclamation: enterOuterAlt(_localctx, 2); { - setState(86); + setState(88); match(Exclamation); } break; case Number: enterOuterAlt(_localctx, 3); { - setState(87); + setState(89); match(Number); } break; case Space: enterOuterAlt(_localctx, 4); { - setState(88); + setState(90); match(Space); } break; case Backslash: enterOuterAlt(_localctx, 5); { - setState(89); + setState(91); match(Backslash); - setState(90); - match(LineBreak); + setState(92); + anyChar(); } break; case Equals: enterOuterAlt(_localctx, 6); { - setState(91); + setState(93); match(Equals); } break; case Colon: enterOuterAlt(_localctx, 7); { - setState(92); + setState(94); match(Colon); } break; @@ -756,32 +747,83 @@ public class JavaPropertiesParser extends Parser { return _localctx; } + public static class AnyCharContext extends ParserRuleContext { + public TerminalNode LineBreak() { return getToken(JavaPropertiesParser.LineBreak, 0); } + public TerminalNode IdentifierChar() { return getToken(JavaPropertiesParser.IdentifierChar, 0); } + public TerminalNode Backslash() { return getToken(JavaPropertiesParser.Backslash, 0); } + public TerminalNode Colon() { return getToken(JavaPropertiesParser.Colon, 0); } + public TerminalNode Equals() { return getToken(JavaPropertiesParser.Equals, 0); } + public TerminalNode Space() { return getToken(JavaPropertiesParser.Space, 0); } + public TerminalNode Exclamation() { return getToken(JavaPropertiesParser.Exclamation, 0); } + public TerminalNode Number() { return getToken(JavaPropertiesParser.Number, 0); } + public AnyCharContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_anyChar; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof JavaPropertiesListener ) ((JavaPropertiesListener)listener).enterAnyChar(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof JavaPropertiesListener ) ((JavaPropertiesListener)listener).exitAnyChar(this); + } + } + + public final AnyCharContext anyChar() throws RecognitionException { + AnyCharContext _localctx = new AnyCharContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_anyChar); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(97); + _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 { + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\nb\4\2\t\2\4\3\t"+ - "\3\4\4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2\2\2KL\3\2\2\2L\17\3\2\2\2MQ\7\n\2\2NO\7\3\2\2OQ\t\5\2\2PM\3\2\2"+ + "\2PN\3\2\2\2Q\21\3\2\2\2RV\t\6\2\2SU\5\24\13\2TS\3\2\2\2UX\3\2\2\2VT\3"+ + "\2\2\2VW\3\2\2\2W\23\3\2\2\2XV\3\2\2\2Yb\7\n\2\2Zb\7\6\2\2[b\7\7\2\2\\"+ + "b\7\t\2\2]^\7\3\2\2^b\5\26\f\2_b\7\5\2\2`b\7\4\2\2aY\3\2\2\2aZ\3\2\2\2"+ + "a[\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 4f55d3a7f..e83ac9c9e 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 @@ -13,6 +13,7 @@ package org.springframework.ide.vscode.java.properties.parser.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.List; @@ -45,7 +46,9 @@ public class PropertiesAntlrParserTest { String expectedKey, String expectedEncodedKey, String expectedValue, String expectedEncodedValue) { ParseResults results = parser.parse(text); - assertTrue(results.syntaxErrors.isEmpty()); + if (!results.syntaxErrors.isEmpty()) { + fail(results.syntaxErrors.get(0).getMessage()); + } assertTrue(results.problems.isEmpty()); assertEquals(1, results.ast.getAllNodes().size()); @@ -102,6 +105,18 @@ public class PropertiesAntlrParserTest { public void testPropertyWithColonSeparatorAndSpaces() throws Exception { testPropertyLine("key \t : \t \tvalue", "key", "key", "value", " \t \tvalue"); } + + @Test + public void testPropertyWithEscapedValue() { + testPropertyLine("key=something \\nescapy", "key", "key", "something \nescapy", "something \\nescapy"); + testPropertyLine("key=something \\\\escapy", "key", "key", "something \\escapy", "something \\\\escapy"); + testPropertyLine("key=something\\:escapy", "key", "key", "something:escapy", "something\\:escapy"); + testPropertyLine("key=something\\=escapy", "key", "key", "something=escapy", "something\\=escapy"); + testPropertyLine("key=something\\ escapy", "key", "key", "something escapy", "something\\ escapy"); + testPropertyLine("key=something\\'escapy", "key", "key", "something'escapy", "something\\'escapy"); + testPropertyLine("key=something\\#escapy", "key", "key", "something#escapy", "something\\#escapy"); + testPropertyLine("key=something\\!escapy", "key", "key", "something!escapy", "something\\!escapy"); + } @Test public void testPropertyWithSpaceSeparator() throws Exception { diff --git a/headless-services/spring-boot-language-server/src/main/resources/application.properties b/headless-services/spring-boot-language-server/src/main/resources/application.properties index ab8019fe5..72b03c5d1 100644 --- a/headless-services/spring-boot-language-server/src/main/resources/application.properties +++ b/headless-services/spring-boot-language-server/src/main/resources/application.properties @@ -5,6 +5,7 @@ languageserver.completion-trigger-characters.spring-boot-properties-yaml: abcdef languageserver.completion-trigger-characters.spring-boot-properties: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. spring.main.banner-mode: off +#logging.level.org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer=debug #logging.level.org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava=debug #logging.level.org.springframework.ide.vscode.boot.app.SpringSymbolIndex=debug #logging.level.org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp=off \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index 0c6d3dd9e..7c86b4ef8 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -92,6 +92,22 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { editor.assertProblems("key|extraneous input"); } + @Test public void bug_GH_STS4_314() throws Exception { + ///See: https://github.com/spring-projects/sts4/issues/314 + data("my.text", "java.lang.String", null, null); + Editor editor; + + editor = newEditor( + "my.text=something \\n escapy" + ); + editor.assertProblems(/*NONE*/); + + editor = newEditor( + "my.text=something simple" + ); + editor.assertProblems(/*NONE*/); + } + @Test public void bug_158348104() throws Exception { //See: https://www.pivotaltracker.com/story/show/158348104 data("spring.activemq.close-timeout", "java.time.Duration", null, null);