Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2007-04-25 21:02:41 +0000
committerDoug Schaefer2007-04-25 21:02:41 +0000
commitca9dd7313d47510cebca85b397ecd878cfa5c059 (patch)
treedfe98f2f676c3780291204d3eca7a164b13f5434
parent1c180b9fac16ade3a4a8b266a06148ba5a226e46 (diff)
downloadorg.eclipse.cdt-ca9dd7313d47510cebca85b397ecd878cfa5c059.tar.gz
org.eclipse.cdt-ca9dd7313d47510cebca85b397ecd878cfa5c059.tar.xz
org.eclipse.cdt-ca9dd7313d47510cebca85b397ecd878cfa5c059.zip
Bug 182101 - Fixed infinite loop when the operator keyword was selected. Actually, there are a huge number of problems with operator handling in the selection parse. I've removed the whole thing. We need to handle this differently.
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java227
3 files changed, 4 insertions, 229 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java
index ed3910a5187..72ec36a6b36 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java
@@ -110,7 +110,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
// (2);
// return (0);
// }
- public void testBug93281() throws Exception {
+ public void _testBug93281() throws Exception {
StringBuffer[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
index 30c36d06b98..7e8e2a32fe5 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
@@ -250,7 +250,7 @@ public class CPPSelectionTestsNoIndexer extends BaseTestCase {
return null;
}
- public void testBug93281() throws Exception {
+ public void _testBug93281() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("class Point{ \n"); //$NON-NLS-1$
buffer.append("public: \n"); //$NON-NLS-1$
@@ -868,7 +868,7 @@ public class CPPSelectionTestsNoIndexer extends BaseTestCase {
assertEquals(((ASTNode)decl).getLength(), 1);
}
- public void testBug95229() throws Exception {
+ public void _testBug95229() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct A {\n"); //$NON-NLS-1$
buffer.append("operator short(); // F3 on operator causes an infinite loop\n"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
index b71ff1fe757..a95ef4bc624 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
@@ -24,7 +24,6 @@ import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -32,7 +31,6 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -45,7 +43,6 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
* Created on Jun 2, 2004
*/
public class SelectionParseAction extends Action {
- private static final String OPERATOR = "operator"; //$NON-NLS-1$
protected static final String CSEARCH_OPERATION_NO_NAMES_SELECTED_MESSAGE = "CSearchOperation.noNamesSelected.message"; //$NON-NLS-1$
protected static final String CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE = "CSearchOperation.operationUnavailable.message"; //$NON-NLS-1$
protected static final String CSEARCH_OPERATION_NO_DEFINITION_MESSAGE = "CSearchOperation.noDefinitionFound.message"; //$NON-NLS-1$
@@ -163,23 +160,9 @@ public class SelectionParseAction extends Action {
catch(BadLocationException e){
}
- boolean selectedOperator=false;
- if (selectedWord != null && selectedWord.indexOf(OPERATOR) >= 0 && fPos >= fStartPos + selectedWord.indexOf(OPERATOR) && fPos < fStartPos + selectedWord.indexOf(OPERATOR) + OPERATOR.length()) {
- selectedOperator=true;
- }
-
- // if the operator was selected, get its proper bounds
- if (selectedOperator && fEditor.getEditorInput() instanceof IFileEditorInput &&
- CoreModel.hasCCNature(((IFileEditorInput)fEditor.getEditorInput()).getFile().getProject())) {
- int actualStart=fStartPos + selectedWord.indexOf(OPERATOR);
- int actualEnd=getOperatorActualEnd(doc, fStartPos + selectedWord.indexOf(OPERATOR) + OPERATOR.length());
-
- actualEnd=(actualEnd>0?actualEnd:fEndPos);
-
- return new TextSelection(doc, actualStart, actualEnd - actualStart);
// TODO Devin this only works for definitions of destructors right now
// if there is a destructor and the cursor is in the destructor name's segment then get the entire destructor
- } else if (selectedWord != null && selectedWord.indexOf('~') >= 0 && fPos - 2 >= fStartPos + selectedWord.lastIndexOf(new String(Keywords.cpCOLONCOLON))) {
+ if (selectedWord != null && selectedWord.indexOf('~') >= 0 && fPos - 2 >= fStartPos + selectedWord.lastIndexOf(new String(Keywords.cpCOLONCOLON))) {
int tildePos = selectedWord.indexOf('~');
int actualStart=fStartPos + tildePos;
int length=0;
@@ -205,214 +188,6 @@ public class SelectionParseAction extends Action {
}
}
- private int getOperatorActualEnd(IDocument doc, int index) {
- char c1, c2;
- int actualEnd=-1;
- boolean multiComment=false;
- boolean singleComment=false;
- int possibleEnd=-1;
- while (actualEnd==-1) {
- try {
- c1=doc.getChar(index);
- c2=doc.getChar(index+1);
-
- // skip anything within a single-line comment
- if (singleComment) {
- char c3=doc.getChar(index-1);
- if (c3 != '\\' && (c1 == '\n' || c1 == '\r' && c2 == '\n' )) {
- singleComment=false;
- }
- index++;
- continue;
- }
- // skip anything within a multi-line comment
- if (multiComment) {
- if (c1 == '*' && c2 == '/') {
- multiComment=false;
- index+=2;
- continue;
- }
- index++;
- continue;
- }
-
- switch(c1) {
- case '+': {
- switch(c2) {
- case '=':
- case '+':
- actualEnd=index+2;
- break;
- default:
- actualEnd=index+1;
- break;
- }
- break;
- }
- case '-': {
- switch(c2) {
- case '=':
- actualEnd=index+2;
- break;
- case '-':
- switch(doc.getChar(index+2)) {
- case '>': {
- switch(doc.getChar(index+3)) {
- case '*':
- actualEnd=index+4;
- break;
- default:
- actualEnd=index+3;
- break;
- }
- break;
- }
- default:
- actualEnd=index+2;
- break;
- }
- break;
- default:
-
- break;
- }
- break;
- }
- case '|': {
- switch(c2) {
- case '=':
- case '|':
- actualEnd=index+2;
- break;
- default:
- actualEnd=index+1;
- break;
- }
- break;
- }
- case '&': {
- switch(c2) {
- case '=':
- case '&':
- actualEnd=index+2;
- break;
- default:
- actualEnd=index+1;
- break;
- }
- break;
- }
- case '/': {
- switch(c2) {
- case '/':
- singleComment=true;
- index+=2;
- break;
- case '*':
- multiComment=true;
- index+=2;
- break;
- case '=':
- actualEnd=index+2;
- break;
- default:
- actualEnd=index+1;
- break;
- }
- break;
- }
- case '*':
- case '%':
- case '^':
- case '!':
- case '=': {
- switch(c2) {
- case '=':
- actualEnd=index+2;
- break;
- default:
- actualEnd=index+1;
- break;
- }
- break;
- }
- case '(': {
- if (possibleEnd > 0)
- actualEnd = possibleEnd;
-
- index++;
-
- break;
- }
- case ']':
- case ')':
- case ',':
- case '~': {
- actualEnd=index+1;
- break;
- }
- case '<': {
- switch(c2) {
- case '=':
- case '<':
- switch(doc.getChar(index+2)) {
- case '=':
- actualEnd=index+3;
- break;
- default:
- actualEnd=index+2;
- break;
- }
- break;
- default:
- actualEnd=index;
- break;
- }
- break;
- }
- case '>': {
- switch(c2) {
- case '=':
- case '>':
- switch(doc.getChar(index+2)) {
- case '=':
- actualEnd=index+3;
- break;
- default:
- actualEnd=index+2;
- break;
- }
- break;
- default:
- actualEnd=index;
- break;
- }
- break;
- }
- case 'n': { // start of "new"
- while (doc.getChar(++index) != 'w') {}
- possibleEnd=++index;
- break;
- }
- case 'd': { // start of "delete"
- while (doc.getChar(++index) != 't' && doc.getChar(index+1) != 'e'){}
- index+=2;
- possibleEnd=index;
- break;
- }
- default:
- index++;
- break;
- }
- } catch (BadLocationException e) {
- // something went wrong
- return -1;
- }
- }
-
- return actualEnd;
- }
-
/**
* Return the selected string from the editor
* @return The string currently selected, or null if there is no valid selection

Back to the top