diff --git a/headless-services/commons/pom.xml b/headless-services/commons/pom.xml index 9da5839646..56fbd013ea 100644 --- a/headless-services/commons/pom.xml +++ b/headless-services/commons/pom.xml @@ -153,6 +153,11 @@ org.eclipse.jgit ${jgit-version} + + org.apache.commons + commons-text + 1.12.0 + diff --git a/headless-services/spring-boot-language-server/pom.xml b/headless-services/spring-boot-language-server/pom.xml index 1fb202e411..0d8daa6e14 100644 --- a/headless-services/spring-boot-language-server/pom.xml +++ b/headless-services/spring-boot-language-server/pom.xml @@ -134,6 +134,11 @@ json 20231013 + + org.apache.commons + commons-text + + org.eclipse.lemminx diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/StringLiteralLanguageSnippet.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/StringLiteralLanguageSnippet.java index a76a57ea76..ed37220739 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/StringLiteralLanguageSnippet.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/StringLiteralLanguageSnippet.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.text.StringEscapeUtils; import org.eclipse.jdt.core.dom.StringLiteral; import org.springframework.ide.vscode.commons.util.text.IRegion; import org.springframework.ide.vscode.commons.util.text.Region; @@ -31,8 +32,12 @@ public class StringLiteralLanguageSnippet implements EmbeddedLanguageSnippet { */ private transient List specialRegions; + private static String getLiteralValueStr(String escaped) { + return StringEscapeUtils.unescapeJava(escaped.substring(1, escaped.length() - 1)); + } + public StringLiteralLanguageSnippet(StringLiteral literal) { - this(literal.getEscapedValue(), literal.getLiteralValue(), literal.getStartPosition()); + this(literal.getEscapedValue(), getLiteralValueStr(literal.getEscapedValue()), literal.getStartPosition()); } public StringLiteralLanguageSnippet(String escapedValue, String literalValue, int literalOffset) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/TextBlockLanguageSnippet.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/TextBlockLanguageSnippet.java index 6647def706..057d0fb42d 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/TextBlockLanguageSnippet.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/embedded/lang/TextBlockLanguageSnippet.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.text.StringEscapeUtils; import org.eclipse.jdt.core.dom.TextBlock; import org.springframework.ide.vscode.commons.util.text.IRegion; import org.springframework.ide.vscode.commons.util.text.Region; @@ -26,8 +27,12 @@ public class TextBlockLanguageSnippet implements EmbeddedLanguageSnippet { private transient int startOffset; private transient List specialRegions; + private static String getLiteralValueStr(String escaped) { + return StringEscapeUtils.unescapeJava(escaped.substring(3, escaped.length() - 3)); + } + public TextBlockLanguageSnippet(TextBlock block) { - this(block.getEscapedValue(), block.getLiteralValue(), block.getStartPosition()); + this(block.getEscapedValue(), getLiteralValueStr(block.getEscapedValue()), block.getStartPosition()); } public TextBlockLanguageSnippet(String escapedValue, String literalValue, int literalOffset) {