1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-05-21 19:44:46 -07:00
parent 66131f1da6
commit a17d1225d1
3 changed files with 42 additions and 43 deletions

View file

@ -228,7 +228,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
final IASTName[] result= {null}; final IASTName[] result= {null};
if (sel instanceof ITextSelection) { if (sel instanceof ITextSelection) {
final ITextSelection textSel = (ITextSelection)sel; final ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)editor.getInputCElement(); ITranslationUnit tu = editor.getInputCElement();
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() { IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
@Override @Override
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException { public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {

View file

@ -34,7 +34,7 @@ import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/** /**
* Test Ctrl_F3/F3 with the DOM Indexer for a C++ project. * Test Ctrl-F3/F3 with the DOM Indexer for a C++ project.
*/ */
public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsIndexer { public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsIndexer {
private static final int MAX_WAIT_TIME = 8000; private static final int MAX_WAIT_TIME = 8000;
@ -170,7 +170,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
int hoffset= hcode.indexOf("testTemplate"); int hoffset= hcode.indexOf("testTemplate");
int soffset = scode.indexOf("testTemplate"); int soffset = scode.indexOf("testTemplate");
IASTNode def = testF3(file, soffset+2); IASTNode def = testF3(file, soffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertEquals("testTemplate", ((IASTName) def).toString()); assertEquals("testTemplate", ((IASTName) def).toString());
assertEquals(hoffset, ((ASTNode) def).getOffset()); assertEquals(hoffset, ((ASTNode) def).getOffset());
@ -227,8 +227,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
int hoffset= hcode.indexOf("MyInt"); int hoffset= hcode.indexOf("MyInt");
int soffset = scode.indexOf("MyInt"); int soffset = scode.indexOf("MyInt");
IASTNode decl = testF3(file, soffset+2); IASTNode decl = testF3(file, soffset + 2);
IASTNode def = testF3(hfile, hoffset+2); IASTNode def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyInt", ((IASTName) decl).toString()); assertEquals("MyInt", ((IASTName) decl).toString());
@ -240,8 +240,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyConst"); hoffset= hcode.indexOf("MyConst");
soffset = scode.indexOf("MyConst"); soffset = scode.indexOf("MyConst");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyConst", ((IASTName) decl).toString()); assertEquals("MyConst", ((IASTName) decl).toString());
@ -253,8 +253,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyFunc"); hoffset= hcode.indexOf("MyFunc");
soffset = scode.indexOf("MyFunc"); soffset = scode.indexOf("MyFunc");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyFunc", ((IASTName) decl).toString()); assertEquals("MyFunc", ((IASTName) decl).toString());
@ -266,8 +266,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyStruct"); hoffset= hcode.indexOf("MyStruct");
soffset = scode.indexOf("MyStruct"); soffset = scode.indexOf("MyStruct");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyStruct", ((IASTName) decl).toString()); assertEquals("MyStruct", ((IASTName) decl).toString());
@ -279,8 +279,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyClass"); hoffset= hcode.indexOf("MyClass");
soffset = scode.indexOf("MyClass"); soffset = scode.indexOf("MyClass");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyClass", ((IASTName) decl).toString()); assertEquals("MyClass", ((IASTName) decl).toString());
@ -984,6 +984,24 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
assertNode("gvar", offset0, decl); assertNode("gvar", offset0, decl);
} }
// #define MYMACRO
// #undef MYMACRO
public void testUndef_312399() throws Exception {
StringBuilder[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
IFile hfile = importFile("testUndef_312399.h", hcode);
IFile file = importFile("testUndef_312399.cpp", scode);
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
IASTNode target = testF3(file, scode.indexOf("MYMACRO"));
assertTrue(target instanceof IASTName);
assertEquals("MYMACRO", ((IASTName) target).toString());
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset());
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength());
}
// int wurscht; // int wurscht;
// #include "aheader.h" // #include "aheader.h"
@ -1229,22 +1247,4 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
assertEquals("ambiguous input: 2", e.getMessage()); assertEquals("ambiguous input: 2", e.getMessage());
} }
} }
// #define MYMACRO
// #undef MYMACRO
public void testUndef_312399() throws Exception {
StringBuilder[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
IFile hfile = importFile("testUndef_312399.h", hcode);
IFile file = importFile("testUndef_312399.cpp", scode);
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
IASTNode target = testF3(file, scode.indexOf("MYMACRO"));
assertTrue(target instanceof IASTName);
assertEquals("MYMACRO", ((IASTName) target).toString());
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset());
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength());
}
} }

View file

@ -8,7 +8,6 @@
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection; package org.eclipse.cdt.ui.tests.text.selection;
import junit.framework.Test; import junit.framework.Test;