Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2011-01-31 10:53:49 +0000
committerAnton Leherbauer2011-01-31 10:53:49 +0000
commit270544ee2e9aeaef8b4a690fd9cdd1c8b3bdf70a (patch)
treeebb127d38b71b94fac5548db0589795694fcf289
parentd4c8d8949379b7f9c1c864292317623fbc7d7e00 (diff)
downloadorg.eclipse.cdt-201101311025.tar.gz
org.eclipse.cdt-201101311025.tar.xz
org.eclipse.cdt-201101311025.zip
Bug 335702 - [c++0x] Template brackets matching doesn't work with adjacent closing angle bracketsv201101311025
-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