mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Bug 335702 - [c++0x] Template brackets matching doesn't work with adjacent closing angle brackets
This commit is contained in:
parent
d4c8d89493
commit
270544ee2e
2 changed files with 27 additions and 2 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -234,4 +234,24 @@ public class PairMatcherTest extends TestCase {
|
||||||
otherIdx= fDocument.get().indexOf('>', idx + 1);
|
otherIdx= fDocument.get().indexOf('>', idx + 1);
|
||||||
assertEquals(otherIdx, match.getOffset() + match.getLength() - 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -181,6 +181,9 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
|
||||||
* <code>false</code> otherwise
|
* <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
private boolean isTemplateParameterOpenBracket(int offset, IDocument document, CHeuristicScanner scanner) {
|
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));
|
int prevToken= scanner.previousToken(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
|
||||||
if (prevToken == Symbols.TokenIDENT || prevToken == Symbols.TokenTEMPLATE) {
|
if (prevToken == Symbols.TokenIDENT || prevToken == Symbols.TokenTEMPLATE) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -203,6 +206,8 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
|
||||||
if (offset >= document.getLength() - 1)
|
if (offset >= document.getLength() - 1)
|
||||||
return true;
|
return true;
|
||||||
int thisToken= scanner.previousToken(offset, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
|
int thisToken= scanner.previousToken(offset, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
|
||||||
|
if (thisToken == Symbols.TokenSHIFTRIGHT)
|
||||||
|
return true;
|
||||||
if (thisToken != Symbols.TokenGREATERTHAN)
|
if (thisToken != Symbols.TokenGREATERTHAN)
|
||||||
return false;
|
return false;
|
||||||
int prevToken= scanner.previousToken(scanner.getPosition(), Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
|
int prevToken= scanner.previousToken(scanner.getPosition(), Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
|
||||||
|
|
Loading…
Add table
Reference in a new issue