aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Tepavich2012-11-02 16:47:32 (EDT)
committerScott Tepavich2012-11-02 16:48:51 (EDT)
commit5eddf150e9d3903d30c3ca247ccb4643e1de3388 (patch)
tree692b7426e0eda76c5ca9bf504dcd1b74feb3dd91
parent3c5006fef0cb28924c354bf59db6ea82d8be5599 (diff)
downloadorg.eclipse.tcf-5eddf150e9d3903d30c3ca247ccb4643e1de3388.zip
org.eclipse.tcf-5eddf150e9d3903d30c3ca247ccb4643e1de3388.tar.gz
org.eclipse.tcf-5eddf150e9d3903d30c3ca247ccb4643e1de3388.tar.bz2
Bug[390878] Context-queries for breakpoints are not wrapped with doublerefs/changes/15/8015/2
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java1
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java74
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java44
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties3
4 files changed, 83 insertions, 39 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java
index 6e61732..9328a42 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java
@@ -24,6 +24,7 @@ public class Messages extends NLS {
public static String TCFThreadFilterQueryAdvancedLabel;
public static String TCFThreadFilterQueryTreeViewLabel;
public static String TCFThreadFilterEditorFormatError;
+ public static String TCFThreadFilterEditorUnbalancedParameters;
public static String TCFThreadFilterEditorNoOpenChannel;
public static String TCFThreadFileterEditorInvalidQuery;
public static String TCFBreakpointPreferencesEnableDefaultTriggerScope;
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java
index 0bef367..8e03b70 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java
@@ -9,6 +9,9 @@
*******************************************************************************/
package org.eclipse.tcf.internal.cdt.ui.breakpoints;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
@@ -51,25 +54,31 @@ public class TCFContextQueryExpressionDialog extends SelectionDialog {
}
String getParameterInitialValue (String comparator, int initIndex){
+ String param = comparator + "=";
if (expression != null && expression.length() > 0) {
- int indexExpr = expression.indexOf (comparator, initIndex);
+ int indexExpr = expression.indexOf (param, initIndex);
if (indexExpr != -1){
// Make sure we didn't partial match to another parameter name.
if (indexExpr != 0) {
String testChar = expression.substring(indexExpr-1, indexExpr);
- if (!testChar.equals(",")) {
+ if (!testChar.matches("[,/]")) {
return getParameterInitialValue(comparator,indexExpr+1);
}
}
- int startOfVal = expression.indexOf ('=', indexExpr);
+ int startOfVal = indexExpr + param.length();
if (startOfVal != -1) {
- startOfVal += 1;
int endOfVal = -1;
if (startOfVal != 0) {
- endOfVal = expression.indexOf (',', startOfVal);
+ if (expression.charAt(startOfVal) == '"') {
+ startOfVal+=1;
+ endOfVal = expression.indexOf('"', startOfVal);
+ }
+ else {
+ endOfVal = expression.indexOf (',', startOfVal);
+ }
if (endOfVal == -1) {
endOfVal = expression.length();
- }
+ }
}
return expression.substring(startOfVal, endOfVal);
}
@@ -171,7 +180,7 @@ public class TCFContextQueryExpressionDialog extends SelectionDialog {
// Make sure we didn't partial match to another parameter name.
if (indexExpr != 0) {
String testChar = expression.substring(indexExpr-1, indexExpr);
- if (!testChar.equals(",")) {
+ if (!testChar.matches("[,/]")) {
return findParameter(comparator,indexExpr+1);
}
}
@@ -181,26 +190,43 @@ public class TCFContextQueryExpressionDialog extends SelectionDialog {
}
private boolean replaceParameter(String parameter, String replaceString, int index) {
+ String testChar = null;
+ int endLocation = 0;
+ if (replaceString.length() != 0 && expression.contains(replaceString))
+ return true;
if (index != 0) {
- String testChar = expression.substring(index+parameter.length(), index+1+parameter.length());
+ testChar = expression.substring(index+parameter.length(), index+1+parameter.length());
if (!testChar.equals("=")) {
return false;
}
testChar = expression.substring(index-1, index);
- if (!testChar.equals(",")) {
+ if (!testChar.matches("[,/]"))
return false;
+ }
+ testChar = expression.substring(index+parameter.length()+1,index+parameter.length()+2);
+ if (testChar.equals("\"")) {
+ endLocation = expression.indexOf('"', index+parameter.length()+3);
+ if (endLocation != -1 && endLocation != (expression.length() -1)) {
+ testChar = expression.substring(endLocation+1, endLocation+2);
+ if (testChar.equals(","))
+ endLocation++;
}
- else {
- index-=1;
- }
+ else
+ endLocation = -1;
+ }
+ else {
+ endLocation = expression.indexOf(',', index+1);
}
- int endLocation = expression.indexOf(',', index+1);
+
if (endLocation == -1) {
endLocation = expression.length();
+ testChar = expression.substring(index-1, index);
+ if (testChar.matches("[,]") && replaceString.length() == 0)
+ index-=1;
}
- else if (index == 0 && replaceString.length() == 0) {
+ else if (replaceString.length() == 0)
endLocation++;
- }
+
String removeStr = expression.substring(index, endLocation);
expression = expression.replace(removeStr, replaceString);
@@ -224,7 +250,11 @@ public class TCFContextQueryExpressionDialog extends SelectionDialog {
return;
}
cellString = cellString.trim();
- if (cellString.length() != 0) {
+ if (cellString.length() > 0) {
+ if (cellString.charAt(0) != '"')
+ cellString = "\"" + cellString;
+ if (cellString.charAt(cellString.length()-1 ) != '"')
+ cellString += "\"";
if (expression == null || expression.length() == 0) {
expression = new String(paramName + "=" + cellString);
}
@@ -232,12 +262,16 @@ public class TCFContextQueryExpressionDialog extends SelectionDialog {
String nameValuePair = paramName + "=" + cellString;
int strIndex = findParameter(paramName, 0);
if (strIndex == -1) {
- expression += "," + nameValuePair;
+ String check_parameter = expression;
+ Pattern p = Pattern.compile("\"([^\"]*)\"");
+ Matcher m = p.matcher(check_parameter);
+ check_parameter = m.replaceAll("temp");
+ if (check_parameter.matches("^(.*?)=(.*)$"))
+ expression += "," + nameValuePair;
+ else
+ expression += nameValuePair;
}
else {
- if (strIndex != 0) {
- nameValuePair = "," + nameValuePair;
- }
if (!replaceParameter(paramName,nameValuePair,strIndex)) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
index aad7007..5828666 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
@@ -16,6 +16,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
@@ -411,8 +413,23 @@ public class TCFThreadFilterEditor {
return result;
}
- boolean missingParameterValue(String expression, int fromIndex) {
- boolean result = false;
+ String missingParameterValue(String expression, int fromIndex) {
+ String result = null;
+ if (fromIndex == 0) {
+ // Ignore content in double-quotes.
+ Pattern p = Pattern.compile("\"([^\"]*)\"");
+ Matcher m = p.matcher(expression);
+ expression = m.replaceAll("temp");
+
+ // No whitespace
+ if (expression.matches("^(.*?)(\\s)(.*)$"))
+ return Messages.TCFThreadFilterEditorFormatError;
+
+ // Check characters around equals.
+ if (expression.matches("^(.*?)[^a-zA-Z0-9_]=[^a-zA-Z0-9_](.*)$"))
+ return Messages.TCFThreadFilterEditorUnbalancedParameters;
+ }
+
int lastIndex = expression.length();
if (lastIndex != 0 && fromIndex <= lastIndex) {
int equalsIndex = expression.indexOf('=', fromIndex);
@@ -420,23 +437,14 @@ public class TCFThreadFilterEditor {
int nextEqualsIndex = expression.indexOf('=',equalsIndex+1);
if (commaIndex == lastIndex-1 || equalsIndex == lastIndex-1 ||
equalsIndex == 0 || commaIndex == 0) {
- return true;
+ return Messages.TCFThreadFilterEditorUnbalancedParameters;
}
if (equalsIndex > 0) {
- String failPattern = new String("[=,\\s]");
- String testChar = expression.substring(equalsIndex-1, equalsIndex);
- String testNextChar = expression.substring(equalsIndex+1,equalsIndex+2);
- if (testChar.matches(failPattern) || testNextChar.matches(failPattern) ||
- (commaIndex != -1 && commaIndex < equalsIndex) ||
- (nextEqualsIndex != -1 && (commaIndex == -1 || nextEqualsIndex < commaIndex))) {
- return true;
+ if ((commaIndex != -1 && commaIndex < equalsIndex) ||
+ (nextEqualsIndex != -1 && (commaIndex == -1 || nextEqualsIndex < commaIndex))) {
+ return Messages.TCFThreadFilterEditorUnbalancedParameters;
}
if (commaIndex!=-1) {
- testChar = expression.substring(commaIndex-1, commaIndex);
- testNextChar = expression.substring(commaIndex+1,commaIndex+2);
- if (testChar.matches(failPattern) || testNextChar.matches(failPattern)) {
- return true;
- }
result = missingParameterValue(expression, commaIndex+1);
}
}
@@ -447,14 +455,14 @@ public class TCFThreadFilterEditor {
private class ExpressionModifier implements ModifyListener {
public void modifyText(ModifyEvent e) {
String expression = scopeExprCombo.getText();
- if (missingParameterValue(expression, 0)) {
+ String error = missingParameterValue(expression, 0);
+ if (error != null) {
scopeExpressionDecoration.show();
- fPage.setErrorMessage(Messages.TCFThreadFilterEditorFormatError);
+ fPage.setErrorMessage(error);
fPage.setValid(false);
}
else {
fContextList.clear();
- String error = null;
if (expression != null && expression.length() != 0)
error = getQueryFilteredContexts (expression, fContextList);
if (error == null ) {
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties
index c0b3575..a9b6716 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties
@@ -16,7 +16,8 @@ TCFThreadFilterQueryButtonAdvanced=Default Settings
TCFThreadFilterQueryButtonEdit=Edit
TCFThreadFilterQueryAdvancedLabel=Breakpoint Scoping Expression:
TCFThreadFilterQueryTreeViewLabel=Restrict to Selected Contexts:
-TCFThreadFilterEditorFormatError=Parameters must be name value pairs
+TCFThreadFilterEditorUnbalancedParameters=Parameters must be name value pairs
+TCFThreadFilterEditorFormatError=Unquoted text must contain alphanumeric characters or '_'
TCFThreadFilterEditorNoOpenChannel=No open connection to target
TCFThreadFileterEditorInvalidQuery=Invalid context query syntax:
TCFBreakpointPreferencesEnableDefaultTriggerScope=Apply scope to new breakpoints