Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java')
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
index 4cc1d2c39..9fa324602 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019, 2020 IBM Corporation and others.
+ * Copyright (c) 2019, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -76,6 +76,12 @@ public class TextBlock extends Expression {
private String escapedValue = "\"\"";//$NON-NLS-1$
/**
+ * The literal string without the quotes and the applicable preceding and
+ * trailing whitespace if any ; defaults to empty string.
+ */
+ private String literalValue = "";//$NON-NLS-1$
+
+ /**
* Creates a new unparented TextBlock node owned by the given AST.
* By default, the TextBlock denotes the empty string.
* <p>
@@ -190,14 +196,15 @@ public class TextBlock extends Expression {
}
/* (omit javadoc for this method)
- * This method is a copy of setEscapedValue(String) that doesn't do any validation.
+ * This method is does what setEscapedValue(String) does but without any validation.
+ * In addition, it also sets the literalValue property.
*/
- void internalSetEscapedValue(String token) {
+ void internalSetEscapedValue(String token, String literal) {
preValueChange(ESCAPED_VALUE_PROPERTY);
this.escapedValue = token;
+ this.literalValue = literal;
postValueChange(ESCAPED_VALUE_PROPERTY);
}
-
/**
* Returns the value of this literal node.
* <p>
@@ -217,6 +224,9 @@ public class TextBlock extends Expression {
* @since 3.24
*/
public String getLiteralValue() {
+ if (!this.literalValue.isEmpty()) {
+ return this.literalValue;
+ }
char[] escaped = getEscapedValue().toCharArray();
int len = escaped.length;
if (len < 7) {

Back to the top