mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 435233 - Wrong parameter is highlighted in a function call with a
list initializer
This commit is contained in:
parent
9a96a017e5
commit
c91dfd42d0
1 changed files with 23 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
* Copyright (c) 2000, 2014 QNX Software Systems 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
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
char curr= d.getChar(pos);
|
char curr= d.getChar(pos);
|
||||||
pos++;
|
pos++;
|
||||||
if (curr == '\\') {
|
if (curr == '\\') {
|
||||||
// ignore escaped characters
|
// Ignore escaped characters.
|
||||||
pos++;
|
pos++;
|
||||||
} else if (curr == ch) {
|
} else if (curr == ch) {
|
||||||
return pos;
|
return pos;
|
||||||
|
@ -81,11 +82,12 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCharCount(IDocument document, int start, int end,
|
private int getCharCount(IDocument document, int start, int end, char increment, char decrement,
|
||||||
char increment, char decrement, boolean considerNesting) throws BadLocationException {
|
boolean considerNesting) throws BadLocationException {
|
||||||
Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
|
Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
|
||||||
|
|
||||||
int nestingLevel = 0;
|
int parenNestingLevel = 0;
|
||||||
|
int braceNestingLevel = 0;
|
||||||
int charCount = 0;
|
int charCount = 0;
|
||||||
while (start < end) {
|
while (start < end) {
|
||||||
char curr = document.getChar(start++);
|
char curr = document.getChar(start++);
|
||||||
|
@ -122,12 +124,21 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
default:
|
default:
|
||||||
if (considerNesting) {
|
if (considerNesting) {
|
||||||
if ('(' == curr) {
|
if ('(' == curr) {
|
||||||
++nestingLevel;
|
++parenNestingLevel;
|
||||||
} else if (')' == curr) {
|
} else if (')' == curr) {
|
||||||
--nestingLevel;
|
--parenNestingLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nestingLevel != 0)
|
if (parenNestingLevel != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ('{' == curr) {
|
||||||
|
++braceNestingLevel;
|
||||||
|
} else if ('}' == curr) {
|
||||||
|
--braceNestingLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (braceNestingLevel != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +217,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
private int[] computeCommaPositions(String code) {
|
private int[] computeCommaPositions(String code) {
|
||||||
final int length= code.length();
|
final int length= code.length();
|
||||||
int pos= 0;
|
int pos= 0;
|
||||||
List<Integer> positions= new ArrayList<Integer>();
|
List<Integer> positions= new ArrayList<>();
|
||||||
positions.add(new Integer(-1));
|
positions.add(new Integer(-1));
|
||||||
while (pos < length && pos != -1) {
|
while (pos < length && pos != -1) {
|
||||||
char ch= code.charAt(pos);
|
char ch= code.charAt(pos);
|
||||||
|
@ -223,6 +234,9 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
case '[':
|
case '[':
|
||||||
pos= indexOfClosingPeer(code, '[', ']', pos);
|
pos= indexOfClosingPeer(code, '[', ']', pos);
|
||||||
break;
|
break;
|
||||||
|
case '{':
|
||||||
|
pos= indexOfClosingPeer(code, '{', '}', pos);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue