Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Läubrich2021-01-21 16:30:43 +0000
committerChristoph Läubrich2021-01-23 07:09:24 +0000
commit1eef256603cbad46cc7b2e53f68fca96c29674f8 (patch)
treecfdd627371f30f007e0d9280619f2faa9c80a581
parente4bedb87d125fb7234720a47523f9e3b4b117111 (diff)
downloadeclipse.platform.text-1eef256603cbad46cc7b2e53f68fca96c29674f8.tar.gz
eclipse.platform.text-1eef256603cbad46cc7b2e53f68fca96c29674f8.tar.xz
eclipse.platform.text-1eef256603cbad46cc7b2e53f68fca96c29674f8.zip
Bug 570519 - Allow to specify TemplateVariable#fInitialLength
Change-Id: I16c1845d7fc807ef6940d31259313afaa5c71044 Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
-rw-r--r--org.eclipse.text/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java30
2 files changed, 24 insertions, 8 deletions
diff --git a/org.eclipse.text/META-INF/MANIFEST.MF b/org.eclipse.text/META-INF/MANIFEST.MF
index fbcad6f8538..d8167b0de29 100644
--- a/org.eclipse.text/META-INF/MANIFEST.MF
+++ b/org.eclipse.text/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.text
-Bundle-Version: 3.10.500.qualifier
+Bundle-Version: 3.11.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java
index d95a9a5a81d..5b9b8c2970e 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Christoph Läubrich - Bug 570519 - Allow to specify TemplateVariable#fInitialLength
*******************************************************************************/
package org.eclipse.jface.text.templates;
@@ -87,7 +88,7 @@ public class TemplateVariable {
* @since 3.3
*/
public TemplateVariable(TemplateVariableType type, String name, String defaultValue, int[] offsets) {
- this(type, name, new String[] { defaultValue }, offsets);
+ this(type, name, new String[] { defaultValue }, offsets, defaultValue.length());
}
/**
@@ -111,7 +112,21 @@ public class TemplateVariable {
* @param offsets the array of offsets of the variable
*/
public TemplateVariable(String type, String name, String[] values, int[] offsets) {
- this(new TemplateVariableType(type), name, values, offsets);
+ this(type, name, values, offsets, values[0].length());
+ }
+
+ /**
+ * Creates a template variable with multiple possible values.
+ *
+ * @param type the type of the variable
+ * @param name the name of the variable
+ * @param values the values available at this variable, non-empty
+ * @param offsets the array of offsets of the variable
+ * @param length the length of the variable in the template at offset positions
+ * @since 3.11
+ */
+ public TemplateVariable(String type, String name, String[] values, int[] offsets, int length) {
+ this(new TemplateVariableType(type), name, values, offsets, length);
}
/**
@@ -121,18 +136,19 @@ public class TemplateVariable {
* @param name the name of the variable
* @param values the values available at this variable, non-empty
* @param offsets the array of offsets of the variable
+ * @param initialLength the length of the variable in the template
* @since 3.3
*/
- TemplateVariable(TemplateVariableType type, String name, String[] values, int[] offsets) {
+ TemplateVariable(TemplateVariableType type, String name, String[] values, int[] offsets, int initialLength) {
Assert.isNotNull(type);
Assert.isNotNull(name);
+ fInitialLength= initialLength;
fType= type;
fName= name;
setValues(values);
setOffsets(offsets);
setUnambiguous(false);
setResolved(false);
- fInitialLength= values[0].length();
}
/**
@@ -198,9 +214,9 @@ public class TemplateVariable {
* resolved values of the variable.
*
* @return the initial length of the variable
- * @since 3.3
+ * @since 3.11
*/
- final int getInitialLength() {
+ public final int getInitialLength() {
return fInitialLength;
}

Back to the top