Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeb Ford-Reitz2012-01-30 16:27:14 +0000
committerZeb Ford-Reitz2012-01-30 16:27:14 +0000
commit1df924b58419e4f5cb1a6b9e7932ec0596851785 (patch)
tree26d289eeab59b82ae6e913cf644e1c60d6c58e48
parent8bce77f316eead6e3e19cfe1bf161e328b350ec7 (diff)
downloadorg.eclipse.jubula.core-1df924b58419e4f5cb1a6b9e7932ec0596851785.tar.gz
org.eclipse.jubula.core-1df924b58419e4f5cb1a6b9e7932ec0596851785.tar.xz
org.eclipse.jubula.core-1df924b58419e4f5cb1a6b9e7932ec0596851785.zip
Adds functions to parameter grammar.
The format of functions is ?<function_name>([arg1[,arg2[,...]]]). An example call would be: ?concat(prefix_, ={PARAM}, _suffix) This commit does not include built-in functions. Also, the functions are not yet evaluated during test exection.
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/XmlImporter.java11
-rw-r--r--org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java14
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/parser/parameter/JubulaParameterLexer.java53
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/AbstractParamValueToken.java105
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/FunctionToken.java114
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/GuiParamValueConverter.java4
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/INestableParamValueToken.java24
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IParamValueToken.java7
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/LiteralToken.java63
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ModelParamValueConverter.java18
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java47
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParsedParameter.java78
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java72
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/SimpleValueToken.java100
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/VariableToken.java77
-rw-r--r--org.eclipse.jubula.releng/lib/sablecc/parameter.sable47
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/i18n/guidancerStrings.properties1
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java3
18 files changed, 537 insertions, 301 deletions
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/XmlImporter.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/XmlImporter.java
index cfa8ff4de..e5b52e7d9 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/XmlImporter.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/XmlImporter.java
@@ -1657,7 +1657,16 @@ class XmlImporter {
LocaleUtil.convertStrToLocale(
i18nVal.getLanguage()),
null);
- converter.replaceGuidsInReferences(m_oldToNewGuids);
+
+ if (!converter.containsErrors()) {
+ // Only try to replace reference GUIDs if the
+ // string could be successfully parsed.
+ // Otherwise, the model string will be overwritten with
+ // the empty string because no tokens were created
+ // during parsing.
+ converter.replaceGuidsInReferences(m_oldToNewGuids);
+ }
+
i18nValString = converter.getModelString();
} catch (IllegalArgumentException iae) {
// Do nothing.
diff --git a/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java b/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java
index 27b090ab3..ff38a5926 100644
--- a/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java
+++ b/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java
@@ -19,11 +19,11 @@ import java.io.StringReader;
import java.util.Arrays;
import java.util.Collection;
-import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.Lexer;
import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.LexerException;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.Start;
import org.eclipse.jubula.client.core.gen.parser.parameter.parser.Parser;
import org.eclipse.jubula.client.core.gen.parser.parameter.parser.ParserException;
+import org.eclipse.jubula.client.core.parser.parameter.JubulaParameterLexer;
import org.eclipse.jubula.client.core.utils.ParsedParameter;
import org.eclipse.jubula.client.core.utils.SemanticParsingException;
import org.junit.Test;
@@ -46,7 +46,7 @@ public class TestParameterInput {
@SuppressWarnings("nls")
@Test
public void testParameterInput() throws IOException {
- Parser parser = new Parser(new Lexer(new PushbackReader(
+ Parser parser = new Parser(new JubulaParameterLexer(new PushbackReader(
new StringReader(m_inputString))));
try {
Start ast = parser.parse();
@@ -80,7 +80,10 @@ public class TestParameterInput {
{"={PARAMETER}", true},
{"=1", true},
{"={1}", true},
- {"?()", true},
+ {"?abc()", true},
+ {"?abc(arg)", true},
+ {"?abc(arg1, arg2)", true},
+ {"?abc(?abc(arg1, arg2), ={PARAM_ARG}, \\=prefix${VARIABLE_ARG}\\$\\?suffix)", true},
{"=", false}, // missing parameter name
{"={}", false}, // missing parameter name
@@ -90,11 +93,14 @@ public class TestParameterInput {
{"?", false}, // missing function body
{"?(", false}, // missing closing parentheses
{"?)", false}, // missing opening parentheses
- {"?a", false}, // invalid (literal) after function symbol
+ {"?()", false}, // missing function name
+ {"?a", false}, // missing function argument list
{"?=", false}, // invalid (parameter symbol) after function symbol
{"??", false}, // invalid (function symbol) after function symbol
{"?$", false}, // invalid (variable symbol) after function symbol
{"?''", false}, // invalid (single quote) after function symbol
+ {"?abc(?abc(arg1, arg2))", true},
+ {"?abc(?abc(arg1, arg2), ={PARAM_ARG}, prefix${VARIABLE_ARG}suffix)", true},
});
}
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/parser/parameter/JubulaParameterLexer.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/parser/parameter/JubulaParameterLexer.java
new file mode 100644
index 000000000..ddcae6de8
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/parser/parameter/JubulaParameterLexer.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.parser.parameter;
+
+import java.io.PushbackReader;
+
+import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.Lexer;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.TBeginFunctionArgsToken;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.TEndFunctionArgsToken;
+
+/**
+ * Customized lexer for Jubula test data parameter strings.
+ *
+ * Tracks the nesting level of functions in the parameter string and
+ * modifies the lexer state as necessary based on the current nesting level.
+ */
+public class JubulaParameterLexer extends Lexer {
+
+ /** current depth of function nesting */
+ private int m_functionDepth = 0;
+
+ /**
+ * Constructor
+ *
+ * @param in Reader for input stream.
+ */
+ public JubulaParameterLexer(PushbackReader in) {
+ super(in);
+ }
+
+ @Override
+ protected void filter() {
+ if (token instanceof TBeginFunctionArgsToken
+ && Lexer.State.FUNCTION_ARGS.equals(state)) {
+ m_functionDepth++;
+ }
+ if (token instanceof TEndFunctionArgsToken) {
+ m_functionDepth--;
+ }
+ if (m_functionDepth > 0
+ && Lexer.State.NORMAL.equals(state)) {
+ state = Lexer.State.FUNCTION_ARGS;
+ }
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/AbstractParamValueToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/AbstractParamValueToken.java
new file mode 100644
index 000000000..ade5d1fbd
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/AbstractParamValueToken.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.utils;
+
+import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
+
+/**
+ * Base class for implementors of {@link IParamValueToken}.
+ */
+public abstract class AbstractParamValueToken implements IParamValueToken {
+
+ /** Constant for a Variable as a data type of test data */
+ protected static final String VARIABLE = "guidancer.datatype.Variable"; //$NON-NLS-1$
+
+ /**
+ * <code>m_value</code> string represents the token in the GUI
+ */
+ private String m_value = null;
+
+ /**
+ * index of first character of this token in the entire parameter value
+ */
+ private int m_startPos = 0;
+
+ /**
+ * <code>m_errorKey</code>I18NKey for error message
+ * associated with result of invocation of validate()
+ */
+ private Integer m_errorKey = null;
+
+ /** param description belonging to currently edited parameter value */
+ private IParamDescriptionPO m_desc;
+
+ /**
+ * Constructor
+ *
+ * @param s string represents the token
+ * @param pos index of first character of token in entire string
+ * @param desc param description belonging to currently edited parameter value
+ */
+ public AbstractParamValueToken(
+ String s, int pos, IParamDescriptionPO desc) {
+
+ m_value = s;
+ m_startPos = pos;
+ m_desc = desc;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public final Integer getErrorKey() {
+ return m_errorKey;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public final void setErrorKey(Integer errorKey) {
+ m_errorKey = errorKey;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ protected final String getValue() {
+ return m_value;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ protected final IParamDescriptionPO getParamDescription() {
+ return m_desc;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public final int getStartIndex() {
+ return m_startPos;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public final int getEndIndex() {
+ return m_startPos + m_value.length();
+ }
+
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/FunctionToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/FunctionToken.java
new file mode 100644
index 000000000..17d2dabfc
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/FunctionToken.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.utils;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
+import org.eclipse.jubula.client.core.utils.ParamValueConverter.ConvValidationState;
+
+/**
+ * Token that represents a function call.
+ */
+public class FunctionToken extends AbstractParamValueToken
+ implements INestableParamValueToken {
+
+ /** the tokens comprising the function arguments */
+ private IParamValueToken[] m_argTokens;
+
+ /** the string at the beginning of the function : ?&lt;name&gt;(*/
+ private String m_prefix;
+
+ /** the string at the end of the function : ) */
+ private String m_suffix;
+
+ /**
+ * Constructor
+ *
+ * @param s string represents the entire token
+ * @param functionPrefix string represents the text at the beginning of the token
+ * @param functionSuffix string represents the text at the end of the token
+ * @param pos index of first character of token in entire string
+ * @param desc param description belonging to currently edited parameter value
+ * @param argTokens the tokens that comprise the arguments for the function
+ */
+ public FunctionToken(String s,
+ String functionPrefix, String functionSuffix,
+ int pos, IParamDescriptionPO desc,
+ IParamValueToken[] argTokens) {
+
+ super(s, pos, desc);
+ m_argTokens = argTokens;
+ m_prefix = functionPrefix;
+ m_suffix = functionSuffix;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public ConvValidationState validate() {
+ // FIXME implement
+ return null;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String getExecutionString(List<ExecObject> stack, Locale locale) {
+ // FIXME implement
+ return StringUtils.EMPTY;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String getGuiString() {
+ StringBuilder guiStringBuilder = new StringBuilder();
+ guiStringBuilder.append(m_prefix);
+
+ for (IParamValueToken nestedToken : getNestedTokens()) {
+ guiStringBuilder.append(nestedToken.getGuiString());
+ }
+
+ guiStringBuilder.append(m_suffix);
+ return guiStringBuilder.toString();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String getModelString() {
+ StringBuilder modelStringBuilder = new StringBuilder();
+ modelStringBuilder.append(m_prefix);
+
+ for (IParamValueToken nestedToken : getNestedTokens()) {
+ modelStringBuilder.append(nestedToken.getModelString());
+ }
+
+ modelStringBuilder.append(m_suffix);
+ return modelStringBuilder.toString();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public IParamValueToken[] getNestedTokens() {
+ return m_argTokens;
+ }
+
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/GuiParamValueConverter.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/GuiParamValueConverter.java
index 0c009a0c1..06ee3b09d 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/GuiParamValueConverter.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/GuiParamValueConverter.java
@@ -19,7 +19,6 @@ import java.util.Locale;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
-import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.Lexer;
import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.LexerException;
import org.eclipse.jubula.client.core.gen.parser.parameter.parser.Parser;
import org.eclipse.jubula.client.core.gen.parser.parameter.parser.ParserException;
@@ -27,6 +26,7 @@ import org.eclipse.jubula.client.core.i18n.Messages;
import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
import org.eclipse.jubula.client.core.model.IParameterInterfacePO;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
+import org.eclipse.jubula.client.core.parser.parameter.JubulaParameterLexer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,7 +73,7 @@ public class GuiParamValueConverter extends ParamValueConverter {
/** create tokens from gui string */
void createTokens() {
- Parser parser = new Parser(new Lexer(new PushbackReader(
+ Parser parser = new Parser(new JubulaParameterLexer(new PushbackReader(
new StringReader(StringUtils.defaultString(getGuiString())))));
ParsedParameter parsedParam =
new ParsedParameter(true, getCurrentNode(), getDesc());
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/INestableParamValueToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/INestableParamValueToken.java
new file mode 100644
index 000000000..d312a0e0e
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/INestableParamValueToken.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.utils;
+
+/**
+ * A token capable of containing other tokens.
+ */
+public interface INestableParamValueToken extends IParamValueToken {
+
+ /**
+ *
+ * @return the contained tokens.
+ */
+ public IParamValueToken[] getNestedTokens();
+
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IParamValueToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IParamValueToken.java
index 7c9fa2465..856e4419a 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IParamValueToken.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/IParamValueToken.java
@@ -51,13 +51,6 @@ public interface IParamValueToken {
Locale locale) throws InvalidDataException;
/**
- * validates, if this token must be internationalized
- *
- * @return true, if the token needs consideration of locale
- */
- public abstract boolean isI18Nrelevant();
-
- /**
* @return the current value in gui representation for this token
*/
public abstract String getGuiString();
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/LiteralToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/LiteralToken.java
index 82bb811c0..e64339a2a 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/LiteralToken.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/LiteralToken.java
@@ -24,36 +24,14 @@ import org.eclipse.jubula.tools.exception.InvalidDataException;
/**
* token to represent a string starts end ends with a single quote
*/
-class LiteralToken implements IParamValueToken {
-
- /**
- * <code>m_value</code> string represents the token in the GUI
- */
- private String m_value = null;
-
- /**
- * index of first character of this token in the entire parameter value
- */
- private int m_startPos = -1;
-
- /**
- * index of last character of this token in the entire value
- */
- private int m_endPos = -1;
-
- /**
- * <code>m_errorKey</code>I18NKey for error message
- * associated with result of invocation of validate()
- */
- private Integer m_errorKey;
+class LiteralToken extends AbstractParamValueToken {
/**
* @param s string represents the token
* @param pos index of first character of token in entire string
*/
public LiteralToken(String s, int pos) {
- m_value = s;
- m_startPos = pos;
+ super(s, pos, null);
}
@@ -74,33 +52,11 @@ class LiteralToken implements IParamValueToken {
return true;
}
- /** {@inheritDoc}
- * @see IParamValueToken#getErrorKey()
- */
- public Integer getErrorKey() {
- return m_errorKey;
- }
-
- /**
- * @return index of last character of tokenvalue in entire string
- */
- public int getEndIndex() {
- return m_endPos;
- }
-
- /**
- * @return index of first character of tokenvalue in entire string
- */
- public int getStartIndex() {
- return m_startPos;
- }
-
-
/**
* @return the current value for this token
*/
public String getGuiString() {
- return m_value;
+ return getValue();
}
@@ -113,8 +69,8 @@ class LiteralToken implements IParamValueToken {
String execString = StringConstants.EMPTY;
// remove quotes
- if (m_value != null && m_value.length() > 1) {
- execString = m_value.substring(1, m_value.length() - 1);
+ if (getValue() != null && getValue().length() > 1) {
+ execString = getValue().substring(1, getValue().length() - 1);
}
return execString;
}
@@ -124,14 +80,7 @@ class LiteralToken implements IParamValueToken {
* @see org.eclipse.jubula.client.core.utils.IParamValueToken#getModelString()
*/
public String getModelString() {
- return m_value;
+ return getValue();
}
-
- /** {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#setErrorKey(java.lang.Integer)
- */
- public void setErrorKey(Integer errorKey) {
- m_errorKey = errorKey;
- }
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ModelParamValueConverter.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ModelParamValueConverter.java
index 5b5136ae5..7421e1ada 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ModelParamValueConverter.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ModelParamValueConverter.java
@@ -19,7 +19,6 @@ import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
-import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.Lexer;
import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.LexerException;
import org.eclipse.jubula.client.core.gen.parser.parameter.parser.Parser;
import org.eclipse.jubula.client.core.gen.parser.parameter.parser.ParserException;
@@ -27,6 +26,7 @@ import org.eclipse.jubula.client.core.i18n.Messages;
import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
import org.eclipse.jubula.client.core.model.IParameterInterfacePO;
import org.eclipse.jubula.client.core.model.ITestDataPO;
+import org.eclipse.jubula.client.core.parser.parameter.JubulaParameterLexer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,7 +77,17 @@ public class ModelParamValueConverter extends ParamValueConverter {
for (IParamValueToken token : getTokens()) {
builder.append(token.getGuiString());
}
- setGuiString(builder.toString());
+
+ if (builder.length() > 0) {
+ setGuiString(builder.toString());
+ } else {
+ // If no tokens were generated, then either the model string
+ // could not be successfully parsed or the model string is
+ // empty. Either way, use the model string in
+ // order to show the current (possibly unparseable) state of the
+ // parameter string.
+ return getModelString();
+ }
}
return super.getGuiString();
}
@@ -86,7 +96,7 @@ public class ModelParamValueConverter extends ParamValueConverter {
* @{inheritDoc}
*/
void createTokens() {
- Parser parser = new Parser(new Lexer(new PushbackReader(
+ Parser parser = new Parser(new JubulaParameterLexer(new PushbackReader(
new StringReader(StringUtils.defaultString(
getModelString())))));
ParsedParameter parsedParam =
@@ -130,7 +140,7 @@ public class ModelParamValueConverter extends ParamValueConverter {
public boolean removeReference(String guid) {
boolean isRefRemoved = false;
List<IParamValueToken> tokensCopy =
- new ArrayList<IParamValueToken>(getTokens());
+ new ArrayList<IParamValueToken>(getAllTokens());
for (IParamValueToken token : tokensCopy) {
if (token instanceof RefToken) {
RefToken refToken = (RefToken)token;
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java
index 6b519ee8c..4d8234472 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java
@@ -12,6 +12,7 @@ package org.eclipse.jubula.client.core.utils;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -130,7 +131,7 @@ public abstract class ParamValueConverter {
*/
public List<String> getNamesForReferences() {
List<String> paramNames = new ArrayList<String>();
- for (IParamValueToken token : m_tokens) {
+ for (IParamValueToken token : getAllTokens()) {
if (token instanceof RefToken) {
RefToken refToken = (RefToken)token;
paramNames.add(RefToken.extractCore(refToken.getGuiString()));
@@ -144,7 +145,7 @@ public abstract class ParamValueConverter {
*/
public List<String> getVariables() {
List<String> variables = new ArrayList<String>();
- for (IParamValueToken token : m_tokens) {
+ for (IParamValueToken token : getAllTokens()) {
if (token instanceof VariableToken) {
variables.add(((VariableToken)token).getGuiString());
}
@@ -157,7 +158,7 @@ public abstract class ParamValueConverter {
* @return true, if string contains at least one reference
*/
public boolean containsReferences() {
- for (IParamValueToken token : m_tokens) {
+ for (IParamValueToken token : getAllTokens()) {
if (token instanceof RefToken) {
return true;
}
@@ -169,7 +170,7 @@ public abstract class ParamValueConverter {
* @return true, if string contains only simple values
*/
public boolean containsOnlySimpleValues() {
- for (IParamValueToken token : m_tokens) {
+ for (IParamValueToken token : getTokens()) {
if (!(token instanceof SimpleValueToken)) {
return false;
}
@@ -186,7 +187,7 @@ public abstract class ParamValueConverter {
public String getExecutionString(List<ExecObject> stack,
Locale locale) throws InvalidDataException {
StringBuilder builder = new StringBuilder();
- for (IParamValueToken token : m_tokens) {
+ for (IParamValueToken token : getTokens()) {
builder.append(token.getExecutionString(
new ArrayList<ExecObject>(stack), locale));
}
@@ -209,9 +210,41 @@ public abstract class ParamValueConverter {
return m_tokens;
}
-
+ /**
+ *
+ * @return all tokens contained in this converter (including nested tokens).
+ */
+ protected List<IParamValueToken> getAllTokens() {
+ List<IParamValueToken> tokens =
+ new ArrayList<IParamValueToken>(getTokens());
+ for (IParamValueToken token : getTokens()) {
+ if (token instanceof INestableParamValueToken) {
+ addAllSubTokens((INestableParamValueToken)token, tokens);
+ }
+ }
+
+ return tokens;
+ }
/**
+ * Recursive method for finding all (recursively) nested tokens.
+ *
+ * @param token The token from which to acquire nested tokens.
+ * @param tokenList The list to which the nested tokens should be added.
+ */
+ private void addAllSubTokens(
+ INestableParamValueToken token, List<IParamValueToken> tokenList) {
+
+ IParamValueToken[] nestedTokens = token.getNestedTokens();
+ tokenList.addAll(Arrays.asList(nestedTokens));
+ for (IParamValueToken subToken : nestedTokens) {
+ if (subToken instanceof INestableParamValueToken) {
+ addAllSubTokens((INestableParamValueToken)subToken, tokenList);
+ }
+ }
+ }
+
+ /**
* @param tokens The tokens to set.
*/
protected void setTokens(List<IParamValueToken> tokens) {
@@ -251,7 +284,7 @@ public abstract class ParamValueConverter {
*/
public List<RefToken> getRefTokens() {
List <RefToken> refTokens = new ArrayList<RefToken>();
- for (IParamValueToken token : getTokens()) {
+ for (IParamValueToken token : getAllTokens()) {
if (token instanceof RefToken) {
refTokens.add((RefToken)token);
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParsedParameter.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParsedParameter.java
index 9348f8241..735e5e73c 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParsedParameter.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParsedParameter.java
@@ -15,12 +15,17 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jubula.client.core.gen.parser.parameter.analysis.DepthFirstAdapter;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.AAlphanumericFunctionArgToken;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.AAlphanumericParamToken;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.AAnySequenceParamToken;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.AEscapeSequenceFunctionArgToken;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.AEscapeSequenceParamToken;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.AFunction;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.ALiteral;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.AReference;
import org.eclipse.jubula.client.core.gen.parser.parameter.node.AVariable;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.PFunctionArgList;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.TComma;
import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
import org.eclipse.jubula.client.core.model.IParameterInterfacePO;
import org.eclipse.jubula.tools.i18n.I18n;
@@ -205,6 +210,79 @@ public class ParsedParameter extends DepthFirstAdapter {
anySeq.getChar().getPos(), m_paramDesc));
}
+ @Override
+ public void caseAFunction(AFunction function) {
+ // No call to super() here because we want to traverse the argument list
+ // separately. We do not want the argument list productions to appear
+ // aside from the function.
+
+ if (function.getFunctionName() == null
+ || StringUtils.isEmpty(function.getFunctionName().getText())) {
+ throw new SemanticParsingException(
+ I18n.getString(MessageIDs.getMessage(
+ MessageIDs.E_MISSING_FUNCTION_NAME)),
+ MessageIDs.E_MISSING_FUNCTION_NAME,
+ function.getFunctionToken().getPos());
+ }
+
+ // collect argument list
+ ParsedParameter argumentParser = new ParsedParameter(
+ m_isGuiSource, m_paramNode, m_paramDesc);
+ PFunctionArgList functionArgList = function.getFunctionArgList();
+ if (functionArgList != null) {
+ functionArgList.apply(argumentParser);
+ }
+
+ IParamValueToken[] argumentTokens = argumentParser.getTokens().toArray(
+ new IParamValueToken[argumentParser.getTokens().size()]);
+ StringBuilder functionTextBuilder = new StringBuilder();
+ functionTextBuilder.append(function.getFunctionToken().getText())
+ .append(function.getFunctionName().getText())
+ .append(function.getBeginFunctionArgsToken().getText());
+
+ String functionPrefix = functionTextBuilder.toString();
+ for (IParamValueToken token : argumentTokens) {
+ functionTextBuilder.append(token.getGuiString());
+ }
+
+ String functionSuffix = function.getEndFunctionArgsToken().getText();
+ functionTextBuilder.append(functionSuffix);
+
+ m_paramValueTokens.add(new FunctionToken(
+ functionTextBuilder.toString(),
+ functionPrefix, functionSuffix,
+ function.getFunctionToken().getPos(), m_paramDesc,
+ argumentTokens));
+
+ }
+
+ @Override
+ public void caseTComma(TComma node) {
+ super.caseTComma(node);
+ m_paramValueTokens.add(new SimpleValueToken(
+ node.getText(), node.getPos(), m_paramDesc));
+ }
+
+ @Override
+ public void caseAEscapeSequenceFunctionArgToken(
+ AEscapeSequenceFunctionArgToken escapeSequence) {
+ super.caseAEscapeSequenceFunctionArgToken(escapeSequence);
+ m_paramValueTokens.add(new SimpleValueToken(
+ escapeSequence.getEscapedSymbolInFunction().getText(),
+ escapeSequence.getEscapedSymbolInFunction().getPos(),
+ m_paramDesc));
+ }
+
+ @Override
+ public void caseAAlphanumericFunctionArgToken(
+ AAlphanumericFunctionArgToken node) {
+ super.caseAAlphanumericFunctionArgToken(node);
+ m_paramValueTokens.add(new SimpleValueToken(
+ node.getFunctionAlphanumeric().getText(),
+ node.getFunctionAlphanumeric().getPos(),
+ m_paramDesc));
+ }
+
/**
*
* @return the tokens parsed from the AST.
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java
index f4ad451cf..8dab6bd94 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java
@@ -45,7 +45,7 @@ import org.eclipse.jubula.tools.messagehandling.MessageIDs;
* @author BREDEX GmbH
* @created 14.08.2007
*/
-public class RefToken implements IParamValueToken {
+public class RefToken extends AbstractParamValueToken {
/** prefix for a reference */
private static final String PREFIX = "={"; //$NON-NLS-1$
@@ -62,18 +62,6 @@ public class RefToken implements IParamValueToken {
*/
private String m_modelString = null;
- /**
- * index of first character of this token in the entire parameter value
- */
- private int m_startPos = 0;
-
-
- /**
- * <code>m_errorKey</code>I18NKey for error message
- * associated with result of invocation of validate()
- */
- private Integer m_errorKey;
-
/** flag for differentiation between token creation based on string in gui- or
* model representation
*/
@@ -82,9 +70,6 @@ public class RefToken implements IParamValueToken {
/** node holding this reference */
private IParameterInterfacePO m_currentNode;
- /** param description belonging to this reference */
- private IParamDescriptionPO m_desc;
-
/**
* use this constructor only for references coming from gui
* @param string represents the token
@@ -95,12 +80,13 @@ public class RefToken implements IParamValueToken {
*/
public RefToken(String string, boolean isGuiString, int startPos,
IParameterInterfacePO node, IParamDescriptionPO desc) {
+
+ super(string, startPos, desc);
if (!isValid(string, isGuiString)) {
throw new IllegalArgumentException(Messages.SyntaxErrorInReference
+ StringConstants.SPACE
+ new StringBuilder(string).toString());
}
- m_startPos = startPos;
m_isTokenGuiBased = isGuiString;
if (isGuiString) {
m_guiString = string;
@@ -108,7 +94,6 @@ public class RefToken implements IParamValueToken {
m_modelString = string;
}
m_currentNode = node;
- m_desc = desc;
}
@@ -256,7 +241,8 @@ public class RefToken implements IParamValueToken {
}
if ((paramNames.keySet()).contains(refName)) {
IParamDescriptionPO desc = paramNames.get(refName);
- if (desc.getType().equals(m_desc.getType())) {
+ if (desc.getType().equals(
+ getParamDescription().getType())) {
state = ConvValidationState.valid;
} else {
state = ConvValidationState.invalid;
@@ -272,7 +258,8 @@ public class RefToken implements IParamValueToken {
if (paramName.startsWith(refName)) {
IParamDescriptionPO desc =
paramNames.get(paramName);
- if (desc.getType().equals(m_desc.getType())) {
+ if (desc.getType().equals(
+ getParamDescription().getType())) {
state = ConvValidationState.undecided;
break;
}
@@ -341,7 +328,7 @@ public class RefToken implements IParamValueToken {
}
ParamValueConverter conv = new ModelParamValueConverter(
data.getValue(locale),
- execNode, locale, m_desc);
+ execNode, locale, getParamDescription());
stack.remove(stack.size() - 1);
return conv.getExecutionString(stack, locale);
}
@@ -366,39 +353,6 @@ public class RefToken implements IParamValueToken {
MessageIDs.E_NO_REFERENCE);
}
-
- /**
- * {@inheritDoc}
- * @see IParamValueToken#isI18Nrelevant()
- */
- public boolean isI18Nrelevant() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- * @see IParamValueToken#getErrorKey()
- */
- public Integer getErrorKey() {
- return m_errorKey;
- }
-
- /**
- * {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getEndIndex()
- */
- public int getEndIndex() {
- return m_startPos + m_guiString.length();
- }
-
- /**
- * {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getStartIndex()
- */
- public int getStartIndex() {
- return m_startPos;
- }
-
/**
* {@inheritDoc}
* @see org.eclipse.jubula.client.core.utils.IParamValueToken#getValue()
@@ -443,16 +397,6 @@ public class RefToken implements IParamValueToken {
return refName;
}
-
-
- /**
- * @param errorKey The errorKey to set.
- */
- public void setErrorKey(Integer errorKey) {
- m_errorKey = errorKey;
- }
-
-
/**
* @param modelString The modelString to set.
*/
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/SimpleValueToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/SimpleValueToken.java
index a7fbd2224..cad6ad104 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/SimpleValueToken.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/SimpleValueToken.java
@@ -26,28 +26,7 @@ import org.eclipse.jubula.tools.messagehandling.MessageIDs;
* @author BREDEX GmbH
* @created 14.08.2007
*/
-class SimpleValueToken implements IParamValueToken {
- /** Constant for a Variable as a data type of test data */
- private static final String VARIABLE = "guidancer.datatype.Variable"; //$NON-NLS-1$
-
- /**
- * <code>m_value</code> string represents the token in the GUI
- */
- private String m_value = null;
-
- /**
- * index of first character of this token in the entire parameter value
- */
- private int m_startPos = 0;
-
- /**
- * <code>m_errorKey</code>I18NKey for error message
- * associated with result of invocation of validate()
- */
- private Integer m_errorKey;
-
- /** param description belonging to currently edited parameter value */
- private IParamDescriptionPO m_desc;
+class SimpleValueToken extends AbstractParamValueToken {
/**
* @param s string represents the token
@@ -55,9 +34,7 @@ class SimpleValueToken implements IParamValueToken {
* @param desc param description belonging to currently edited parameter value
*/
public SimpleValueToken(String s, int pos, IParamDescriptionPO desc) {
- m_value = s;
- m_startPos = pos;
- m_desc = desc;
+ super(s, pos, desc);
}
@@ -67,9 +44,9 @@ class SimpleValueToken implements IParamValueToken {
*/
public ConvValidationState validate() {
ConvValidationState state = ConvValidationState.notSet;
- if (VARIABLE.equals(m_desc.getType())) {
+ if (VARIABLE.equals(getParamDescription().getType())) {
final String wordRegex = "[0-9a-z_A-Z]{1,}"; //$NON-NLS-1$
- if (Pattern.matches(wordRegex, m_value)) {
+ if (Pattern.matches(wordRegex, getValue())) {
state = ConvValidationState.valid;
} else {
state = ConvValidationState.invalid;
@@ -79,62 +56,28 @@ class SimpleValueToken implements IParamValueToken {
return state;
}
-
-
-
- /**
- * {@inheritDoc}
- * @see IParamValueToken#isI18Nrelevant()
- */
- public boolean isI18Nrelevant() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- * @see IParamValueToken#getErrorKey()
- */
- public Integer getErrorKey() {
- return m_errorKey;
- }
-
- /**
- * {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getEndIndex()
- */
- public int getEndIndex() {
- return m_startPos + m_value.length();
- }
-
/**
+ *
* {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getStartIndex()
- */
- public int getStartIndex() {
- return m_startPos;
- }
-
- /**
- * {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getValue()
*/
public String getGuiString() {
- return m_value;
+ return getValue();
}
- /** {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getExecutionString(int, org.eclipse.jubula.client.core.utils.Traverser, java.util.Locale)
+ /**
+ *
+ * {@inheritDoc}
*/
public String getExecutionString(List<ExecObject> stack, Locale locale)
throws InvalidDataException {
StringBuilder builder = new StringBuilder();
int index = 0;
do {
- char c = m_value.charAt(index);
+ char c = getValue().charAt(index);
if (c == '\\') {
- if (index + 1 < m_value.length()) {
+ if (index + 1 < getValue().length()) {
index++;
- c = m_value.charAt(index);
+ c = getValue().charAt(index);
char[] validChars = {'\\', '=', '{', '}', '$', '\''};
boolean isValid = false;
for (char validChar : validChars) {
@@ -153,35 +96,30 @@ class SimpleValueToken implements IParamValueToken {
msg.append(StringConstants.SPACE);
msg.append(Messages.AfterBackslashIn);
msg.append(StringConstants.SPACE);
- msg.append(m_value);
+ msg.append(getValue());
throw new InvalidDataException(msg.toString(),
MessageIDs.E_SYNTAX_ERROR);
}
} else {
throw new InvalidDataException(
Messages.NotAllowedToSetSingleBackslashIn
- + StringConstants.SPACE + m_value,
+ + StringConstants.SPACE + getValue(),
MessageIDs.E_SYNTAX_ERROR);
}
} else {
builder.append(c);
index++;
}
- } while (index < m_value.length());
+ } while (index < getValue().length());
return builder.toString();
}
- /** {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getModelString()
+ /**
+ *
+ * {@inheritDoc}
*/
public String getModelString() {
- return m_value;
+ return getValue();
}
- /**
- * @param errorKey The errorKey to set.
- */
- public void setErrorKey(Integer errorKey) {
- m_errorKey = errorKey;
- }
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/VariableToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/VariableToken.java
index 258758379..2d5ac8bb0 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/VariableToken.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/VariableToken.java
@@ -26,16 +26,8 @@ import org.eclipse.jubula.tools.messagehandling.MessageIDs;
* @author BREDEX GmbH
* @created 14.08.2007
*/
-class VariableToken implements IParamValueToken {
+class VariableToken extends AbstractParamValueToken {
- /** Constant for a Variable as a data type of test data */
- private static final String VARIABLE = "guidancer.datatype.Variable"; //$NON-NLS-1$
-
- /**
- * <code>m_value</code> string represents the token in the GUI
- */
- private String m_value = null;
-
/**
* represents the actual name of the variable (without the additional
* pre- and post-fix information contained in <code>m_value</code>).
@@ -43,20 +35,6 @@ class VariableToken implements IParamValueToken {
private String m_variableName = null;
/**
- * index of first character of this token in the entire parameter value
- */
- private int m_startPos = 0;
-
- /**
- * <code>m_errorKey</code>I18NKey for error message
- * associated with result of invocation of validate()
- */
- private Integer m_errorKey = null;
-
- /** param description belonging to currently edited parameter value */
- private IParamDescriptionPO m_desc;
-
- /**
* @param s string represents the token
* @param pos index of first character of token in entire string
* @param variableName The name of the variable represented by the token
@@ -66,10 +44,10 @@ class VariableToken implements IParamValueToken {
*/
public VariableToken(String s, int pos, String variableName,
IParamDescriptionPO desc) {
- m_value = s;
+
+ super(s, pos, desc);
m_variableName = variableName;
- m_startPos = pos;
- m_desc = desc;
+
}
/**
@@ -79,52 +57,19 @@ class VariableToken implements IParamValueToken {
*/
public ConvValidationState validate() {
ConvValidationState state = ConvValidationState.notSet;
- if (VARIABLE.equals(m_desc.getType())) {
+ if (VARIABLE.equals(getParamDescription().getType())) {
state = ConvValidationState.invalid;
setErrorKey(MessageIDs.E_INVALID_VAR_NAME);
}
return state;
}
-
- /**
- * {@inheritDoc}
- * @see IParamValueToken#isI18Nrelevant()
- */
- public boolean isI18Nrelevant() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- * @see IParamValueToken#getErrorKey()
- */
- public Integer getErrorKey() {
- return m_errorKey;
- }
-
- /**
- * {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getEndIndex()
- */
- public int getEndIndex() {
- return m_startPos + m_value.length();
- }
-
- /**
- * {@inheritDoc}
- * @see org.eclipse.jubula.client.core.utils.IParamValueToken#getStartIndex()
- */
- public int getStartIndex() {
- return m_startPos;
- }
-
/**
* {@inheritDoc}
* @see org.eclipse.jubula.client.core.utils.IParamValueToken#getValue()
*/
public String getGuiString() {
- return m_value;
+ return getValue();
}
/** {@inheritDoc}
@@ -136,7 +81,7 @@ class VariableToken implements IParamValueToken {
.getVariableStore().getValue(m_variableName);
if (resolvedVar == null) {
throw new InvalidDataException(Messages.VariableWithName
- + StringConstants.SPACE + m_value
+ + StringConstants.SPACE + getValue()
+ StringConstants.SPACE + Messages.IsNotResolvable,
MessageIDs.E_UNRESOLV_VAR_ERROR);
}
@@ -147,13 +92,7 @@ class VariableToken implements IParamValueToken {
* @see org.eclipse.jubula.client.core.utils.IParamValueToken#getModelString()
*/
public String getModelString() {
- return m_value;
+ return getValue();
}
- /**
- * @param errorKey The errorKey to set.
- */
- public void setErrorKey(Integer errorKey) {
- m_errorKey = errorKey;
- }
}
diff --git a/org.eclipse.jubula.releng/lib/sablecc/parameter.sable b/org.eclipse.jubula.releng/lib/sablecc/parameter.sable
index 8e1c45274..88751a380 100644
--- a/org.eclipse.jubula.releng/lib/sablecc/parameter.sable
+++ b/org.eclipse.jubula.releng/lib/sablecc/parameter.sable
@@ -1,4 +1,10 @@
-/* Grammar for Client parameter values. */
+/**
+ * Grammar for Client parameter values.
+ *
+ * nested State functionality implemented in
+ * org.eclipse.jubula.client.core.parser.parameter.JubulaParameterLexer
+ */
+
Package org.eclipse.jubula.client.core.gen.parser.parameter;
Helpers
@@ -6,7 +12,8 @@ Helpers
alphanumeric = ['0'..'9'] | ['a'..'z'] | ['A'..'Z'] | '_';
any_char = [0 .. 0xffff];
not_literal_symbol = [any_char - literal_symbol];
- escapable = ''' | '\' | '=' | '$';
+ escapable = ''' | '\' | '=' | '$' | '?';
+ escapable_in_function = escapable | ',' | '(' | ')';
States
normal,
@@ -14,13 +21,32 @@ States
var_brace,
reference,
ref_brace,
+ function_name,
+ function,
+ function_args,
literal;
Tokens
- {normal->literal}
+ {function_args->literal,normal->literal}
open_literal = ''';
+
+ {function_args->function_name,normal->function_name}
+ function_token = '?';
+ {function_name->function}
+ function_name = alphanumeric+;
+ {function->function_args}
+ begin_function_args_token = '(';
+ {function_args}
+ comma = ','(' ')?;
+ {function_args}
+ escaped_symbol_in_function = '\' escapable_in_function;
+ {function_args}
+ function_alphanumeric = alphanumeric+;
+ {function_args->normal}
+ end_function_args_token = ')';
+
- {normal->reference}
+ {function_args->reference,normal->reference}
reference_token = '=';
{normal}
escaped_symbol = '\' escapable;
@@ -28,7 +54,7 @@ Tokens
open_brace = '{';
{variable->normal,var_brace->normal,reference->normal,ref_brace->normal}
close_brace = '}';
- {normal->variable}
+ {function_args->variable,normal->variable}
variable_token = '$';
{normal}
alphanumeric = alphanumeric+;
@@ -52,8 +78,19 @@ Productions
{escape_sequence}escaped_symbol |
{reference}P.reference |
{variable}P.variable |
+ {function}P.function |
{alphanumeric}alphanumeric |
{any_sequence}char;
literal = open_literal literal_body? close_literal;
reference = reference_token open_brace? reference_body? close_brace?;
variable = variable_token open_brace? variable_body? close_brace?;
+ function = function_token function_name begin_function_args_token function_arg_list? end_function_args_token;
+ function_arg_list = {one} function_arg | {many} function_arg_list comma function_arg;
+ function_arg_token = {alphanumeric}function_alphanumeric |
+ {literal}P.literal |
+ {escape_sequence}escaped_symbol_in_function |
+ {reference}P.reference |
+ {variable}P.variable |
+ {function}P.function;
+ function_arg = function_arg_token+;
+ \ No newline at end of file
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/i18n/guidancerStrings.properties b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/i18n/guidancerStrings.properties
index a9e213ebf..6356dc219 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/i18n/guidancerStrings.properties
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/i18n/guidancerStrings.properties
@@ -369,6 +369,7 @@ ErrorMessage.MESSAGE_REQUEST=Problem while requesting a message from AUT Agent.
ErrorMessage.MESSAGE_SEND=Problem while sending a message to AUT Agent.
ErrorMessage.MISSING_CLOSING_BRACE=Missing closing brace in a name part of parameter value.
ErrorMessage.MISSING_CONTENT=Missing reference name between curly braces.
+ErrorMessage.MISSING_FUNCTION_NAME=Missing function name after function symbol.
ErrorMessage.MODIFIED_OBJECT=Object was modified in Database.
ErrorMessage.MOVE_TC_COMP_NAME_EXISTS=The selected Test Cases could not be moved. The Component Name "{0}" (which is reassigned within the current Project) exists in the external Project.
ErrorMessage.MOVE_TC_COMP_TYPE_INCOMPATIBLE=The selected Test Cases could not be moved. The Component Name "{0}" possesses incompatible types between Projects\: "{1}" is not compatible with "{2}".
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java
index 41dc69e15..3c97bd0b1 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java
@@ -460,6 +460,8 @@ public class MessageIDs {
public static final Integer E_NOT_SUPP_COMBO_ITEM = new Integer(9517);
/**reference error, because references are invalid for test data cubes. */
public static final Integer E_REF_IN_TDC = new Integer(9518);
+ /** missing name for a function in a parameter value */
+ public static final Integer E_MISSING_FUNCTION_NAME = new Integer (9519);
@@ -845,6 +847,7 @@ public class MessageIDs {
messageMap.put(E_TOO_BIG_VALUE, e, "ErrorMessage.TOO_BIG_VALUE", null); //$NON-NLS-1$
messageMap.put(E_TOO_SMALL_VALUE, e, "ErrorMessage.TOO_SMALL_VALUE", null); //$NON-NLS-1$
messageMap.put(E_NOT_SUPP_COMBO_ITEM, e, "ErrorMessage.NOT_SUPP_COMBO_ITEM", null); //$NON-NLS-1$
+ messageMap.put(E_MISSING_FUNCTION_NAME, e, "ErrorMessage.MISSING_FUNCTION_NAME", null); //$NON-NLS-1$
}
/**

Back to the top