mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Bug 305487: ArrayStoreException using F3
This commit is contained in:
parent
05957c8002
commit
0dc6ec197c
3 changed files with 34 additions and 38 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2010 Wind River Systems, Inc. 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
|
||||||
|
@ -105,6 +105,10 @@ public class BaseUITestCase extends BaseTestCase {
|
||||||
return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", getClass(), getName(), sections);
|
return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", getClass(), getName(), sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAboveComment() throws IOException {
|
||||||
|
return getContentsForTest(1)[0].toString();
|
||||||
|
}
|
||||||
|
|
||||||
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
||||||
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2010 Wind River Systems, Inc. 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
|
||||||
|
@ -1172,4 +1172,19 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
|
||||||
assertEquals(hoffset, ((ASTNode) def).getOffset());
|
assertEquals(hoffset, ((ASTNode) def).getOffset());
|
||||||
assertEquals(9, ((ASTNode) def).getLength());
|
assertEquals(9, ((ASTNode) def).getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void test( ABC* p);
|
||||||
|
// void test( ABC* q) {}
|
||||||
|
// void call_test(){
|
||||||
|
// test( 0 );
|
||||||
|
// }
|
||||||
|
public void testBug305487() throws Exception {
|
||||||
|
String code = getAboveComment();
|
||||||
|
IFile file = importFile("testBug305487.cpp", code); //$NON-NLS-1$
|
||||||
|
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
|
||||||
|
|
||||||
|
int offset= code.indexOf("test( 0 )"); //$NON-NLS-1$
|
||||||
|
IASTNode def = testF3(file, offset + 1);
|
||||||
|
assertTrue(def instanceof IASTName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
* Copyright (c) 2009, 2010 Wind River Systems, Inc. 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
|
||||||
|
@ -192,39 +192,32 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
||||||
navigateToName(sourceName);
|
navigateToName(sourceName);
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
IName[] declNames = null;
|
List<IName> nameList= new ArrayList<IName>();
|
||||||
String filename = ast.getFilePath();
|
String filename = ast.getFilePath();
|
||||||
for (IBinding binding : bindings) {
|
for (IBinding binding : bindings) {
|
||||||
if (binding != null && !(binding instanceof IProblemBinding)) {
|
if (binding != null && !(binding instanceof IProblemBinding)) {
|
||||||
IName[] names = findDeclNames(ast, kind, binding);
|
IName[] names = findDeclNames(ast, kind, binding);
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (final IName name : names) {
|
||||||
if (names[i] instanceof IIndexName &&
|
if (name instanceof IIndexName &&
|
||||||
filename.equals(((IIndexName) names[i]).getFileLocation().getFileName())) {
|
filename.equals(((IIndexName) name).getFileLocation().getFileName())) {
|
||||||
// Exclude index names from the current file.
|
// Exclude index names from the current file.
|
||||||
names[i] = null;
|
} else if (isSameName(name, sourceName)) {
|
||||||
} else if (isSameName(names[i], sourceName)) {
|
|
||||||
// Exclude the current location.
|
// Exclude the current location.
|
||||||
names[i] = null;
|
|
||||||
} else if (binding instanceof IParameter) {
|
} else if (binding instanceof IParameter) {
|
||||||
if (!isInSameFunction(sourceName, names[i])) {
|
if (isInSameFunction(sourceName, name)) {
|
||||||
names[i] = null;
|
nameList.add(name);
|
||||||
}
|
}
|
||||||
} else if (binding instanceof ICPPTemplateParameter) {
|
} else if (binding instanceof ICPPTemplateParameter) {
|
||||||
if (!isInSameTemplate(sourceName, names[i])) {
|
if (isInSameTemplate(sourceName, name)) {
|
||||||
names[i] = null;
|
nameList.add(name);
|
||||||
|
}
|
||||||
|
} else if (name != null) {
|
||||||
|
nameList.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compact(names);
|
|
||||||
if (declNames == null) {
|
|
||||||
declNames = names;
|
|
||||||
} else {
|
|
||||||
declNames = (IName[]) ArrayUtil.addAll(IName.class, declNames, names);
|
|
||||||
}
|
}
|
||||||
}
|
IName[] declNames = nameList.toArray(new IName[nameList.size()]);
|
||||||
}
|
|
||||||
declNames = (IName[]) ArrayUtil.removeNulls(IName.class, declNames);
|
|
||||||
|
|
||||||
if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, declNames)) {
|
if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, declNames)) {
|
||||||
found= true;
|
found= true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -377,22 +370,6 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compacts an array by moving all <code>null</code> elements to the end.
|
|
||||||
* @param array
|
|
||||||
*/
|
|
||||||
private void compact(Object[] array) {
|
|
||||||
for (int i = 0, j = 0; i < array.length; i++) {
|
|
||||||
if (array[i] != null) {
|
|
||||||
if (i != j) {
|
|
||||||
array[j] = array[i];
|
|
||||||
array[i] = null;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSameName(IName n1, IName n2) {
|
private boolean isSameName(IName n1, IName n2) {
|
||||||
if (n1 == n2)
|
if (n1 == n2)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue