Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/PairMatcherTest.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java7
2 files changed, 27 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/PairMatcherTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/PairMatcherTest.java
index b7bc2434610..7a13f282892 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/PairMatcherTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/PairMatcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@@ -234,4 +234,24 @@ public class PairMatcherTest extends TestCase {
otherIdx= fDocument.get().indexOf('>', idx + 1);
assertEquals(otherIdx, match.getOffset() + match.getLength() - 1);
}
+
+ public void testDoubleClosingAngleBrackets_Bug335702() {
+ fDocument.set("list<list<int>> a;");
+ int idx= fDocument.get().indexOf('<', 0);
+ IRegion match= fPairMatcher.match(fDocument, idx + 1);
+ assertNotNull(match);
+ int otherIdx= fDocument.get().lastIndexOf('>');
+ assertEquals(otherIdx, match.getOffset() + match.getLength() - 1);
+
+ match= fPairMatcher.match(fDocument, otherIdx + 1);
+ assertNotNull(match);
+ assertEquals(idx, match.getOffset());
+
+ idx= fDocument.get().indexOf('<', idx+1);
+ match= fPairMatcher.match(fDocument, idx + 1);
+ assertNotNull(match);
+ otherIdx= fDocument.get().indexOf('>', idx + 1);
+ assertEquals(otherIdx, match.getOffset() + match.getLength() - 1);
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
index b9808dae8ed..97fea7f12df 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@@ -181,6 +181,9 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* <code>false</code> otherwise
*/
private boolean isTemplateParameterOpenBracket(int offset, IDocument document, CHeuristicScanner scanner) {
+ int nextToken = scanner.nextToken(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
+ if (nextToken == Symbols.TokenSHIFTLEFT || nextToken == Symbols.TokenLESSTHAN)
+ return false;
int prevToken= scanner.previousToken(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
if (prevToken == Symbols.TokenIDENT || prevToken == Symbols.TokenTEMPLATE) {
return true;
@@ -203,6 +206,8 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
if (offset >= document.getLength() - 1)
return true;
int thisToken= scanner.previousToken(offset, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+ if (thisToken == Symbols.TokenSHIFTRIGHT)
+ return true;
if (thisToken != Symbols.TokenGREATERTHAN)
return false;
int prevToken= scanner.previousToken(scanner.getPosition(), Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));

Back to the top