mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
CORE & UI
Removed IParserCallback. Partially converted DOM to ISourceElementRequestor (requires refactoring of CModelBuilder & StuctureComparator modules in near future). Completely finished ISourceElementRequestor/IASTFactory work for QuickParse mode. Added pointer to methods/functions into AST callback structure. Restructured AST class hierarchy. Removed the old IParserCallback return Objects from every Parser method. TESTS Rewrote the entire DOMTests suite to now be AST tests. Removed DOMTests, BaseDOMTest, DOMFailedTests after methods were migrated to QuickParseASTTests & ASTFailedTests. Made sure every parser failed test had a defect number associated with it.
This commit is contained in:
parent
bc45e8c29c
commit
b43dece8ee
113 changed files with 6348 additions and 7885 deletions
|
@ -1,4 +1,9 @@
|
|||
2003-06-15 Victor Mozgin
|
||||
2003-07-17
|
||||
Rewrote the entire DOMTests suite to now be AST tests.
|
||||
Removed DOMTests, BaseDOMTest, DOMFailedTests after methods were migrated to QuickParseASTTests & ASTFailedTests.
|
||||
Made sure every parser failed test had a defect number associated with it.
|
||||
|
||||
2003-07-15 Victor Mozgin
|
||||
Moved testBug39349() from DOMFailedTest.java to DOMTests.java.
|
||||
Moved testBug39544() from DOMFailedTest.java to DOMTests.java.
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ import org.eclipse.core.runtime.Path;
|
|||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class CModelElementsFailedTests extends TestCase {
|
||||
private ICProject fCProject;
|
||||
|
||||
private static final boolean domCurrentlyBroken = true;
|
||||
private ICProject fCProject;
|
||||
private IFile headerFile;
|
||||
private NullProgressMonitor monitor;
|
||||
|
||||
|
@ -100,6 +102,14 @@ public class CModelElementsFailedTests extends TestCase {
|
|||
|
||||
// tu ---> namespace: MyPackage
|
||||
ArrayList tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||
// INSERTED BY JOHNC 7/17/2003 to make fail test fail rather than err
|
||||
if( domCurrentlyBroken )
|
||||
{
|
||||
assertFalse( "There are declarations - failure", tuPackages.size() != 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
INamespace namespace = (INamespace) tuPackages.get(0);
|
||||
assertEquals(namespace.getElementName(), new String("MyPackage"));
|
||||
|
||||
|
|
|
@ -0,0 +1,465 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.failedTests;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.tests.BaseASTTest;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTFailedTests extends BaseASTTest
|
||||
{
|
||||
private static final boolean debugging = false;
|
||||
public ASTFailedTests(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
public void testBug36730() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("FUNCTION_MACRO( 1, a )\n int i;");
|
||||
}
|
||||
public void testBug39504A() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
IASTVariable variable = (IASTVariable)parse("int y = sizeof(x[0]);").getDeclarations().next();
|
||||
}
|
||||
catch( ClassCastException cce )
|
||||
{
|
||||
assertFalse( "We should not get a cast error here", false );
|
||||
}
|
||||
}
|
||||
public void testBug39504B() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("int y = sizeof (int*);");
|
||||
}
|
||||
public void testBug39505A() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
|
||||
}
|
||||
public void testBug39505B() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("int* gp_down = static_cast<int*>(gp_stat);");
|
||||
}
|
||||
|
||||
public void testBug39523()
|
||||
{
|
||||
if( ! debugging )
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("#define e0 \"a\"\n");
|
||||
code.write("#define e1 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0\n");
|
||||
code.write("#define e2 e1 e1 e1 e1 e1 e1 e1 e1 e1 e1\n");
|
||||
code.write("#define e3 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2\n");
|
||||
code.write("#define e4 e3 e3 e3 e3 e3 e3 e3 e3 e3 e3\n");
|
||||
code.write("#define e5 e4 e4 e4 e4 e4 e4 e4 e4 e4 e4\n");
|
||||
code.write("void foo() { (void)(e5); }\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
boolean testPassed = false;
|
||||
try {
|
||||
parse(code.toString());
|
||||
testPassed = true;
|
||||
fail( "We should not reach this point");
|
||||
} catch (Throwable e) {
|
||||
if (!(e instanceof StackOverflowError))
|
||||
fail("Unexpected Error: " + e.getMessage());
|
||||
}
|
||||
if (testPassed)
|
||||
fail("The expected error did not occur.");
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug39525() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("C &(C::*DD)(const C &x) = &C::operator=;");
|
||||
}
|
||||
public void testBug39526() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("UnitList unit_list (String(\"keV\"));");
|
||||
}
|
||||
public void testBug39528() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write("struct B: public A {\n");
|
||||
code.write(" A a;\n");
|
||||
code.write(" B() try : A(1), a(2)\n");
|
||||
code.write(" { throw 1; }\n");
|
||||
code.write(" catch (...)\n");
|
||||
code.write(" { if (c != 3) r |= 1; }\n");
|
||||
code.write("};\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
assertCodeFailsParse(code.toString());
|
||||
}
|
||||
public void testBug39531() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("class AString { operator char const *() const; };");
|
||||
}
|
||||
public void testBug39532() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("class N1::N2::B : public A {};");
|
||||
}
|
||||
public void testBug39535() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("namespace bar = foo;");
|
||||
}
|
||||
public void testBug39536A() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("template<class E> class X { X<E>(); };");
|
||||
}
|
||||
public void testBug39536B() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("template<class E> class X { inline X<E>(int); };");
|
||||
}
|
||||
public void testBug39537() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("typedef foo<(U::id > 0)> foobar;");
|
||||
}
|
||||
public void testBug39538() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("template C::operator int<float> ();");
|
||||
}
|
||||
public void testBug39540() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("class {} const null;");
|
||||
}
|
||||
public void testBug39542() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("void f(int a, struct {int b[a];} c) {}");
|
||||
}
|
||||
public void testBug39546() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("signed char c = (signed char) 0xffffffff;");
|
||||
}
|
||||
//Here starts C99-specific section
|
||||
public void testBug39549() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("struct X x = { .b = 40, .z = {} };");
|
||||
}
|
||||
public void testBug39550() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("double x = 0x1.fp1;");
|
||||
}
|
||||
public void testBug39551A() throws Exception
|
||||
{
|
||||
IASTFunction function = (IASTFunction)parse("extern float _Complex conjf (float _Complex);").getDeclarations().next();
|
||||
assertEquals( function.getName(), "conjf");
|
||||
}
|
||||
public void testBug39551B() throws Exception
|
||||
{
|
||||
IASTVariable variable = (IASTVariable)parse("_Imaginary double id = 99.99 * __I__;").getDeclarations().next();
|
||||
assertEquals( variable.getName(), "id");
|
||||
}
|
||||
|
||||
public void testBug39552A() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write(
|
||||
"%:define glue(x, y) x %:%: y /* #define glue(x, y) x ## y. */\n");
|
||||
code.write("#ifndef glue\n");
|
||||
code.write("#error glue not defined!\n");
|
||||
code.write("#endif\n");
|
||||
code.write("%:define str(x) %:x /* #define str(x) #x */\n");
|
||||
code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
|
||||
code.write("glue (<, %) /* { */\n");
|
||||
code.write(" /* di_str[] = */\n");
|
||||
code.write(
|
||||
" const char di_str glue(<, :)glue(:, >) = str(%:%:<::><%%>%:);\n");
|
||||
code.write(
|
||||
" /* Check the glue macro actually pastes, and that the spelling of\n");
|
||||
code.write(" all digraphs is preserved. */\n");
|
||||
code.write(" if (glue(str, cmp) (di_str, \"%:%:<::><%%>%:\"))\n");
|
||||
code.write(" err (\"Digraph spelling not preserved!\");\n");
|
||||
code.write(" return 0;\n");
|
||||
code.write("glue (%, >) /* } */\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
assertCodeFailsParse(code.toString());
|
||||
}
|
||||
public void testBug39552B() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write("??=include <stdio.h>\n");
|
||||
code.write("??=define TWELVE 1??/\n");
|
||||
code.write("2\n");
|
||||
code.write("static const char str??(??) = \"0123456789??/n\";\n");
|
||||
code.write("int\n");
|
||||
code.write("main(void)\n");
|
||||
code.write("??<\n");
|
||||
code.write(" unsigned char x = 5;\n");
|
||||
code.write(" if (sizeof str != TWELVE)\n");
|
||||
code.write(" abort ();\n");
|
||||
code.write(
|
||||
" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
|
||||
code.write(" x ??'= 3;\n");
|
||||
code.write(" if (x != 6)\n");
|
||||
code.write(" abort ();\n");
|
||||
code.write(" if ((5 ??! 3) != 7)\n");
|
||||
code.write(" abort ();\n");
|
||||
code.write(" return 0;\n");
|
||||
code.write("??>\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
assertCodeFailsParse(code.toString());
|
||||
}
|
||||
public void testBug39553() throws Exception
|
||||
{
|
||||
parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC");
|
||||
assertFalse( quickParseCallback.getInclusions().hasNext() );
|
||||
}
|
||||
public void testBug39554() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("_Pragma(\"foobar\")");
|
||||
}
|
||||
public void testBug39556() throws Exception
|
||||
{
|
||||
IASTFunction function = (IASTFunction)parse("int *restrict ip_fn (void);").getDeclarations().next();
|
||||
assertFalse(
|
||||
"The expected error did not occur.",
|
||||
function.getReturnType().getPointerOperators().hasNext() );
|
||||
}
|
||||
|
||||
//Here C99-specific section ends
|
||||
//Here GCC-specific section starts
|
||||
public void testBug39676() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("struct { int e1, e2; } v = { e2: 0 }");
|
||||
}
|
||||
public void testBug39677() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("B::B() : a(({ 1; })) {}");
|
||||
}
|
||||
public void testBug39678() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("char *s = L\"a\" \"b\";");
|
||||
}
|
||||
public void testBug39679() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("Foo blat() return f(4) {}");
|
||||
}
|
||||
public void testBug39681() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write("double\n");
|
||||
code.write("foo (double a, double b)\n");
|
||||
code.write("{\n");
|
||||
code.write(" double square (double z) { return z * z; }\n");
|
||||
code.write(" return square (a) + square (b);\n");
|
||||
code.write("}\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
parse(code.toString());
|
||||
}
|
||||
|
||||
public void testBug39682() throws Exception
|
||||
{
|
||||
IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)parse("typedef name = (a+1);").getDeclarations().next();
|
||||
assertFalse(
|
||||
"The expected error did not occur.",
|
||||
typedef.getName().equals( "name" ) );
|
||||
}
|
||||
public void testBug39684() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("typeof(foo(1)) bar () { return foo(1); }");
|
||||
}
|
||||
public void testBug39686() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write("__complex__ double x; // complex double\n");
|
||||
code.write("__complex__ short int a; // complex short int\n");
|
||||
code.write("x = 2.5fi; // 2.5 imaginary float literal\n");
|
||||
code.write("a = 3i; // imaginary integer literal\n");
|
||||
code.write("double v = __real__ x; // real part of expression\n");
|
||||
code.write(
|
||||
"double w = __imag__ x; // imaginary part of expression\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
assertCodeFailsParse(code.toString());
|
||||
}
|
||||
public void testBug39687() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("struct entry tester (int len; char data[len][len], int len) {}");
|
||||
}
|
||||
public void testBug39688() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write("#define decl(type, vars...) \\\n");
|
||||
code.write(" type vars ;\n");
|
||||
code.write("decl(int, x, y)\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
Iterator declarations = parse(code.toString()).getDeclarations();
|
||||
assertFalse( "Should be 2 declarations, not 0", declarations.hasNext() );
|
||||
}
|
||||
public void testBug39694() throws Exception
|
||||
{
|
||||
IASTVariable variable = (IASTVariable)parse("int ab$cd = 1;").getDeclarations().next();
|
||||
assertFalse(
|
||||
"The expected error did not occur.",
|
||||
variable.equals("ab$cd"));
|
||||
}
|
||||
public void testBug39695() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("int a = __alignof__ (int);");
|
||||
}
|
||||
public void testBug39695A() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("int foo asm (\"myfoo\") = 2;");
|
||||
}
|
||||
public void testBug39695B() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("extern func () asm (\"FUNC\");");
|
||||
}
|
||||
public void testBug39695C() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("register int *foo asm (\"a5\");");
|
||||
}
|
||||
public void testBug39698A() throws Exception
|
||||
{
|
||||
Iterator declarations = parse("int c = a <? b;").getDeclarations();
|
||||
assertFalse( "Should be 1 declaration, not 0", declarations.hasNext() );
|
||||
}
|
||||
public void testBug39698B() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("int c = a >? b;");
|
||||
}
|
||||
public void testBug39701A() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("extern template int max (int, int);");
|
||||
}
|
||||
public void testBug39701B() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("inline template class Foo<int>;");
|
||||
}
|
||||
public void testBug39701C() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("static template class Foo<int>;");
|
||||
}
|
||||
public void testBug39702() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write("signature T {\n");
|
||||
code.write(" int f (int);\n");
|
||||
code.write(" int f0 () { return f (0); };\n");
|
||||
code.write("};\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
Iterator declarations = parse(code.toString()).getDeclarations();
|
||||
IASTDeclaration d = (IASTDeclaration)declarations.next();
|
||||
assertFalse( "Should be 1 declaration, not 2", !declarations.hasNext() );
|
||||
}
|
||||
public void testBug39703() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
{
|
||||
code.write(
|
||||
"/* __extension__ enables GNU C mode for the duration of the declaration. */\n");
|
||||
code.write("__extension__ struct G {\n");
|
||||
code.write(" struct { char z; };\n");
|
||||
code.write(" char g;\n");
|
||||
code.write("};\n");
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
}
|
||||
IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)assertSoleDeclaration(code.toString());
|
||||
assertEquals( ((IASTClassSpecifier)abs.getTypeSpecifier()).getName(), "G" );
|
||||
}
|
||||
public void testBug39704A() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("__declspec (dllimport) int foo;");
|
||||
}
|
||||
|
||||
|
||||
public void testBug39704B() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
IASTPointerToFunction p2f = (IASTPointerToFunction)assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));");
|
||||
fail( "We should not reach this point");
|
||||
}
|
||||
catch( ClassCastException cce )
|
||||
{
|
||||
failedAsExpected();
|
||||
}
|
||||
}
|
||||
public void testBug39704C() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));");
|
||||
assertNotReached();
|
||||
} catch( ClassCastException cce )
|
||||
{
|
||||
}
|
||||
}
|
||||
public void testBug39704D() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("__declspec(dllexport) int func1 (int a) {}");
|
||||
}
|
||||
public void testBug39705() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("#ident \"@(#)filename.c 1.3 90/02/12\"");
|
||||
}
|
||||
//Here GCC-specific section ends
|
||||
public void testBug40007() throws Exception
|
||||
{
|
||||
parse("int y = #;");
|
||||
}
|
||||
|
||||
public void testBug40422() throws Exception {
|
||||
// Parse and get the translaton unit
|
||||
parse("int A::* x = 0;").getDeclarations().next();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,468 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.failedTests;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.cdt.core.parser.tests.BaseDOMTest;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.Declarator;
|
||||
import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class DOMFailedTest extends BaseDOMTest {
|
||||
|
||||
public DOMFailedTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBug36730()throws Exception {
|
||||
failTest("FUNCTION_MACRO( 1, a )\n int i;");
|
||||
}
|
||||
|
||||
public void testBug39504A() throws Exception {
|
||||
TranslationUnit tu = parse("int y = sizeof(x[0]);");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertFalse("The expected error did not occur.", declaration.getDeclarators().size() == 1 );
|
||||
}
|
||||
|
||||
public void testBug39504B() throws Exception {
|
||||
failTest("int y = sizeof (int*);");
|
||||
}
|
||||
|
||||
public void testBug39505A() throws Exception {
|
||||
failTest("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
|
||||
}
|
||||
|
||||
public void testBug39505B() throws Exception {
|
||||
failTest("int* gp_down = static_cast<int*>(gp_stat);");
|
||||
}
|
||||
|
||||
public void testBug39523() {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("#define e0 \"a\"\n");
|
||||
code.write("#define e1 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0\n");
|
||||
code.write("#define e2 e1 e1 e1 e1 e1 e1 e1 e1 e1 e1\n");
|
||||
code.write("#define e3 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2\n");
|
||||
code.write("#define e4 e3 e3 e3 e3 e3 e3 e3 e3 e3 e3\n");
|
||||
code.write("#define e5 e4 e4 e4 e4 e4 e4 e4 e4 e4 e4\n");
|
||||
code.write("void foo() { (void)(e5); }\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
boolean testPassed = false;
|
||||
try {
|
||||
parse(code.toString());
|
||||
testPassed = true;
|
||||
fail( "We should not reach this point");
|
||||
} catch (Throwable e) {
|
||||
if (!(e instanceof StackOverflowError))
|
||||
fail("Unexpected Error: " + e.getMessage());
|
||||
}
|
||||
if (testPassed)
|
||||
fail("The expected error did not occur.");
|
||||
}
|
||||
|
||||
public void testBug39525() throws Exception {
|
||||
failTest("C &(C::*DD)(const C &x) = &C::operator=;");
|
||||
}
|
||||
|
||||
public void testBug39526() throws Exception {
|
||||
failTest("UnitList unit_list (String(\"keV\"));");
|
||||
}
|
||||
|
||||
public void testBug39528() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("struct B: public A {\n");
|
||||
code.write(" A a;\n");
|
||||
code.write(" B() try : A(1), a(2)\n");
|
||||
code.write(" { throw 1; }\n");
|
||||
code.write(" catch (...)\n");
|
||||
code.write(" { if (c != 3) r |= 1; }\n");
|
||||
code.write("};\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
failTest(code.toString());
|
||||
}
|
||||
|
||||
public void testBug39531() throws Exception {
|
||||
failTest("class AString { operator char const *() const; };");
|
||||
}
|
||||
|
||||
public void testBug39532() throws Exception {
|
||||
failTest("class N1::N2::B : public A {};");
|
||||
}
|
||||
|
||||
public void testBug39535() throws Exception {
|
||||
failTest("namespace bar = foo;");
|
||||
}
|
||||
|
||||
public void testBug39536A() throws Exception {
|
||||
TranslationUnit tu = parse("template<class E> class X { X<E>(); };");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
TemplateDeclaration tDeclaration = (TemplateDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(tDeclaration.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tDeclaration.getDeclarations().get(0);
|
||||
ClassSpecifier cs = (ClassSpecifier)declaration.getTypeSpecifier();
|
||||
assertEquals(cs.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration2 = (SimpleDeclaration)cs.getDeclarations().get(0);
|
||||
assertEquals(declaration2.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration2.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", declarator.getName() != null);
|
||||
}
|
||||
|
||||
public void testBug39536B() throws Exception {
|
||||
failTest("template<class E> class X { inline X<E>(int); };");
|
||||
}
|
||||
|
||||
public void testBug39537() throws Exception {
|
||||
failTest("typedef foo<(U::id > 0)> foobar;");
|
||||
}
|
||||
|
||||
public void testBug39538() throws Exception {
|
||||
failTest("template C::operator int<float> ();");
|
||||
}
|
||||
|
||||
public void testBug39540() throws Exception {
|
||||
failTest("class {} const null;");
|
||||
}
|
||||
|
||||
public void testBug39542() throws Exception {
|
||||
failTest("void f(int a, struct {int b[a];} c) {}");
|
||||
}
|
||||
|
||||
public void testBug39546() throws Exception {
|
||||
failTest("signed char c = (signed char) 0xffffffff;");
|
||||
}
|
||||
|
||||
|
||||
// Here starts C99-specific section
|
||||
|
||||
public void testBug39549() throws Exception {
|
||||
failTest("struct X x = { .b = 40, .z = {} };");
|
||||
}
|
||||
|
||||
public void testBug39550() throws Exception {
|
||||
failTest("double x = 0x1.fp1;");
|
||||
}
|
||||
|
||||
public void testBug39551A() throws Exception {
|
||||
TranslationUnit tu = parse("extern float _Complex conjf (float _Complex);");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(declaration.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
|
||||
assertEquals(declarator.getParms().getDeclarations().size(), 1);
|
||||
ParameterDeclaration declaration2 = (ParameterDeclaration)declarator.getParms().getDeclarations().get(0);
|
||||
assertEquals(declaration2.getDeclarators().size(), 1);
|
||||
Declarator declarator2 = (Declarator)declaration2.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", declarator2.getName() == null );
|
||||
}
|
||||
|
||||
public void testBug39551B() throws Exception {
|
||||
TranslationUnit tu = parse("_Imaginary double id = 99.99 * __I__;");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
String s = declaration.getDeclSpecifier().getTypeName();
|
||||
assertFalse("The expected error did not occur.", !declaration.getDeclSpecifier().getTypeName().equals("double") );
|
||||
}
|
||||
|
||||
public void testBug39552A() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("%:define glue(x, y) x %:%: y /* #define glue(x, y) x ## y. */\n");
|
||||
code.write("#ifndef glue\n");
|
||||
code.write("#error glue not defined!\n");
|
||||
code.write("#endif\n");
|
||||
code.write("%:define str(x) %:x /* #define str(x) #x */\n");
|
||||
|
||||
code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
|
||||
code.write("glue (<, %) /* { */\n");
|
||||
code.write(" /* di_str[] = */\n");
|
||||
code.write(" const char di_str glue(<, :)glue(:, >) = str(%:%:<::><%%>%:);\n");
|
||||
|
||||
code.write(" /* Check the glue macro actually pastes, and that the spelling of\n");
|
||||
code.write(" all digraphs is preserved. */\n");
|
||||
code.write(" if (glue(str, cmp) (di_str, \"%:%:<::><%%>%:\"))\n");
|
||||
code.write(" err (\"Digraph spelling not preserved!\");\n");
|
||||
|
||||
code.write(" return 0;\n");
|
||||
code.write("glue (%, >) /* } */\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
failTest(code.toString());
|
||||
}
|
||||
|
||||
public void testBug39552B() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("??=include <stdio.h>\n");
|
||||
|
||||
code.write("??=define TWELVE 1??/\n");
|
||||
code.write("2\n");
|
||||
|
||||
code.write("static const char str??(??) = \"0123456789??/n\";\n");
|
||||
|
||||
code.write("int\n");
|
||||
code.write("main(void)\n");
|
||||
code.write("??<\n");
|
||||
code.write(" unsigned char x = 5;\n");
|
||||
|
||||
code.write(" if (sizeof str != TWELVE)\n");
|
||||
code.write(" abort ();\n");
|
||||
|
||||
code.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
|
||||
code.write(" x ??'= 3;\n");
|
||||
code.write(" if (x != 6)\n");
|
||||
code.write(" abort ();\n");
|
||||
|
||||
code.write(" if ((5 ??! 3) != 7)\n");
|
||||
code.write(" abort ();\n");
|
||||
|
||||
code.write(" return 0;\n");
|
||||
code.write("??>\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
failTest(code.toString());
|
||||
}
|
||||
|
||||
public void testBug39553() throws Exception {
|
||||
TranslationUnit tu = parse(
|
||||
"#define COMP_INC \"foobar.h\" \n" +
|
||||
"#include COMP_INC");
|
||||
assertFalse("The expected error did not occur.", tu.getInclusions().size() == 1 );
|
||||
}
|
||||
|
||||
public void testBug39554() throws Exception {
|
||||
failTest("_Pragma(\"foobar\")");
|
||||
}
|
||||
|
||||
public void testBug39556() throws Exception {
|
||||
TranslationUnit tu = parse("int *restrict ip_fn (void);");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(declaration.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", declarator.getPointerOperators().size() == 1 );
|
||||
}
|
||||
|
||||
// Here C99-specific section ends
|
||||
|
||||
// Here GCC-specific section starts
|
||||
|
||||
public void testBug39676() throws Exception {
|
||||
failTest("struct { int e1, e2; } v = { e2: 0 }");
|
||||
}
|
||||
|
||||
public void testBug39677() throws Exception {
|
||||
failTest("B::B() : a(({ 1; })) {}");
|
||||
}
|
||||
|
||||
public void testBug39678() throws Exception {
|
||||
failTest("char *s = L\"a\" \"b\";");
|
||||
}
|
||||
|
||||
public void testBug39679() throws Exception {
|
||||
failTest("Foo blat() return f(4) {}");
|
||||
}
|
||||
|
||||
public void testBug39681() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("double\n");
|
||||
code.write("foo (double a, double b)\n");
|
||||
code.write("{\n");
|
||||
code.write(" double square (double z) { return z * z; }\n");
|
||||
|
||||
code.write(" return square (a) + square (b);\n");
|
||||
code.write("}\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
TranslationUnit tu = parse(code.toString());
|
||||
// Internal structure for functions is not supported, so actual test
|
||||
// needs to be added later
|
||||
}
|
||||
|
||||
public void testBug39682() throws Exception {
|
||||
TranslationUnit tu = parse("typedef name = (a+1);");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(declaration.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", declarator.getName() != null );
|
||||
}
|
||||
|
||||
public void testBug39684() throws Exception {
|
||||
failTest("typeof(foo(1)) bar () { return foo(1); }");
|
||||
}
|
||||
|
||||
public void testBug39686() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("__complex__ double x; // complex double\n");
|
||||
code.write("__complex__ short int a; // complex short int\n");
|
||||
code.write("x = 2.5fi; // 2.5 imaginary float literal\n");
|
||||
code.write("a = 3i; // imaginary integer literal\n");
|
||||
code.write("double v = __real__ x; // real part of expression\n");
|
||||
code.write("double w = __imag__ x; // imaginary part of expression\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
failTest(code.toString());
|
||||
}
|
||||
|
||||
public void testBug39687() throws Exception {
|
||||
failTest("struct entry tester (int len; char data[len][len], int len) {}");
|
||||
}
|
||||
|
||||
public void testBug39688() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("#define decl(type, vars...) \\\n");
|
||||
code.write(" type vars ;\n");
|
||||
|
||||
code.write("decl(int, x, y)\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
TranslationUnit tu = parse(code.toString());
|
||||
assertFalse("The expected error did not occur.", tu.getDeclarations().size() == 1 );
|
||||
}
|
||||
|
||||
public void testBug39694() throws Exception {
|
||||
TranslationUnit tu = parse("int ab$cd = 1;");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(declaration.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", declarator.getName().equals("ab$cd") );
|
||||
}
|
||||
|
||||
public void testBug39695() throws Exception {
|
||||
failTest("int a = __alignof__ (int);");
|
||||
}
|
||||
|
||||
public void testBug39695A() throws Exception {
|
||||
failTest("int foo asm (\"myfoo\") = 2;");
|
||||
}
|
||||
|
||||
public void testBug39695B() throws Exception {
|
||||
failTest("extern func () asm (\"FUNC\");");
|
||||
}
|
||||
|
||||
public void testBug39695C() throws Exception {
|
||||
failTest("register int *foo asm (\"a5\");");
|
||||
}
|
||||
|
||||
public void testBug39698A() throws Exception {
|
||||
TranslationUnit tu = parse("int c = a <? b;");
|
||||
|
||||
assertFalse("The expected error did not occur.", tu.getDeclarations().size() == 1 );
|
||||
}
|
||||
|
||||
public void testBug39698B() throws Exception {
|
||||
failTest("int c = a >? b;");
|
||||
}
|
||||
|
||||
public void testBug39701A() throws Exception {
|
||||
failTest("extern template int max (int, int);");
|
||||
}
|
||||
|
||||
public void testBug39701B() throws Exception {
|
||||
failTest("inline template class Foo<int>;");
|
||||
}
|
||||
|
||||
public void testBug39701C() throws Exception {
|
||||
failTest("static template class Foo<int>;");
|
||||
}
|
||||
|
||||
public void testBug39702() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("signature T {\n");
|
||||
code.write(" int f (int);\n");
|
||||
code.write(" int f0 () { return f (0); };\n");
|
||||
code.write("};\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
TranslationUnit tu = parse(code.toString());
|
||||
assertFalse("The expected error did not occur.", tu.getDeclarations().size() == 1 );
|
||||
}
|
||||
|
||||
public void testBug39703() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
try {
|
||||
code.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n");
|
||||
code.write("__extension__ struct G {\n");
|
||||
code.write(" struct { char z; };\n");
|
||||
code.write(" char g;\n");
|
||||
code.write("};\n");
|
||||
} catch( IOException ioe ){}
|
||||
|
||||
TranslationUnit tu = parse(code.toString());
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertFalse("The expected error did not occur.", declaration.getDeclSpecifier().getName() == null );
|
||||
}
|
||||
|
||||
public void testBug39704A() throws Exception {
|
||||
failTest("__declspec (dllimport) int foo;");
|
||||
}
|
||||
|
||||
public void testBug39704B() throws Exception {
|
||||
TranslationUnit tu = parse("extern int (* import) (void) __attribute__((dllimport));");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(declaration.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", !declarator.getName().toString().equals("__attribute__"));
|
||||
}
|
||||
|
||||
public void testBug39704C() throws Exception {
|
||||
TranslationUnit tu = parse("int func2 (void) __attribute__((dllexport));");
|
||||
|
||||
assertEquals(tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals(declaration.getDeclarators().size(), 1);
|
||||
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
|
||||
assertFalse("The expected error did not occur.", !declarator.getName().toString().equals("__attribute__"));
|
||||
}
|
||||
|
||||
public void testBug39704D() throws Exception {
|
||||
failTest("__declspec(dllexport) int func1 (int a) {}");
|
||||
}
|
||||
|
||||
public void testBug39705() throws Exception {
|
||||
failTest("#ident \"@(#)filename.c 1.3 90/02/12\"");
|
||||
}
|
||||
|
||||
// Here GCC-specific section ends
|
||||
|
||||
public void testBug40007() throws Exception {
|
||||
parse("int y = #;");
|
||||
}
|
||||
}
|
|
@ -14,18 +14,18 @@ import java.io.IOException;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.cdt.core.parser.tests.BaseDOMTest;
|
||||
import org.eclipse.cdt.core.parser.tests.BaseASTTest;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class LokiFailures extends BaseDOMTest {
|
||||
public class LokiFailures extends BaseASTTest {
|
||||
|
||||
public LokiFailures(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBugTypeManip151()
|
||||
public void testBug40419()
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
try
|
||||
|
@ -34,7 +34,7 @@ public class LokiFailures extends BaseDOMTest {
|
|||
code.write( "enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n" );
|
||||
code.write( "!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };" );
|
||||
} catch( IOException ioe ){}
|
||||
failTest( code.toString() );
|
||||
assertCodeFailsParse( code.toString() );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ package org.eclipse.cdt.core.parser.failedTests;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.cdt.core.parser.tests.BaseDOMTest;
|
||||
import org.eclipse.cdt.core.parser.tests.BaseASTTest;
|
||||
|
||||
/**
|
||||
* @author hamer
|
||||
*/
|
||||
public class STLFailedTests extends BaseDOMTest {
|
||||
public class STLFailedTests extends BaseASTTest {
|
||||
|
||||
public STLFailedTests(String name) {
|
||||
super(name);
|
||||
|
@ -29,7 +29,7 @@ public class STLFailedTests extends BaseDOMTest {
|
|||
code.write("template <class _CharT> class char_traits\n");
|
||||
code.write(": public __char_traits_base<_CharT, _CharT>\n");
|
||||
code.write("{};\n");
|
||||
failTest(code.toString());
|
||||
assertCodeFailsParse(code.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import junit.framework.TestCase;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IQueryResult;
|
||||
|
|
|
@ -24,7 +24,7 @@ import junit.framework.Test;
|
|||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParserCallback;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ public abstract class AutomatedFramework extends TestCase {
|
|||
return suite;
|
||||
}
|
||||
|
||||
protected static IParserCallback nullCallback = new NullSourceElementRequestor();
|
||||
protected static ISourceElementRequestor nullCallback = new NullSourceElementRequestor();
|
||||
protected static Properties properties = new Properties();
|
||||
protected static String defaultNature;
|
||||
protected static String outputFile = null;
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class BaseASTTest extends TestCase
|
||||
{
|
||||
public BaseASTTest( String a )
|
||||
{
|
||||
super( a );
|
||||
}
|
||||
|
||||
protected IQuickParseCallback quickParseCallback;
|
||||
protected IParser parser;
|
||||
protected IASTCompilationUnit parse( String code, boolean quick, boolean throwExceptionOnError ) throws ParserException
|
||||
{
|
||||
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
quickParseCallback = ParserFactory.createQuickParseCallback();
|
||||
parser = ParserFactory.createParser( ParserFactory.createScanner( new StringReader( code ), "code", new ScannerInfo(), mode), quickParseCallback, mode );
|
||||
if( ! parser.parse() && throwExceptionOnError )
|
||||
throw new ParserException("Parse failure");
|
||||
return quickParseCallback.getCompilationUnit();
|
||||
}
|
||||
|
||||
protected IASTCompilationUnit parse( String code )throws ParserException
|
||||
{
|
||||
return parse( code, true, true );
|
||||
}
|
||||
|
||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
||||
{
|
||||
Iterator declarationIter = parse( code ).getDeclarations();
|
||||
assertTrue( declarationIter.hasNext() );
|
||||
IASTDeclaration returnValue = (IASTDeclaration)declarationIter.next();
|
||||
assertFalse( declarationIter.hasNext() );
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public void assertCodeFailsParse(String code) {
|
||||
boolean testPassed = false;
|
||||
try {
|
||||
IASTCompilationUnit tu = parse(code);
|
||||
testPassed = true;
|
||||
fail( "We should not reach this point");
|
||||
} catch (Throwable e) {
|
||||
if (!(e instanceof ParserException))
|
||||
fail("Unexpected Error: " + e.getMessage());
|
||||
}
|
||||
if (testPassed)
|
||||
fail("The expected error did not occur.");
|
||||
}
|
||||
|
||||
protected void assertSimpleReturnType(IASTFunction function, IASTSimpleTypeSpecifier.Type type)
|
||||
{
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).getType(), type );
|
||||
}
|
||||
|
||||
protected void assertSimpleType(IASTVariable variable, IASTSimpleTypeSpecifier.Type type)
|
||||
{
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), type );
|
||||
}
|
||||
|
||||
protected void assertParameterSimpleType(IASTParameterDeclaration variable, IASTSimpleTypeSpecifier.Type type)
|
||||
{
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)variable.getTypeSpecifier()).getType(), type );
|
||||
}
|
||||
|
||||
protected void failedAsExpected()
|
||||
{
|
||||
assertFalse( "The expected error did not occur.", false );
|
||||
}
|
||||
|
||||
protected void assertNotReached()
|
||||
{
|
||||
fail( "We should not reach this point");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corp. - Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class BaseDOMTest extends TestCase {
|
||||
|
||||
public BaseDOMTest( String arg )
|
||||
{
|
||||
super( arg );
|
||||
}
|
||||
|
||||
public TranslationUnit parse( String code ) throws Exception
|
||||
{
|
||||
return parse( code, true, true );
|
||||
}
|
||||
|
||||
public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception {
|
||||
DOMBuilder domBuilder = new DOMBuilder();
|
||||
ParserMode mode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), mode ), domBuilder, mode );
|
||||
if( ! parser.parse() )
|
||||
if( throwOnError ) throw new ParserException( "Parse failure" );
|
||||
else domBuilder.getTranslationUnit().setParseSuccessful( false );
|
||||
|
||||
return domBuilder.getTranslationUnit();
|
||||
}
|
||||
|
||||
public void failTest(String code) {
|
||||
boolean testPassed = false;
|
||||
try {
|
||||
TranslationUnit tu = parse(code);
|
||||
testPassed = true;
|
||||
fail( "We should not reach this point");
|
||||
} catch (Throwable e) {
|
||||
if (!(e instanceof ParserException))
|
||||
fail("Unexpected Error: " + e.getMessage());
|
||||
}
|
||||
if (testPassed)
|
||||
fail("The expected error did not occur.");
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,7 @@ public class ExprEvalTest extends TestCase {
|
|||
public void runTest(String code, int expectedValue) throws Exception {
|
||||
|
||||
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, new ScannerInfo(), null ), new NullSourceElementRequestor(), ParserMode.QUICK_PARSE);
|
||||
IASTExpression expression = parser.expression(null);
|
||||
IASTExpression expression = parser.expression();
|
||||
assertEquals(expectedValue, expression.evaluateExpression());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Declaration;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ParserTestSuite extends TestCase {
|
|||
suite.addTestSuite(BranchTrackerTest.class);
|
||||
suite.addTestSuite(ScannerTestCase.class);
|
||||
suite.addTestSuite(ExprEvalTest.class);
|
||||
suite.addTestSuite(DOMTests.class);
|
||||
suite.addTestSuite(QuickParseASTTests.class);
|
||||
suite.addTestSuite(ParserSymbolTableTest.class);
|
||||
suite.addTestSuite(CModelElementsTests.class);
|
||||
suite.addTestSuite(MacroTests.class);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.search.ICSearchConstants;
|
|||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.internal.core.search.matching.ClassDeclarationPattern;
|
||||
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
|
||||
|
|
|
@ -5,18 +5,15 @@ package org.eclipse.cdt.core.search.tests;
|
|||
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
@ -31,10 +28,6 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* @author bgheorgh
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.model.tests.AllCoreTests;
|
|||
import org.eclipse.cdt.core.model.tests.BinaryTests;
|
||||
import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
||||
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
||||
import org.eclipse.cdt.core.parser.failedTests.DOMFailedTest;
|
||||
import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
|
||||
import org.eclipse.cdt.core.parser.failedTests.LokiFailures;
|
||||
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
|
||||
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
||||
|
@ -87,7 +87,7 @@ public class AutomatedIntegrationSuite extends TestSuite
|
|||
suite.addTest(suite.new GenerateReport("startFailedTests"));
|
||||
|
||||
// Add all failed tests
|
||||
suite.addTestSuite(DOMFailedTest.class);
|
||||
suite.addTestSuite(ASTFailedTests.class);
|
||||
suite.addTestSuite(LokiFailures.class);
|
||||
suite.addTestSuite(STLFailedTests.class);
|
||||
suite.addTestSuite(CModelElementsFailedTests.class);
|
||||
|
|
|
@ -16,23 +16,7 @@ package org.eclipse.cdt.internal.core.dom;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ArrayQualifier implements IExpressionOwner {
|
||||
|
||||
private Expression constantExpression;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||
*/
|
||||
public Expression getExpression() {
|
||||
return constantExpression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||
*/
|
||||
public void setExpression(Expression exp) {
|
||||
constantExpression = exp;
|
||||
}
|
||||
public class ArrayQualifier {
|
||||
|
||||
public ArrayQualifier( Declarator owner )
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -40,7 +39,7 @@ public class BaseSpecifier {
|
|||
public void setAccess(int access) { this.access.setAccess(access); }
|
||||
public int getAccess() { return access.getAccess(); }
|
||||
|
||||
private Name name;
|
||||
public void setName(Name name) { this.name = name; }
|
||||
public Name getName() { return name; }
|
||||
private String name;
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getName() { return name; }
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.core.dom;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class BitField implements IExpressionOwner {
|
||||
public class BitField {
|
||||
|
||||
|
||||
public BitField( Declarator owner )
|
||||
|
@ -22,21 +22,7 @@ public class BitField implements IExpressionOwner {
|
|||
ownerDeclarator= owner;
|
||||
}
|
||||
private final Declarator ownerDeclarator;
|
||||
private Expression expression = null;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||
*/
|
||||
public Expression getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||
*/
|
||||
public void setExpression(Expression exp) {
|
||||
expression = exp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -4,27 +4,30 @@ import java.util.Collections;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable, IAccessable {
|
||||
|
||||
private AccessSpecifier access = new AccessSpecifier( AccessSpecifier.v_private );
|
||||
private String classKeyImage = null;
|
||||
private AccessSpecifier access = new AccessSpecifier( AccessSpecifier.v_private );
|
||||
private ClassKey key = new ClassKey();
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private int startingOffset = 0, totalLength = 0, nameOffset = 0;
|
||||
private int topLine = 0, bottomLine = 0;
|
||||
private IToken classKeyToken = null;
|
||||
|
||||
public int getClassKey() { return key.getClassKey(); }
|
||||
|
||||
public ClassSpecifier(int classKey, TypeSpecifier.IOwner declaration) {
|
||||
super(declaration);
|
||||
this.key.setClassKey(classKey);
|
||||
if( classKey == ClassKey.t_class )
|
||||
classKeyImage = "class";
|
||||
else if( classKey == ClassKey.t_struct )
|
||||
classKeyImage = "struct";
|
||||
else if( classKey == ClassKey.t_union )
|
||||
classKeyImage = "union";
|
||||
}
|
||||
|
||||
private Name name;
|
||||
public void setName(Name n) { name = n; }
|
||||
public Name getName() { return name; }
|
||||
private String name;
|
||||
public void setName(String n) { name = n; }
|
||||
public String getName() { return name; }
|
||||
|
||||
private List baseSpecifiers = new LinkedList();
|
||||
public void addBaseSpecifier(BaseSpecifier baseSpecifier) {
|
||||
|
@ -63,6 +66,10 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable
|
|||
return startingOffset;
|
||||
}
|
||||
|
||||
public int getClassKeyEndOffset()
|
||||
{
|
||||
return startingOffset + classKeyImage.length();
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -84,22 +91,6 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable
|
|||
totalLength = i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classKeyToken.
|
||||
* @return Token
|
||||
*/
|
||||
public IToken getClassKeyToken() {
|
||||
return classKeyToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the classKeyToken.
|
||||
* @param classKeyToken The classKeyToken to set
|
||||
*/
|
||||
public void setClassKeyToken(IToken classKeyToken) {
|
||||
this.classKeyToken = classKeyToken;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IOffsetable#setTopLine(int)
|
||||
*/
|
||||
|
@ -128,4 +119,28 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable
|
|||
return bottomLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getClassKeyImage()
|
||||
{
|
||||
return classKeyImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getNameOffset()
|
||||
{
|
||||
return nameOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
*/
|
||||
public void setNameOffset(int i)
|
||||
{
|
||||
nameOffset = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,16 +12,15 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ConstructorChainElement implements IExpressionOwner {
|
||||
public class ConstructorChainElement {
|
||||
|
||||
private Name name;
|
||||
private String name;
|
||||
private final ConstructorChain ownerChain;
|
||||
|
||||
ConstructorChainElement( ConstructorChain chain )
|
||||
|
@ -32,7 +31,7 @@ public class ConstructorChainElement implements IExpressionOwner {
|
|||
/**
|
||||
* @return Name
|
||||
*/
|
||||
public Name getName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -40,7 +39,7 @@ public class ConstructorChainElement implements IExpressionOwner {
|
|||
* Sets the name.
|
||||
* @param name The name to set
|
||||
*/
|
||||
public void setName(Name name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -53,21 +52,4 @@ public class ConstructorChainElement implements IExpressionOwner {
|
|||
}
|
||||
|
||||
|
||||
private Expression exp = null;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||
*/
|
||||
public Expression getExpression()
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||
*/
|
||||
public void setExpression(Expression exp)
|
||||
{
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,8 +2,6 @@ package org.eclipse.cdt.internal.core.dom;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -168,86 +166,7 @@ public class DeclSpecifier {
|
|||
public static final int t_double = 6;
|
||||
public static final int t_void = 7;
|
||||
|
||||
public void setType(IToken token) {
|
||||
switch (token.getType()) {
|
||||
case IToken.t_typename:
|
||||
setTypename(true);
|
||||
break;
|
||||
case IToken.t_auto :
|
||||
setAuto(true);
|
||||
break;
|
||||
case IToken.t_register :
|
||||
setRegister(true);
|
||||
break;
|
||||
case IToken.t_static :
|
||||
setStatic(true);
|
||||
break;
|
||||
case IToken.t_extern :
|
||||
setExtern(true);
|
||||
break;
|
||||
case IToken.t_mutable :
|
||||
setMutable(true);
|
||||
break;
|
||||
case IToken.t_inline :
|
||||
setInline(true);
|
||||
break;
|
||||
case IToken.t_virtual :
|
||||
setVirtual(true);
|
||||
break;
|
||||
case IToken.t_explicit :
|
||||
setExplicit(true);
|
||||
break;
|
||||
case IToken.t_typedef :
|
||||
setTypedef(true);
|
||||
break;
|
||||
case IToken.t_friend :
|
||||
setFriend(true);
|
||||
break;
|
||||
case IToken.t_const :
|
||||
setConst(true);
|
||||
break;
|
||||
case IToken.t_volatile :
|
||||
setVolatile(true);
|
||||
break;
|
||||
case IToken.t_char :
|
||||
setType(DeclSpecifier.t_char);
|
||||
break;
|
||||
case IToken.t_wchar_t :
|
||||
setType(DeclSpecifier.t_wchar_t);
|
||||
break;
|
||||
case IToken.t_bool :
|
||||
setType(DeclSpecifier.t_bool);
|
||||
break;
|
||||
case IToken.t_short :
|
||||
setShort(true);
|
||||
break;
|
||||
case IToken.t_int :
|
||||
setType(DeclSpecifier.t_int);
|
||||
break;
|
||||
case IToken.t_long :
|
||||
setLong(true);
|
||||
break;
|
||||
case IToken.t_signed :
|
||||
setUnsigned(false);
|
||||
break;
|
||||
case IToken.t_unsigned :
|
||||
setUnsigned(true);
|
||||
break;
|
||||
case IToken.t_float :
|
||||
setType(DeclSpecifier.t_float);
|
||||
break;
|
||||
case IToken.t_double :
|
||||
setType(DeclSpecifier.t_double);
|
||||
break;
|
||||
case IToken.t_void :
|
||||
setType(DeclSpecifier.t_void);
|
||||
break;
|
||||
case IToken.tIDENTIFIER :
|
||||
setType(DeclSpecifier.t_type);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setType(int t) {
|
||||
declSpecifierSeq = declSpecifierSeq & ~typeMask | t;
|
||||
|
@ -265,13 +184,13 @@ public class DeclSpecifier {
|
|||
|
||||
};
|
||||
|
||||
Name name = null;
|
||||
String name = null;
|
||||
|
||||
/**
|
||||
* Returns the name.
|
||||
* @return Name
|
||||
*/
|
||||
public Name getName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -279,7 +198,7 @@ public class DeclSpecifier {
|
|||
* Sets the name.
|
||||
* @param name The name to set
|
||||
*/
|
||||
public void setName(Name name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
|
||||
public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
||||
public class Declarator implements IDeclaratorOwner {
|
||||
|
||||
public Declarator(DeclSpecifier.IContainer declaration) {
|
||||
this.declaration = declaration;
|
||||
|
@ -23,6 +22,7 @@ public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
|||
|
||||
private final DeclSpecifier.IContainer declaration;
|
||||
private final IDeclaratorOwner ownerDeclarator;
|
||||
private int nameOffset;
|
||||
|
||||
/**
|
||||
* Returns the declaration.
|
||||
|
@ -40,13 +40,13 @@ public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
|||
|
||||
}
|
||||
|
||||
private Name name;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Returns the name.
|
||||
* @return Name
|
||||
*/
|
||||
public Name getName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
|||
* Sets the name.
|
||||
* @param name The name to set
|
||||
*/
|
||||
public void setName(Name name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -72,22 +72,6 @@ public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
|||
public ParameterDeclarationClause getParms() {
|
||||
return parms;
|
||||
}
|
||||
|
||||
private Expression initialExpression = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||
*/
|
||||
public Expression getExpression() {
|
||||
return initialExpression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||
*/
|
||||
public void setExpression(Expression exp) {
|
||||
initialExpression = exp;
|
||||
}
|
||||
|
||||
List pointerOperators = new ArrayList();
|
||||
List arrayQualifiers = new ArrayList();
|
||||
|
@ -226,4 +210,20 @@ public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
|||
bitField = field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getNameOffset()
|
||||
{
|
||||
return nameOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
*/
|
||||
public void setNameOffset(int i)
|
||||
{
|
||||
nameOffset = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -27,9 +26,9 @@ public class ElaboratedTypeSpecifier extends TypeSpecifier {
|
|||
this.classKey.setClassKey( classKey );
|
||||
}
|
||||
|
||||
private Name name;
|
||||
public void setName(Name n) { name = n; }
|
||||
public Name getName() { return name; }
|
||||
private String name;
|
||||
public void setName(String n) { name = n; }
|
||||
public String getName() { return name; }
|
||||
|
||||
private ClassSpecifier classSpec = null;
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -29,10 +26,11 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
|
|||
super(declaration);
|
||||
}
|
||||
|
||||
private Name name = null;
|
||||
private String name = null;
|
||||
private List enumeratorDefinitions = new ArrayList();
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private IToken startToken = null;
|
||||
private int nameOffset = 0;
|
||||
private String startImage = null;
|
||||
|
||||
public void addEnumeratorDefinition( EnumeratorDefinition def )
|
||||
{
|
||||
|
@ -50,7 +48,7 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
|
|||
/**
|
||||
* @return Name
|
||||
*/
|
||||
public Name getName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -58,7 +56,7 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
|
|||
* Sets the name.
|
||||
* @param name The name to set
|
||||
*/
|
||||
public void setName(Name name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -94,16 +92,16 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
|
|||
* Returns the startToken.
|
||||
* @return Token
|
||||
*/
|
||||
public IToken getStartToken() {
|
||||
return startToken;
|
||||
public String getStartImage() {
|
||||
return startImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the startToken.
|
||||
* @param startToken The startToken to set
|
||||
*/
|
||||
public void setStartToken(IToken startToken) {
|
||||
this.startToken = startToken;
|
||||
public void setStartImage(String startImage) {
|
||||
this.startImage= startImage;
|
||||
}
|
||||
|
||||
private int topLine = 0, bottomLine = 0;
|
||||
|
@ -138,4 +136,20 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
|
|||
return bottomLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getNameOffset()
|
||||
{
|
||||
return nameOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
*/
|
||||
public void setNameOffset(int i)
|
||||
{
|
||||
nameOffset = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,37 +12,21 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class EnumeratorDefinition implements IExpressionOwner, IOffsetable {
|
||||
public class EnumeratorDefinition implements IOffsetable {
|
||||
|
||||
private Expression initialValue = null;
|
||||
private Name name = null;
|
||||
private String name = null;
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||
*/
|
||||
public Expression getExpression() {
|
||||
return initialValue;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||
*/
|
||||
public void setExpression(Expression exp) {
|
||||
initialValue = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name
|
||||
*/
|
||||
public Name getName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -50,7 +34,7 @@ public class EnumeratorDefinition implements IExpressionOwner, IOffsetable {
|
|||
* Sets the name.
|
||||
* @param name The name to set
|
||||
*/
|
||||
public void setName(Name name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ import java.util.Collections;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -35,7 +33,7 @@ public class ExceptionSpecifier {
|
|||
return Collections.unmodifiableList( typeNames );
|
||||
}
|
||||
|
||||
public void addTypeName( Name name )
|
||||
public void addTypeName( String name )
|
||||
{
|
||||
typeNames.add( name );
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors: John Camelon
|
||||
* Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class Expression {
|
||||
|
||||
private List tokens = new ArrayList();
|
||||
|
||||
public void add( IToken t )
|
||||
{
|
||||
tokens.add( t );
|
||||
}
|
||||
|
||||
public void add( Name t )
|
||||
{
|
||||
tokens.add( t );
|
||||
}
|
||||
|
||||
public List elements()
|
||||
{
|
||||
return Collections.unmodifiableList( tokens );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.parser.Token;
|
||||
|
||||
|
||||
/**
|
||||
* @author dschaefe
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class Name {
|
||||
|
||||
private Token nameStart, nameEnd;
|
||||
|
||||
public Name(Token nameStart) {
|
||||
this.nameStart = nameStart;
|
||||
}
|
||||
|
||||
public void setEnd(Token nameEnd) {
|
||||
this.nameEnd = nameEnd;
|
||||
}
|
||||
|
||||
public int getStartOffset()
|
||||
{
|
||||
return nameStart.getOffset();
|
||||
}
|
||||
|
||||
public int getEndOffset()
|
||||
{
|
||||
return nameEnd.getOffset();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
IToken t = nameStart;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( t.getImage() );
|
||||
if( t.getType() == IToken.t_operator )
|
||||
buffer.append( " " );
|
||||
|
||||
while (t != nameEnd) {
|
||||
t = t.getNext();
|
||||
|
||||
buffer.append( t.getImage() );
|
||||
if (t.getType() == IToken.t_operator) buffer.append( " " );
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public int length()
|
||||
{
|
||||
return getEndOffset() - getStartOffset() + nameEnd.getLength();
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IToken getNameStart() {
|
||||
return nameStart;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,8 +12,6 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -89,12 +87,12 @@ public class PointerOperator {
|
|||
|
||||
|
||||
// This is not a complete name, it is something like A::B::, i.e. ends with ::
|
||||
private Name nameSpecifier = null;
|
||||
private String nameSpecifier = null;
|
||||
|
||||
/**
|
||||
* @return Class name specifier for pointers to members
|
||||
*/
|
||||
public Name getNameSpecifier() {
|
||||
public String getNameSpecifier() {
|
||||
return nameSpecifier;
|
||||
}
|
||||
|
||||
|
@ -102,7 +100,7 @@ public class PointerOperator {
|
|||
* Sets the class name specifier for pointers to members.
|
||||
* @param name The name specifier to set
|
||||
*/
|
||||
public void setNameSpecifier(Name name) {
|
||||
public void setNameSpecifier(String name) {
|
||||
this.nameSpecifier = name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public class SimpleDeclaration extends Declaration implements DeclSpecifier.ICon
|
|||
private AccessSpecifier accessSpecifier = null;
|
||||
private DeclSpecifier declSpec = null;
|
||||
private boolean isFunctionDefinition = false;
|
||||
private int nameOffset;
|
||||
|
||||
|
||||
public SimpleDeclaration(IScope owner )
|
||||
|
@ -84,4 +85,20 @@ public class SimpleDeclaration extends Declaration implements DeclSpecifier.ICon
|
|||
public void setFunctionDefinition(boolean b) {
|
||||
isFunctionDefinition = b;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getNameOffset()
|
||||
{
|
||||
return nameOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
*/
|
||||
public void setNameOffset(int i)
|
||||
{
|
||||
nameOffset = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.parser.Token;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -27,15 +24,14 @@ public class TemplateDeclaration extends Declaration implements IScope, IAccessa
|
|||
|
||||
private final boolean exported;
|
||||
private AccessSpecifier visibility = null;
|
||||
private IToken firstToken, lastToken;
|
||||
|
||||
private List declarations = new ArrayList();
|
||||
private TemplateParameterList templateParms = null;
|
||||
|
||||
public TemplateDeclaration( IScope ownerScope, IToken exported )
|
||||
public TemplateDeclaration( IScope ownerScope, boolean exported )
|
||||
{
|
||||
super( ownerScope );
|
||||
this.firstToken = exported;
|
||||
this.exported = exported.getType() == IToken.t_export ? true : false;
|
||||
this.exported = exported;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -73,34 +69,19 @@ public class TemplateDeclaration extends Declaration implements IScope, IAccessa
|
|||
templateParms = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IToken getFirstToken() {
|
||||
return firstToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @param token
|
||||
*/
|
||||
public IToken getLastToken() {
|
||||
return lastToken;
|
||||
public void setFirstOffset(int startingOffset) {
|
||||
setStartingOffset( startingOffset );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param token
|
||||
*/
|
||||
public void setFirstToken(Token token) {
|
||||
firstToken = token;
|
||||
setStartingOffset( getFirstToken().getOffset() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param token
|
||||
*/
|
||||
public void setLastToken(IToken token) {
|
||||
lastToken = token;
|
||||
setTotalLength( getLastToken().getOffset() + getLastToken().getLength() - getStartingOffset() );
|
||||
public void setLastOffset(int lastOffset) {
|
||||
setTotalLength( lastOffset - getStartingOffset() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -34,8 +33,8 @@ public class TemplateParameter extends Declaration implements ITemplateParameter
|
|||
this.kind = kind;
|
||||
}
|
||||
|
||||
private Name name = null;
|
||||
private Name typeId = null;
|
||||
private String name = null;
|
||||
private String typeId = null;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -48,14 +47,14 @@ public class TemplateParameter extends Declaration implements ITemplateParameter
|
|||
/**
|
||||
* @return Name
|
||||
*/
|
||||
public Name getName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name
|
||||
*/
|
||||
public Name getTypeId() {
|
||||
public String getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class TemplateParameter extends Declaration implements ITemplateParameter
|
|||
* Sets the name.
|
||||
* @param name The name to set
|
||||
*/
|
||||
public void setName(Name name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ public class TemplateParameter extends Declaration implements ITemplateParameter
|
|||
* Sets the typeId.
|
||||
* @param typeId The typeId to set
|
||||
*/
|
||||
public void setTypeId(Name typeId) {
|
||||
public void setTypeId(String typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ package org.eclipse.cdt.internal.core.search.indexing;
|
|||
*/
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IParserCallback;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
|
@ -33,10 +33,12 @@ import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedef;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
|
@ -48,7 +50,7 @@ import org.eclipse.cdt.internal.core.index.IDocument;
|
|||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SourceIndexerRequestor implements IParserCallback,ISourceElementRequestor, IIndexConstants {
|
||||
public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexConstants {
|
||||
|
||||
SourceIndexer indexer;
|
||||
IDocument document;
|
||||
|
@ -122,7 +124,7 @@ public class SourceIndexerRequestor implements IParserCallback,ISourceElementReq
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
|
||||
*/
|
||||
public void acceptTypedef(IASTTypedef typedef) {
|
||||
public void acceptTypedef(IASTTypedefDeclaration typedef) {
|
||||
// TODO Auto-generated method stub
|
||||
//System.out.println("acceptTypedef");
|
||||
}
|
||||
|
@ -1050,6 +1052,30 @@ public class SourceIndexerRequestor implements IParserCallback,ISourceElementReq
|
|||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptAbstractTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration)
|
||||
*/
|
||||
public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTPointerToFunction)
|
||||
*/
|
||||
public void acceptPointerToFunction(IASTPointerToFunction function)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod)
|
||||
*/
|
||||
public void acceptPointerToMethod(IASTPointerToMethod method)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
//TODO: Get rid of these IParserCallbacks once the parser cleans up
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
|||
import org.eclipse.cdt.internal.core.dom.TemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.Name;
|
||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
|
@ -341,12 +340,12 @@ public class CModelBuilder {
|
|||
}
|
||||
// set enumeration position
|
||||
if(enumSpecifier.getName() != null ){
|
||||
element.setIdPos(enumSpecifier.getName().getStartOffset(), enumSpecifier.getName().length());
|
||||
element.setIdPos(enumSpecifier.getStartingOffset(), enumSpecifier.getName().length());
|
||||
}else {
|
||||
element.setIdPos(enumSpecifier.getStartToken().getOffset(), enumSpecifier.getStartToken().getLength());
|
||||
element.setIdPos(enumSpecifier.getStartingOffset(), enumSpecifier.getStartImage().length());
|
||||
}
|
||||
element.setPos(enumSpecifier.getStartingOffset(), enumSpecifier.getTotalLength());
|
||||
element.setTypeName(enumSpecifier.getStartToken().getImage());
|
||||
element.setTypeName(enumSpecifier.getStartImage());
|
||||
// set the element lines
|
||||
element.setLines(enumSpecifier.getTopLine(), enumSpecifier.getBottomLine());
|
||||
|
||||
|
@ -359,7 +358,7 @@ public class CModelBuilder {
|
|||
// add to parent
|
||||
enum.addChild(element);
|
||||
// set enumerator position
|
||||
element.setIdPos(enumDef.getName().getStartOffset(), enumDef.getName().length());
|
||||
element.setIdPos(enumDef.getStartingOffset(), enumDef.getName().length());
|
||||
element.setPos(enumDef.getStartingOffset(), enumDef.getTotalLength());
|
||||
// set the element lines
|
||||
element.setLines(enumDef.getTopLine(), enumDef.getBottomLine());
|
||||
|
@ -411,12 +410,12 @@ public class CModelBuilder {
|
|||
if( classSpecifier.getName() != null )
|
||||
{
|
||||
type = simpleDeclaration.getDeclSpecifier().getTypeName();
|
||||
element.setIdPos( classSpecifier.getName().getStartOffset(), classSpecifier.getName().length() );
|
||||
element.setIdPos( classSpecifier.getNameOffset(), classSpecifier.getName().length() );
|
||||
}
|
||||
else
|
||||
{
|
||||
type = classSpecifier.getClassKeyToken().getImage();
|
||||
element.setIdPos(classSpecifier.getClassKeyToken().getOffset(), classSpecifier.getClassKeyToken().getLength());
|
||||
type = classSpecifier.getClassKeyImage();
|
||||
element.setIdPos(classSpecifier.getStartingOffset(), classSpecifier.getClassKeyImage().length());
|
||||
|
||||
}
|
||||
element.setTypeName( type );
|
||||
|
@ -433,7 +432,7 @@ public class CModelBuilder {
|
|||
|
||||
protected TypeDef createTypeDef(Parent parent, Declarator declarator, SimpleDeclaration simpleDeclaration){
|
||||
// create the element
|
||||
Name domName = getDOMName(declarator);
|
||||
String domName = getDOMName(declarator);
|
||||
if (domName == null) {
|
||||
// Something is wrong, skip this element
|
||||
return null;
|
||||
|
@ -450,7 +449,7 @@ public class CModelBuilder {
|
|||
parent.addChild((CElement)element);
|
||||
|
||||
// set positions
|
||||
element.setIdPos(domName.getStartOffset(), domName.length());
|
||||
element.setIdPos(declarator.getNameOffset(), domName.length());
|
||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||
// set the element lines
|
||||
element.setLines(simpleDeclaration.getTopLine(), simpleDeclaration.getBottomLine());
|
||||
|
@ -461,7 +460,7 @@ public class CModelBuilder {
|
|||
|
||||
protected VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, boolean isTemplate)
|
||||
{
|
||||
Name domName = getDOMName(declarator);
|
||||
String domName = getDOMName(declarator);
|
||||
if (domName == null) {
|
||||
// TODO : improve errorhandling
|
||||
// When parsing syntactically incorrect code, we might
|
||||
|
@ -516,7 +515,7 @@ public class CModelBuilder {
|
|||
parent.addChild( element );
|
||||
|
||||
// set position
|
||||
element.setIdPos( domName.getStartOffset(), domName.length() );
|
||||
element.setIdPos( declarator.getNameOffset(), domName.length() );
|
||||
if(!isTemplate){
|
||||
// set element position
|
||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||
|
@ -530,7 +529,7 @@ public class CModelBuilder {
|
|||
|
||||
protected FunctionDeclaration createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, boolean isTemplate)
|
||||
{
|
||||
Name domName = getDOMName(declarator);
|
||||
String domName = getDOMName(declarator);
|
||||
if (domName == null) {
|
||||
// Something is wrong, skip this element
|
||||
return null;
|
||||
|
@ -614,7 +613,7 @@ public class CModelBuilder {
|
|||
parent.addChild( element );
|
||||
|
||||
// hook up the offsets
|
||||
element.setIdPos( domName.getStartOffset(), domName.length() );
|
||||
element.setIdPos( declarator.getNameOffset(), domName.length() );
|
||||
if(!isTemplate){
|
||||
// set the element position
|
||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||
|
@ -986,7 +985,7 @@ public class CModelBuilder {
|
|||
while (d.hasNext()) {
|
||||
Declarator decl = (Declarator) d.next();
|
||||
|
||||
Name oldKRparamName = getDOMName(decl);
|
||||
String oldKRparamName = getDOMName(decl);
|
||||
String oldKRparamType = getType(declKR, decl);
|
||||
|
||||
if ( (oldKRparamType != null)
|
||||
|
@ -1028,10 +1027,10 @@ public class CModelBuilder {
|
|||
return getParametersString(getParameterTypes(declarator));
|
||||
}
|
||||
|
||||
private Name getDOMName(Declarator declarator)
|
||||
private String getDOMName(Declarator declarator)
|
||||
{
|
||||
Declarator currentDeclarator = declarator;
|
||||
Name name = null;
|
||||
String name = null;
|
||||
|
||||
if (currentDeclarator != null) {
|
||||
while (currentDeclarator.getDeclarator() != null) {
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2003-07-17 John Camelon
|
||||
Removed IParserCallback.
|
||||
Partially converted DOM to ISourceElementRequestor (requires refactoring of CModelBuilder & StuctureComparator modules in near future).
|
||||
Completely finished ISourceElementRequestor/IASTFactory work for QuickParse mode.
|
||||
Added pointer to methods/functions into AST callback structure.
|
||||
Restructured AST class hierarchy.
|
||||
Removed the old IParserCallback return Objects from every Parser method.
|
||||
|
||||
2003-07-15 Victor Mozgin
|
||||
Fixed PR 39349 : Scanner fails on long long literals.
|
||||
Fixed PR 39544 : Scanner fails on wide char literals.
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface IParser {
|
|||
* @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid
|
||||
* expression
|
||||
*/
|
||||
public IASTExpression expression(Object expression) throws Backtrack;
|
||||
public IASTExpression expression() throws Backtrack;
|
||||
|
||||
/**
|
||||
* Is the parser configured for ANSI C or ANSI C++?
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001 Rational Software Corp. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
|
||||
public interface IParserCallback {
|
||||
|
||||
public void setParser( IParser parser );
|
||||
|
||||
public Object translationUnitBegin();
|
||||
public void translationUnitEnd(Object unit);
|
||||
|
||||
public Object inclusionBegin(String includeFile, int nameBeginOffset, int inclusionBeginOffset, boolean local);
|
||||
public void inclusionEnd(Object inclusion);
|
||||
public Object macro(String macroName, int macroNameOffset, int macroBeginOffset, int macroEndOffset);
|
||||
|
||||
public Object simpleDeclarationBegin(Object Container, IToken firstToken);
|
||||
public void simpleDeclSpecifier(Object Container, IToken specifier);
|
||||
public void simpleDeclSpecifierName( Object declaration );
|
||||
public void simpleDeclSpecifierType( Object declaration, Object type );
|
||||
public void simpleDeclarationEnd(Object declaration, IToken lastToken);
|
||||
|
||||
public Object parameterDeclarationBegin( Object Container );
|
||||
public void parameterDeclarationEnd( Object declaration );
|
||||
|
||||
public void nameBegin(IToken firstToken);
|
||||
public void nameEnd(IToken lastToken);
|
||||
|
||||
public Object declaratorBegin(Object container);
|
||||
public void declaratorId(Object declarator);
|
||||
public void declaratorAbort( Object declarator );
|
||||
public void declaratorPureVirtual( Object declarator );
|
||||
public void declaratorCVModifier( Object declarator, IToken modifier );
|
||||
public void declaratorThrowsException( Object declarator );
|
||||
public void declaratorThrowExceptionName( Object declarator );
|
||||
public void declaratorEnd(Object declarator);
|
||||
|
||||
public Object arrayDeclaratorBegin( Object declarator );
|
||||
public void arrayDeclaratorEnd( Object arrayQualifier );
|
||||
|
||||
public Object pointerOperatorBegin( Object container );
|
||||
public void pointerOperatorType( Object ptrOperator, IToken type );
|
||||
public void pointerOperatorName( Object ptrOperator );
|
||||
public void pointerOperatorCVModifier( Object ptrOperator, IToken modifier );
|
||||
public void pointerOperatorAbort( Object ptrOperator );
|
||||
public void pointerOperatorEnd( Object ptrOperator );
|
||||
|
||||
public Object argumentsBegin( Object declarator );
|
||||
public void argumentsEnd(Object parameterDeclarationClause);
|
||||
|
||||
public Object oldKRParametersBegin( Object parameterDeclarationClause );
|
||||
public void oldKRParametersEnd(Object oldKRParameterDeclarationClause);
|
||||
|
||||
public Object functionBodyBegin(Object declaration);
|
||||
public void functionBodyEnd(Object functionBody);
|
||||
|
||||
public Object classSpecifierBegin(Object container, IToken classKey);
|
||||
public void classSpecifierName(Object classSpecifier);
|
||||
public void classSpecifierAbort( Object classSpecifier );
|
||||
public void classMemberVisibility( Object classSpecifier, IToken visibility );
|
||||
public void classSpecifierEnd(Object classSpecifier, IToken closingBrace );
|
||||
|
||||
public Object baseSpecifierBegin( Object containingClassSpec );
|
||||
public void baseSpecifierName( Object baseSpecifier );
|
||||
public void baseSpecifierVisibility( Object baseSpecifier, IToken visibility );
|
||||
public void baseSpecifierVirtual( Object baseSpecifier, boolean virtual );
|
||||
public void baseSpecifierEnd( Object baseSpecifier );
|
||||
|
||||
public Object expressionBegin( Object container );
|
||||
public void expressionOperator(Object expression, IToken operator);
|
||||
public void expressionTerminal(Object expression, IToken terminal);
|
||||
public void expressionName( Object expression );
|
||||
public void expressionAbort( Object expression );
|
||||
public void expressionEnd(Object expression );
|
||||
|
||||
public Object elaboratedTypeSpecifierBegin( Object container, IToken classKey );
|
||||
public void elaboratedTypeSpecifierName( Object elab );
|
||||
public void elaboratedTypeSpecifierEnd( Object elab );
|
||||
|
||||
public Object namespaceDefinitionBegin( Object container, IToken namespace );
|
||||
public void namespaceDefinitionId( Object namespace );
|
||||
public void namespaceDefinitionAbort( Object namespace );
|
||||
public void namespaceDefinitionEnd( Object namespace, IToken closingBrace );
|
||||
|
||||
public Object linkageSpecificationBegin( Object container, String literal );
|
||||
public void linkageSpecificationEnd( Object linkageSpec );
|
||||
|
||||
public Object usingDirectiveBegin( Object container );
|
||||
public void usingDirectiveNamespaceId( Object directive );
|
||||
public void usingDirectiveAbort( Object directive );
|
||||
public void usingDirectiveEnd( Object directive );
|
||||
|
||||
public Object usingDeclarationBegin( Object container );
|
||||
public void usingDeclarationMapping( Object declaration, boolean isTypeName );
|
||||
public void usingDeclarationAbort( Object declaration );
|
||||
public void usingDeclarationEnd( Object declaration );
|
||||
|
||||
public Object enumSpecifierBegin( Object container, IToken enumKey );
|
||||
public void enumSpecifierId( Object enumSpec );
|
||||
public void enumSpecifierAbort( Object enumSpec );
|
||||
public void enumSpecifierEnd( Object enumSpec, IToken closingBrace );
|
||||
|
||||
public Object enumeratorBegin( Object enumSpec );
|
||||
public void enumeratorId( Object enumDefn );
|
||||
public void enumeratorEnd( Object enumDefn, IToken lastToken );
|
||||
|
||||
public void asmDefinition( Object container, String assemblyCode );
|
||||
|
||||
public Object constructorChainBegin( Object declarator );
|
||||
public void constructorChainAbort( Object ctor );
|
||||
public void constructorChainEnd( Object ctor );
|
||||
|
||||
public Object constructorChainElementBegin( Object ctor );
|
||||
public void constructorChainElementId( Object element );
|
||||
public void constructorChainElementEnd( Object element );
|
||||
|
||||
public Object explicitInstantiationBegin( Object container);
|
||||
public void explicitInstantiationEnd( Object instantiation );
|
||||
|
||||
public Object explicitSpecializationBegin( Object container );
|
||||
public void explicitSpecializationEnd( Object instantiation );
|
||||
|
||||
public Object templateDeclarationBegin( Object container, IToken firstToken );
|
||||
public void templateDeclarationAbort( Object templateDecl );
|
||||
public void templateDeclarationEnd( Object templateDecl, IToken lastToken );
|
||||
|
||||
public Object templateParameterListBegin( Object declaration );
|
||||
public void templateParameterListEnd( Object parameterList );
|
||||
|
||||
public Object templateTypeParameterBegin( Object templDecl, IToken kind );
|
||||
public void templateTypeParameterName( Object typeParm );
|
||||
public void templateTypeParameterAbort( Object typeParm );
|
||||
public void templateTypeParameterInitialTypeId( Object typeParm );
|
||||
public void templateTypeParameterEnd( Object typeParm );
|
||||
|
||||
public Object startBitfield(Object declarator);
|
||||
public void endBitfield(Object bitfield);
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
import java.util.Iterator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IQuickParseCallback extends ISourceElementRequestor
|
||||
{
|
||||
public abstract Iterator getInclusions();
|
||||
public abstract Iterator getMacros();
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public abstract IASTCompilationUnit getCompilationUnit();
|
||||
public abstract Iterator iterateOffsetableElements();
|
||||
}
|
|
@ -27,7 +27,6 @@ public interface IScanner {
|
|||
public void setCppNature( boolean value );
|
||||
|
||||
public void setMode(ParserMode mode);
|
||||
public void setCallback(IParserCallback c);
|
||||
|
||||
public int getCount();
|
||||
public int getDepth();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
|
@ -23,10 +24,12 @@ import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedef;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
|
@ -45,8 +48,9 @@ public interface ISourceElementRequestor {
|
|||
public void acceptUsingDirective( IASTUsingDirective usageDirective );
|
||||
public void acceptUsingDeclaration( IASTUsingDeclaration usageDeclaration );
|
||||
public void acceptASMDefinition( IASTASMDefinition asmDefinition );
|
||||
public void acceptTypedef( IASTTypedef typedef );
|
||||
public void acceptTypedef( IASTTypedefDeclaration typedef );
|
||||
public void acceptEnumerationSpecifier( IASTEnumerationSpecifier enumeration );
|
||||
public void acceptAbstractTypeSpecDeclaration( IASTAbstractTypeSpecifierDeclaration abstractDeclaration );
|
||||
|
||||
public void enterFunctionBody( IASTFunction function );
|
||||
public void exitFunctionBody( IASTFunction function );
|
||||
|
@ -79,4 +83,14 @@ public interface ISourceElementRequestor {
|
|||
public void exitCompilationUnit( IASTCompilationUnit compilationUnit );
|
||||
|
||||
public void acceptElaboratedTypeSpecifier(IASTElaboratedTypeSpecifier elaboratedTypeSpec);
|
||||
|
||||
/**
|
||||
* @param function
|
||||
*/
|
||||
public void acceptPointerToFunction(IASTPointerToFunction function);
|
||||
|
||||
/**
|
||||
* @param method
|
||||
*/
|
||||
public void acceptPointerToMethod(IASTPointerToMethod method);
|
||||
}
|
||||
|
|
|
@ -28,4 +28,5 @@ public interface ITokenDuple {
|
|||
public abstract Iterator iterator();
|
||||
public abstract String toString();
|
||||
public abstract boolean isIdentifier();
|
||||
public abstract int length();
|
||||
}
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.internal.core.parser.LineOffsetReconciler;
|
|||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||
import org.eclipse.cdt.internal.core.parser.Preprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.QuickParseCallback;
|
||||
import org.eclipse.cdt.internal.core.parser.Scanner;
|
||||
import org.eclipse.cdt.internal.core.parser.TranslationOptions;
|
||||
import org.eclipse.cdt.internal.core.parser.TranslationResult;
|
||||
|
@ -42,15 +43,15 @@ public class ParserFactory {
|
|||
return new FullParseASTFactory();
|
||||
}
|
||||
|
||||
public static IParser createParser( IScanner scanner, IParserCallback callback, ParserMode mode )
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode )
|
||||
{
|
||||
return createParser(scanner, callback, mode, null, null);
|
||||
}
|
||||
|
||||
public static IParser createParser( IScanner scanner, IParserCallback callback, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, IProblemReporter problemReporter, ITranslationResult unitResult )
|
||||
{
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
IParserCallback ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||
ISourceElementRequestor ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||
return new Parser( scanner, ourCallback, ourMode, problemReporter, unitResult );
|
||||
}
|
||||
|
||||
|
@ -101,4 +102,9 @@ public class ParserFactory {
|
|||
{
|
||||
return new TranslationResult( fileName /* tu */ );
|
||||
}
|
||||
|
||||
public static IQuickParseCallback createQuickParseCallback()
|
||||
{
|
||||
return new QuickParseCallback();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParserMode {
|
||||
public class ParserMode extends Enum {
|
||||
|
||||
// follow inclusions, parse function/method bodies
|
||||
public static final ParserMode COMPLETE_PARSE = new ParserMode( 1 );
|
||||
|
@ -25,10 +25,9 @@ public class ParserMode {
|
|||
// do not follow inclusions, do not parse function/method bodies
|
||||
public static final ParserMode QUICK_PARSE = new ParserMode( 3 );
|
||||
|
||||
private ParserMode( int value )
|
||||
protected ParserMode( int value )
|
||||
{
|
||||
this.value = value;
|
||||
super( value );
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTNotImplementedException
|
||||
public class ASTNotImplementedException extends Exception
|
||||
{
|
||||
}
|
||||
|
|
|
@ -22,9 +22,6 @@ public class ASTPointerOperator extends Enum
|
|||
public static final ASTPointerOperator POINTER = new ASTPointerOperator( 1 );
|
||||
public static final ASTPointerOperator CONST_POINTER = new ASTPointerOperator( 2 );
|
||||
public static final ASTPointerOperator VOLATILE_POINTER = new ASTPointerOperator( 3 );
|
||||
public static final ASTPointerOperator POINTER_TO_FUNCTION = new ASTPointerOperator( 4 );
|
||||
public static final ASTPointerOperator CONST_POINTER_TO_FUNCTION = new ASTPointerOperator( 5 );
|
||||
public static final ASTPointerOperator VOLATILE_POINTER_TO_FUNCTION = new ASTPointerOperator( 6 );
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,12 +16,10 @@ import java.util.Iterator;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTAbstractDeclaration
|
||||
public interface IASTAbstractDeclaration extends IASTTypeSpecifierOwner
|
||||
{
|
||||
public boolean isConst();
|
||||
|
||||
public IASTTypeSpecifier getTypeSpecifier();
|
||||
|
||||
public Iterator getPointerOperators();
|
||||
|
||||
public Iterator getArrayModifiers();
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTAbstractTypeSpecifierDeclaration
|
||||
extends IASTDeclaration, IASTTypeSpecifierOwner, IASTTemplatedDeclaration, IASTOffsetableElement
|
||||
{
|
||||
}
|
|
@ -19,6 +19,7 @@ public interface IASTBaseSpecifier {
|
|||
|
||||
public ASTAccessVisibility getAccess();
|
||||
public boolean isVirtual();
|
||||
public IASTClassSpecifier getParent();
|
||||
public String getParentClassName();
|
||||
public IASTClassSpecifier getParentClassSpecifier() throws ASTNotImplementedException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.Enum;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration, IASTQualifiedNameElement {
|
||||
public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTScopedElement, IASTOffsetableNamedElement, IASTQualifiedNameElement {
|
||||
|
||||
public class ClassNameType extends Enum {
|
||||
|
||||
|
@ -30,7 +30,7 @@ public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTOf
|
|||
super( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ClassNameType getClassNameType();
|
||||
|
||||
public ASTClassKind getClassKind();
|
||||
|
@ -38,5 +38,6 @@ public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTOf
|
|||
public Iterator getBaseClauses();
|
||||
|
||||
public ASTAccessVisibility getCurrentVisibilityMode();
|
||||
public void setCurrentVisibility( ASTAccessVisibility visibility );
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTDeclaration {
|
||||
public interface IASTDeclaration extends IASTScopedElement {
|
||||
|
||||
IASTScope getOwnerScope();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
*/
|
||||
public interface IASTElaboratedTypeSpecifier extends IASTTypeSpecifier, IASTOffsetableElement {
|
||||
|
||||
public String getTypeName();
|
||||
public String getName();
|
||||
public ASTClassKind getClassKind();
|
||||
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ public interface IASTFactory
|
|||
int nameOffset);
|
||||
public IASTUsingDirective createUsingDirective(
|
||||
IASTScope scope,
|
||||
ITokenDuple duple)
|
||||
ITokenDuple duple, int startingOffset, int endingOffset)
|
||||
throws Backtrack;
|
||||
public IASTUsingDeclaration createUsingDeclaration(
|
||||
IASTScope scope,
|
||||
boolean isTypeName,
|
||||
ITokenDuple name);
|
||||
ITokenDuple name, int startingOffset, int endingOffset);
|
||||
public IASTASMDefinition createASMDefinition(
|
||||
IASTScope scope,
|
||||
String assembly,
|
||||
|
@ -55,7 +55,7 @@ public interface IASTFactory
|
|||
public IASTCompilationUnit createCompilationUnit();
|
||||
public IASTLinkageSpecification createLinkageSpecification(
|
||||
IASTScope scope,
|
||||
String spec);
|
||||
String spec, int startingOffset);
|
||||
public IASTClassSpecifier createClassSpecifier(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
|
@ -118,7 +118,7 @@ public interface IASTFactory
|
|||
ITokenDuple duple,
|
||||
IASTExpression expressionList);
|
||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
|
||||
IASTSimpleTypeSpecifier.SimpleType kind,
|
||||
IASTSimpleTypeSpecifier.Type kind,
|
||||
ITokenDuple typeName,
|
||||
boolean isShort,
|
||||
boolean isLong,
|
||||
|
@ -172,12 +172,47 @@ public interface IASTFactory
|
|||
|
||||
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset );
|
||||
|
||||
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParameterKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms );
|
||||
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms );
|
||||
|
||||
public IASTTemplateInstantiation createTemplateInstantiation(IASTScope scope, int startingOffset);
|
||||
|
||||
public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset);
|
||||
|
||||
public IASTTypedef createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset );
|
||||
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset );
|
||||
|
||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
|
||||
|
||||
public IASTPointerToFunction createPointerToFunction(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
List parameters,
|
||||
IASTAbstractDeclaration returnType,
|
||||
IASTExceptionSpecification exception,
|
||||
boolean isInline,
|
||||
boolean isFriend,
|
||||
boolean isStatic,
|
||||
int startOffset,
|
||||
int nameOffset,
|
||||
IASTTemplate ownerTemplate, ASTPointerOperator pointerOperator);
|
||||
|
||||
public IASTPointerToMethod createPointerToMethod(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
List parameters,
|
||||
IASTAbstractDeclaration returnType,
|
||||
IASTExceptionSpecification exception,
|
||||
boolean isInline,
|
||||
boolean isFriend,
|
||||
boolean isStatic,
|
||||
int startOffset,
|
||||
int nameOffset,
|
||||
IASTTemplate ownerTemplate,
|
||||
boolean isConst,
|
||||
boolean isVolatile,
|
||||
boolean isConstructor,
|
||||
boolean isDestructor,
|
||||
boolean isVirtual,
|
||||
boolean isExplicit,
|
||||
boolean isPureVirtual,
|
||||
ASTAccessVisibility visibility, ASTPointerOperator pointerOperator);
|
||||
}
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTLinkageSpecification extends IASTScope, IASTDeclaration {
|
||||
public interface IASTLinkageSpecification extends IASTScope, IASTDeclaration, IASTOffsetableElement {
|
||||
|
||||
public String getLinkageString();
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@ public interface IASTOffsetableNamedElement extends IASTOffsetableElement {
|
|||
|
||||
public String getName();
|
||||
public int getElementNameOffset();
|
||||
public void setNameOffset( int o );
|
||||
public void setElementNameOffset( int o );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTPointerOperatorOwner
|
||||
{
|
||||
public ASTPointerOperator getPointerOperator();
|
||||
}
|
|
@ -6,13 +6,14 @@
|
|||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
public interface IExpressionOwner {
|
||||
|
||||
public Expression getExpression();
|
||||
public void setExpression( Expression exp );
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTPointerToFunction extends IASTFunction, IASTPointerOperatorOwner
|
||||
{
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTPointerToMethod extends IASTMethod, IASTPointerOperatorOwner
|
||||
{
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTScopedElement
|
||||
{
|
||||
IASTScope getOwnerScope();
|
||||
}
|
|
@ -18,23 +18,23 @@ import org.eclipse.cdt.core.parser.Enum;
|
|||
*/
|
||||
public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier
|
||||
{
|
||||
public static class SimpleType extends Enum
|
||||
public static class Type extends Enum
|
||||
{
|
||||
public static final SimpleType UNSPECIFIED = new SimpleType( 1 );
|
||||
public static final SimpleType CHAR = new SimpleType( 1 );
|
||||
public static final SimpleType WCHAR_T = new SimpleType( 2 );
|
||||
public static final SimpleType BOOL = new SimpleType( 3 );
|
||||
public static final SimpleType INT = new SimpleType( 4 );
|
||||
public static final SimpleType FLOAT = new SimpleType( 5 );
|
||||
public static final SimpleType DOUBLE = new SimpleType( 6 );
|
||||
public static final SimpleType VOID = new SimpleType( 7 );
|
||||
public static final SimpleType TYPENAME = new SimpleType( 8 );
|
||||
public static final SimpleType TEMPLATE = new SimpleType( 9 );
|
||||
public static final Type UNSPECIFIED = new Type( 1 );
|
||||
public static final Type CHAR = new Type( 1 );
|
||||
public static final Type WCHAR_T = new Type( 2 );
|
||||
public static final Type BOOL = new Type( 3 );
|
||||
public static final Type INT = new Type( 4 );
|
||||
public static final Type FLOAT = new Type( 5 );
|
||||
public static final Type DOUBLE = new Type( 6 );
|
||||
public static final Type VOID = new Type( 7 );
|
||||
public static final Type CLASS_OR_TYPENAME = new Type( 8 );
|
||||
public static final Type TEMPLATE = new Type( 9 );
|
||||
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
protected SimpleType(int enumValue)
|
||||
protected Type(int enumValue)
|
||||
{
|
||||
super(enumValue);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier
|
|||
|
||||
}
|
||||
|
||||
public SimpleType getType();
|
||||
public Type getType();
|
||||
public String getTypename();
|
||||
public boolean isLong();
|
||||
public boolean isShort();
|
||||
|
|
|
@ -18,24 +18,25 @@ import org.eclipse.cdt.core.parser.Enum;
|
|||
*/
|
||||
public interface IASTTemplateParameter extends IASTTemplateParameterList {
|
||||
|
||||
public class ParameterKind extends Enum
|
||||
public class ParamKind extends Enum
|
||||
{
|
||||
public static final ParameterKind CLASS = new ParameterKind( 1 );
|
||||
public static final ParameterKind TYPENAME = new ParameterKind( 2 );
|
||||
public static final ParameterKind TEMPLATE_LIST = new ParameterKind( 3 );
|
||||
public static final ParameterKind PARAMETER = new ParameterKind( 4 );
|
||||
public static final ParamKind CLASS = new ParamKind( 1 );
|
||||
public static final ParamKind TYPENAME = new ParamKind( 2 );
|
||||
public static final ParamKind TEMPLATE_LIST = new ParamKind( 3 );
|
||||
public static final ParamKind PARAMETER = new ParamKind( 4 );
|
||||
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
protected ParameterKind(int enumValue)
|
||||
protected ParamKind(int enumValue)
|
||||
{
|
||||
super(enumValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ParameterKind getTemplateParameterKind();
|
||||
public ParamKind getTemplateParameterKind();
|
||||
public String getIdentifier();
|
||||
public String getDefaultValueIdExpression();
|
||||
public IASTParameterDeclaration getParameterDeclaration();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTTypeSpecifierOwner
|
||||
{
|
||||
public IASTTypeSpecifier getTypeSpecifier();
|
||||
}
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTTypedef extends IASTDeclaration, IASTOffsetableNamedElement {
|
||||
public interface IASTTypedefDeclaration extends IASTDeclaration, IASTOffsetableNamedElement {
|
||||
|
||||
public String getName();
|
||||
public IASTAbstractDeclaration getAbstractDeclarator();
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTUsingDeclaration extends IASTDeclaration {
|
||||
public interface IASTUsingDeclaration extends IASTDeclaration, IASTOffsetableElement {
|
||||
|
||||
public boolean isTypename();
|
||||
public String usingTypeName();
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTUsingDirective extends IASTDeclaration {
|
||||
public interface IASTUsingDirective extends IASTDeclaration, IASTOffsetableElement {
|
||||
|
||||
public String getNamespaceName();
|
||||
}
|
||||
|
|
|
@ -13,20 +13,26 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedef;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -34,8 +40,8 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType;
|
|||
public class DeclarationWrapper implements IDeclaratorOwner
|
||||
{
|
||||
private ITokenDuple name;
|
||||
private SimpleType simpleType =
|
||||
IASTSimpleTypeSpecifier.SimpleType.UNSPECIFIED;
|
||||
private Type simpleType =
|
||||
IASTSimpleTypeSpecifier.Type.UNSPECIFIED;
|
||||
private boolean isSigned;
|
||||
private boolean isLong;
|
||||
private boolean isShort;
|
||||
|
@ -308,24 +314,40 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
{
|
||||
boolean isWithinClass = (getScope() instanceof IASTClassSpecifier);
|
||||
boolean isFunction = declarator.isFunction();
|
||||
boolean hasInnerDeclarator = ( declarator.getOwnedDeclarator() != null );
|
||||
|
||||
if( hasInnerDeclarator )
|
||||
{
|
||||
ITokenDuple innerPointerName = declarator.getOwnedDeclarator().getPointerOperatorNameDuple();
|
||||
if( innerPointerName != null && innerPointerName.getLastToken().getType() == IToken.tCOLONCOLON )
|
||||
return createP2MethodASTNode(declarator);
|
||||
else
|
||||
return createP2FunctionASTNode( declarator );
|
||||
}
|
||||
|
||||
if (isTypedef())
|
||||
return createTypedef(declarator);
|
||||
if (isWithinClass && isFunction)
|
||||
return createMethodASTNode(declarator);
|
||||
else if (isWithinClass && !isFunction)
|
||||
return createFieldASTNode(declarator);
|
||||
else if ((!isWithinClass) && isFunction)
|
||||
return createFunctionASTNode(declarator);
|
||||
else if (!isFunction && !isWithinClass)
|
||||
return createVariableASTNode(declarator);
|
||||
else
|
||||
throw new Error("WTF"); //return IProblem?
|
||||
|
||||
if (isWithinClass )
|
||||
{
|
||||
if( isFunction)
|
||||
return createMethodASTNode(declarator);
|
||||
else
|
||||
return createFieldASTNode(declarator);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isFunction)
|
||||
return createFunctionASTNode(declarator);
|
||||
else
|
||||
return createVariableASTNode(declarator);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param declarator
|
||||
* @return
|
||||
*/
|
||||
private IASTTypedef createTypedef(Declarator declarator)
|
||||
private IASTTypedefDeclaration createTypedef(Declarator declarator)
|
||||
{
|
||||
return astFactory.createTypedef(
|
||||
scope,
|
||||
|
@ -466,6 +488,68 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
getStartingOffset(),
|
||||
declarator.getNameEndOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param declarator
|
||||
* @return
|
||||
*/
|
||||
private IASTPointerToMethod createP2MethodASTNode(Declarator declarator)
|
||||
{
|
||||
|
||||
return astFactory
|
||||
.createPointerToMethod(
|
||||
scope,
|
||||
declarator.getOwnedDeclarator().getPointerOperatorNameDuple().toString().trim() +
|
||||
declarator.getOwnedDeclarator().getName().trim(),
|
||||
createParameterList(declarator.getParameters()),
|
||||
astFactory.createAbstractDeclaration(
|
||||
constt,
|
||||
getTypeSpecifier(),
|
||||
declarator.getPtrOps(),
|
||||
declarator.getArrayModifiers()),
|
||||
declarator.getExceptionSpecification(),
|
||||
inline,
|
||||
friend,
|
||||
staticc,
|
||||
startingOffset,
|
||||
declarator.getNameStartOffset(),
|
||||
templateDeclaration,
|
||||
declarator.isConst(),
|
||||
declarator.isVolatile(),
|
||||
false,
|
||||
// isConstructor
|
||||
false, // isDestructor
|
||||
virtual,
|
||||
explicit,
|
||||
declarator.isPureVirtual(),
|
||||
((scope instanceof IASTClassSpecifier )? ((IASTClassSpecifier)scope).getCurrentVisibilityMode() : ASTAccessVisibility.PUBLIC )
|
||||
, (ASTPointerOperator)declarator.getOwnedDeclarator().getPtrOps().get(0));
|
||||
}
|
||||
/**
|
||||
* @param declarator
|
||||
* @return
|
||||
*/
|
||||
private IASTPointerToFunction createP2FunctionASTNode(Declarator declarator)
|
||||
{
|
||||
return astFactory.createPointerToFunction(
|
||||
scope,
|
||||
declarator.getOwnedDeclarator().getName(),
|
||||
createParameterList(declarator.getParameters()),
|
||||
astFactory.createAbstractDeclaration(
|
||||
constt,
|
||||
getTypeSpecifier(),
|
||||
declarator.getPtrOps(),
|
||||
declarator.getArrayModifiers()),
|
||||
declarator.getExceptionSpecification(),
|
||||
inline,
|
||||
friend,
|
||||
staticc,
|
||||
startingOffset,
|
||||
declarator.getNameStartOffset(),
|
||||
templateDeclaration, (ASTPointerOperator)declarator.getOwnedDeclarator().getPtrOps().get(0));
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IDeclaratorOwner#getDeclarationWrapper()
|
||||
*/
|
||||
|
@ -532,14 +616,14 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
/**
|
||||
* @return
|
||||
*/
|
||||
public SimpleType getSimpleType()
|
||||
public Type getSimpleType()
|
||||
{
|
||||
return simpleType;
|
||||
}
|
||||
/**
|
||||
* @param type
|
||||
*/
|
||||
public void setSimpleType(SimpleType type)
|
||||
public void setSimpleType(Type type)
|
||||
{
|
||||
simpleType = type;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,9 @@ import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
|||
*/
|
||||
public class Declarator implements IParameterCollection, IDeclaratorOwner
|
||||
{
|
||||
private boolean isFunction;
|
||||
private ITokenDuple pointerOperatorNameDuple;
|
||||
private ITokenDuple namedDuple;
|
||||
private boolean isFunction;
|
||||
private boolean hasFunctionBody;
|
||||
private IASTExpression constructorExpression;
|
||||
private boolean pureVirtual = false;
|
||||
|
@ -172,6 +174,7 @@ public class Declarator implements IParameterCollection, IDeclaratorOwner
|
|||
setName( duple.toString() );
|
||||
setNameStartOffset( duple.getFirstToken().getOffset());
|
||||
setNameEndOffset( duple.getLastToken().getEndOffset());
|
||||
namedDuple = duple;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -365,4 +368,28 @@ public class Declarator implements IParameterCollection, IDeclaratorOwner
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public ITokenDuple getNamedDuple()
|
||||
{
|
||||
return namedDuple;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nameDuple
|
||||
*/
|
||||
public void setPointerOperatorName(ITokenDuple nameDuple)
|
||||
{
|
||||
pointerOperatorNameDuple = nameDuple;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public ITokenDuple getPointerOperatorNameDuple()
|
||||
{
|
||||
return pointerOperatorNameDuple;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,26 +15,16 @@ package org.eclipse.cdt.internal.core.parser;
|
|||
*/
|
||||
public class DeclaratorDuple {
|
||||
|
||||
public DeclaratorDuple( Object o, Declarator d )
|
||||
public DeclaratorDuple( Declarator d )
|
||||
{
|
||||
object = o;
|
||||
declarator = d;
|
||||
}
|
||||
|
||||
private final Declarator declarator;
|
||||
private final Object object;
|
||||
private final Declarator declarator;
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Declarator getDeclarator() {
|
||||
return declarator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author dschaefe
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class Name {
|
||||
|
||||
private IToken nameStart, nameEnd;
|
||||
|
||||
public Name(IToken nameStart) {
|
||||
this.nameStart = nameStart;
|
||||
}
|
||||
|
||||
public Name(IToken nameStart, IToken nameEnd) {
|
||||
this( nameStart );
|
||||
setEnd( nameEnd );
|
||||
}
|
||||
|
||||
|
||||
public void setEnd(IToken nameEnd) {
|
||||
this.nameEnd = nameEnd;
|
||||
}
|
||||
|
||||
public int getStartOffset()
|
||||
{
|
||||
return nameStart.getOffset();
|
||||
}
|
||||
|
||||
public int getEndOffset()
|
||||
{
|
||||
return nameEnd.getOffset();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
IToken t = nameStart;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( t.getImage() );
|
||||
if( t.getType() == IToken.t_operator )
|
||||
buffer.append( " " );
|
||||
|
||||
while (t != nameEnd) {
|
||||
t = t.getNext();
|
||||
|
||||
buffer.append( t.getImage() );
|
||||
if (t.getType() == IToken.t_operator) buffer.append( " " );
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public int length()
|
||||
{
|
||||
return getEndOffset() - getStartOffset() + nameEnd.getLength();
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IToken getNameStart() {
|
||||
return nameStart;
|
||||
}
|
||||
|
||||
public static String tokensToString( Token first, Token last )
|
||||
{
|
||||
Name n = new Name( first, last );
|
||||
return n.toString();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,37 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ParameterCollection implements IParameterCollection
|
||||
{
|
||||
private List list = new ArrayList();
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParameterCollection#getParameters()
|
||||
*/
|
||||
public List getParameters()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParameterCollection#addParameter(org.eclipse.cdt.internal.core.parser.DeclarationWrapper)
|
||||
*/
|
||||
public void addParameter(DeclarationWrapper param)
|
||||
{
|
||||
list.add( param );
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,169 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IQuickParseCallback;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||
|
||||
|
||||
public class QuickParseCallback extends NullSourceElementRequestor implements IQuickParseCallback
|
||||
{
|
||||
private IASTCompilationUnit compilationUnit = null;
|
||||
private List inclusions = new ArrayList();
|
||||
private List macros = new ArrayList();
|
||||
|
||||
public Iterator getInclusions()
|
||||
{
|
||||
return inclusions.iterator();
|
||||
}
|
||||
|
||||
public Iterator getMacros()
|
||||
{
|
||||
return macros.iterator();
|
||||
}
|
||||
|
||||
public void exitCompilationUnit( IASTCompilationUnit compilationUnit )
|
||||
{
|
||||
this.compilationUnit = compilationUnit;
|
||||
}
|
||||
|
||||
public void exitInclusion( IASTInclusion inclusion )
|
||||
{
|
||||
inclusions.add( inclusion );
|
||||
}
|
||||
|
||||
public void acceptMacro( IASTMacro macro )
|
||||
{
|
||||
macros.add( macro );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IASTCompilationUnit getCompilationUnit()
|
||||
{
|
||||
return compilationUnit;
|
||||
}
|
||||
|
||||
public class OffsetableIterator implements Iterator
|
||||
{
|
||||
private final Iterator declarationIter;
|
||||
private final Iterator inclusionIter;
|
||||
private final Iterator macroIter;
|
||||
|
||||
private IASTOffsetableElement currentMacro = null, currentInclusion= null, currentDeclaration= null;
|
||||
|
||||
public OffsetableIterator()
|
||||
{
|
||||
declarationIter = compilationUnit.getDeclarations();
|
||||
inclusionIter = inclusions.iterator();
|
||||
macroIter = macros.iterator();
|
||||
updateInclusionIterator();
|
||||
updateDeclarationIterator();
|
||||
updateMacroIterator();
|
||||
}
|
||||
|
||||
private Object updateDeclarationIterator()
|
||||
{
|
||||
Object offsetable = currentDeclaration;
|
||||
currentDeclaration = ( declarationIter.hasNext() ) ? (IASTOffsetableElement)declarationIter.next() : null;
|
||||
return offsetable;
|
||||
}
|
||||
|
||||
private Object updateMacroIterator()
|
||||
{
|
||||
Object offsetable = currentMacro;
|
||||
currentMacro = ( macroIter.hasNext() ) ? (IASTOffsetableElement)macroIter.next() : null;
|
||||
return offsetable;
|
||||
}
|
||||
|
||||
private Object updateInclusionIterator()
|
||||
{
|
||||
Object offsetable = currentInclusion;
|
||||
currentInclusion = ( inclusionIter.hasNext() ) ? (IASTOffsetableElement)inclusionIter.next() : null;
|
||||
return offsetable;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return (( currentMacro == null && currentInclusion == null && currentDeclaration == null ) ?
|
||||
false : true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
public Object next() {
|
||||
// case 1: all are null
|
||||
if( ! hasNext() )
|
||||
throw new NoSuchElementException();
|
||||
|
||||
// case 2: two of three are null
|
||||
if( currentMacro == null && currentInclusion == null )
|
||||
return updateDeclarationIterator();
|
||||
if( currentDeclaration == null && currentInclusion == null )
|
||||
return updateMacroIterator();
|
||||
if( currentMacro == null && currentDeclaration == null )
|
||||
return updateInclusionIterator();
|
||||
|
||||
// case 3: 1 is null
|
||||
if( currentMacro == null )
|
||||
if( currentDeclaration.getElementStartingOffset() < currentInclusion.getElementStartingOffset() )
|
||||
return updateDeclarationIterator();
|
||||
else
|
||||
return updateInclusionIterator();
|
||||
|
||||
if( currentInclusion == null )
|
||||
if( currentDeclaration.getElementStartingOffset() < currentMacro.getElementStartingOffset() )
|
||||
return updateDeclarationIterator();
|
||||
else
|
||||
return updateMacroIterator();
|
||||
|
||||
if( currentDeclaration == null )
|
||||
if( currentInclusion.getElementStartingOffset() < currentMacro.getElementStartingOffset() )
|
||||
return updateInclusionIterator();
|
||||
else
|
||||
return updateMacroIterator();
|
||||
|
||||
// case 4: none are null
|
||||
if( currentInclusion.getElementStartingOffset() < currentMacro.getElementStartingOffset() &&
|
||||
currentInclusion.getElementStartingOffset() < currentDeclaration.getElementStartingOffset() )
|
||||
return updateInclusionIterator();
|
||||
|
||||
if( currentMacro.getElementStartingOffset() < currentInclusion.getElementStartingOffset() &&
|
||||
currentMacro.getElementStartingOffset() < currentDeclaration.getElementStartingOffset() )
|
||||
return updateMacroIterator();
|
||||
// only remaining case
|
||||
return updateDeclarationIterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException( "OffsetableIterator is a const iterator");
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator iterateOffsetableElements()
|
||||
{
|
||||
return new OffsetableIterator();
|
||||
}
|
||||
}
|
|
@ -28,7 +28,6 @@ import org.eclipse.cdt.core.parser.Backtrack;
|
|||
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IParserCallback;
|
||||
import org.eclipse.cdt.core.parser.IProblemReporter;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
|
@ -388,11 +387,6 @@ public class Scanner implements IScanner {
|
|||
this.mode = mode;
|
||||
}
|
||||
|
||||
private IParserCallback callback;
|
||||
public void setCallback(IParserCallback c) {
|
||||
callback = c;
|
||||
}
|
||||
|
||||
private int getChar() throws ScannerException
|
||||
{
|
||||
return getChar( false );
|
||||
|
@ -1671,7 +1665,7 @@ public class Scanner implements IScanner {
|
|||
IParser parser = ParserFactory.createParser(trial, new NullSourceElementRequestor(), ParserMode.QUICK_PARSE );
|
||||
|
||||
try {
|
||||
IASTExpression exp = parser.expression(null);
|
||||
IASTExpression exp = parser.expression();
|
||||
if( exp.evaluateExpression() == 0 )
|
||||
return false;
|
||||
} catch( Backtrack b )
|
||||
|
@ -1815,11 +1809,6 @@ public class Scanner implements IScanner {
|
|||
|
||||
if( mode == ParserMode.QUICK_PARSE )
|
||||
{
|
||||
if( callback != null )
|
||||
{
|
||||
callback.inclusionEnd(callback.inclusionBegin( f, offset, beginningOffset, !useIncludePath ));
|
||||
}
|
||||
|
||||
if( requestor != null )
|
||||
{
|
||||
IASTInclusion i = astFactory.createInclusion( f, "", !useIncludePath, beginningOffset,
|
||||
|
@ -1986,13 +1975,6 @@ public class Scanner implements IScanner {
|
|||
if (throwExceptionOnBadPreprocessorSyntax)
|
||||
throw new ScannerException(BAD_PP + contextStack.getCurrentContext().getOffset());
|
||||
}
|
||||
|
||||
// call the callback accordingly
|
||||
if( callback != null )
|
||||
{
|
||||
// NOTE: return value is ignored!
|
||||
callback.macro( key, offset, beginning, contextStack.getCurrentContext().getOffset() );
|
||||
}
|
||||
|
||||
if( requestor != null )
|
||||
{
|
||||
|
|
|
@ -92,5 +92,20 @@ public class TokenDuple implements ITokenDuple {
|
|||
{
|
||||
return ( firstToken == lastToken );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#length()
|
||||
*/
|
||||
public int length()
|
||||
{
|
||||
int count = 0;
|
||||
Iterator i = iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
++count;
|
||||
i.next();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class ASTInclusion implements IASTInclusion {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o) {
|
||||
public void setElementNameOffset(int o) {
|
||||
nameOffset = o;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ASTMacro implements IASTMacro {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o) {
|
||||
public void setElementNameOffset(int o) {
|
||||
nameOffset = o;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BaseASTFactory {
|
|||
IASTMacro m = new ASTMacro( name );
|
||||
m.setStartingOffset( startingOffset );
|
||||
m.setEndingOffset( endingOffset );
|
||||
m.setNameOffset( nameOffset );
|
||||
m.setElementNameOffset( nameOffset );
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class BaseASTFactory {
|
|||
IASTInclusion inclusion = new ASTInclusion( name, fileName, local );
|
||||
inclusion.setStartingOffset( startingOffset );
|
||||
inclusion.setEndingOffset( endingOffset );
|
||||
inclusion.setNameOffset( nameOffset );
|
||||
inclusion.setElementNameOffset( nameOffset );
|
||||
return inclusion;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.ast;
|
||||
package org.eclipse.cdt.internal.core.parser.ast.full;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
|
||||
|
@ -24,10 +25,10 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
|||
private final boolean isVirtual;
|
||||
private final ASTAccessVisibility visibility;
|
||||
|
||||
public ASTBaseSpecifier( IASTClassSpecifier c, ASTAccessVisibility a, boolean virtual )
|
||||
public ASTBaseSpecifier( IASTClassSpecifier classSpec, ASTAccessVisibility a, boolean virtual )
|
||||
{
|
||||
isVirtual = virtual;
|
||||
baseClass = c;
|
||||
baseClass = classSpec;
|
||||
visibility = a;
|
||||
}
|
||||
|
||||
|
@ -48,8 +49,16 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParent()
|
||||
*/
|
||||
public IASTClassSpecifier getParent() {
|
||||
return baseClass;
|
||||
public String getParentClassName() {
|
||||
return baseClass.getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParentClassSpecifier()
|
||||
*/
|
||||
public IASTClassSpecifier getParentClassSpecifier() throws ASTNotImplementedException
|
||||
{
|
||||
return baseClass;
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||
|
@ -26,7 +27,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
|||
*/
|
||||
public class ASTClassSpecifier implements IASTFClassSpecifier, IPSTSymbolExtension {
|
||||
|
||||
private final IDerivableContainerSymbol symbol;
|
||||
private final IDerivableContainerSymbol symbol;
|
||||
private final ASTClassKind classKind;
|
||||
private final ClassNameType type;
|
||||
private final String name;
|
||||
|
@ -86,7 +87,7 @@ public class ASTClassSpecifier implements IASTFClassSpecifier, IPSTSymbolExtensi
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o) {
|
||||
public void setElementNameOffset(int o) {
|
||||
nameOffset = o;
|
||||
}
|
||||
|
||||
|
@ -152,4 +153,22 @@ public class ASTClassSpecifier implements IASTFClassSpecifier, IPSTSymbolExtensi
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#setCurrentVisibility(org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||
*/
|
||||
public void setCurrentVisibility(ASTAccessVisibility visibility)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope()
|
||||
*/
|
||||
public IASTScope getOwnerScope()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast.full;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
|
||||
|
@ -22,11 +23,12 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
|||
*/
|
||||
public class ASTLinkageSpecification implements IASTFLinkageSpecification {
|
||||
|
||||
public ASTLinkageSpecification( IContainerSymbol symbol, String linkage )
|
||||
public ASTLinkageSpecification( IContainerSymbol symbol, String linkage, int startingOffset )
|
||||
{
|
||||
this.symbol = symbol;
|
||||
symbol.setASTNode( this );
|
||||
this.linkage = linkage;
|
||||
setStartingOffset(startingOffset);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||
|
@ -65,4 +67,34 @@ public class ASTLinkageSpecification implements IASTFLinkageSpecification {
|
|||
return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||
*/
|
||||
public void setStartingOffset(int o)
|
||||
{
|
||||
offsets.setStartingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||
*/
|
||||
public void setEndingOffset(int o)
|
||||
{
|
||||
offsets.setEndingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||
*/
|
||||
public int getElementStartingOffset()
|
||||
{
|
||||
return offsets.getElementStartingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||
*/
|
||||
public int getElementEndingOffset()
|
||||
{
|
||||
return offsets.getElementEndingOffset();
|
||||
}
|
||||
private Offsets offsets = new Offsets();
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ASTNamespaceDefinition implements IASTFNamespaceDefinition {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o) {
|
||||
public void setElementNameOffset(int o) {
|
||||
nameOffset = o;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.full;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -19,11 +20,14 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
|||
*/
|
||||
public class ASTUsingDirective implements IASTUsingDirective {
|
||||
|
||||
private final String namespaceName;
|
||||
private final String namespaceName;
|
||||
private Offsets offsets = new Offsets();
|
||||
|
||||
public ASTUsingDirective( String namespace )
|
||||
public ASTUsingDirective( String namespace, int startingOffset, int endingOffset )
|
||||
{
|
||||
namespaceName = namespace;
|
||||
offsets.setStartingOffset(startingOffset);
|
||||
offsets.setEndingOffset( endingOffset );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName()
|
||||
|
@ -37,6 +41,34 @@ public class ASTUsingDirective implements IASTUsingDirective {
|
|||
public IASTScope getOwnerScope() {
|
||||
return null; //TODO
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||
*/
|
||||
public void setStartingOffset(int o)
|
||||
{
|
||||
offsets.setStartingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||
*/
|
||||
public void setEndingOffset(int o)
|
||||
{
|
||||
offsets.setEndingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||
*/
|
||||
public int getElementStartingOffset()
|
||||
{
|
||||
return offsets.getElementStartingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||
*/
|
||||
public int getElementEndingOffset()
|
||||
{
|
||||
return offsets.getElementEndingOffset();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser.ast.full;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTBaseSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,8 +18,10 @@ import org.eclipse.cdt.core.parser.IToken;
|
|||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||
|
@ -35,6 +37,8 @@ import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
|
@ -43,15 +47,14 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedef;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParameterKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||
|
@ -69,7 +72,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
|
||||
public IASTUsingDirective createUsingDirective(
|
||||
IASTScope scope,
|
||||
ITokenDuple duple)
|
||||
ITokenDuple duple, int startingOffset, int endingOffset)
|
||||
throws Backtrack {
|
||||
Iterator iter = duple.iterator();
|
||||
IToken t1 = (IToken)iter.next();
|
||||
|
@ -109,7 +112,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
handlePSTException( pste );
|
||||
}
|
||||
|
||||
IASTUsingDirective astUD = new ASTUsingDirective( duple.toString() );
|
||||
IASTUsingDirective astUD = new ASTUsingDirective( duple.toString(), startingOffset, endingOffset );
|
||||
return astUD;
|
||||
}
|
||||
|
||||
|
@ -145,7 +148,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
IASTFNamespaceDefinition namespaceDefinition = new ASTNamespaceDefinition( namespaceSymbol, identifier );
|
||||
namespaceDefinition.setStartingOffset( first );
|
||||
if( identifier != "" )
|
||||
namespaceDefinition.setNameOffset( nameOffset );
|
||||
namespaceDefinition.setElementNameOffset( nameOffset );
|
||||
return namespaceDefinition;
|
||||
}
|
||||
|
||||
|
@ -154,9 +157,9 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
return compilationUnit;
|
||||
}
|
||||
|
||||
public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec) {
|
||||
public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec, int startingOffset) {
|
||||
IContainerSymbol symbol = pst.newContainerSymbol("", ParserSymbolTable.TypeInfo.t_linkage );
|
||||
IASTFLinkageSpecification linkage = new ASTLinkageSpecification( symbol, spec);
|
||||
IASTFLinkageSpecification linkage = new ASTLinkageSpecification( symbol, spec, startingOffset);
|
||||
return linkage;
|
||||
}
|
||||
|
||||
|
@ -170,7 +173,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
|
||||
*/
|
||||
public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, ITokenDuple name) {
|
||||
public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, ITokenDuple name, int startingOffset, int endingOffset) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
@ -273,7 +276,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType, org.eclipse.cdt.core.parser.ITokenDuple, boolean, boolean, boolean, boolean)
|
||||
*/
|
||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(SimpleType kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename)
|
||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
@ -345,7 +348,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTemplateParameter(org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParameterKind, org.eclipse.cdt.core.parser.IToken, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration)
|
||||
*/
|
||||
public IASTTemplateParameter createTemplateParameter(ParameterKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms)
|
||||
public IASTTemplateParameter createTemplateParameter(IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
@ -372,7 +375,34 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypedef(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration)
|
||||
*/
|
||||
public IASTTypedef createTypedef(IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset)
|
||||
public IASTTypedefDeclaration createTypedef(IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List)
|
||||
*/
|
||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration(IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate)
|
||||
*/
|
||||
public IASTPointerToFunction createPointerToFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, ASTPointerOperator pointerOperator)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||
*/
|
||||
public IASTPointerToMethod createPointerToMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, ASTPointerOperator pointerOperator)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTAbstractDeclaration implements IASTAbstractDeclaration
|
||||
public class ASTAbstractDeclaration implements IASTAbstractDeclaration
|
||||
{
|
||||
private final boolean isConst;
|
||||
private final IASTTypeSpecifier typeSpecifier;
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTAbstractTypeSpecifierDeclaration
|
||||
extends ASTDeclaration
|
||||
implements IASTAbstractTypeSpecifierDeclaration
|
||||
{
|
||||
private final IASTTemplate ownerTemplate;
|
||||
private final IASTTypeSpecifier typeSpecifier;
|
||||
/**
|
||||
* @param scope
|
||||
* @param typeSpecifier
|
||||
*/
|
||||
public ASTAbstractTypeSpecifierDeclaration(IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate ownerTemplate, int startingOffset, int endingOffset)
|
||||
{
|
||||
super( ownerTemplate != null ? null : scope );
|
||||
this.typeSpecifier = typeSpecifier;
|
||||
this.ownerTemplate = ownerTemplate;
|
||||
if( ownerTemplate != null )
|
||||
ownerTemplate.setOwnedDeclaration( this );
|
||||
setStartingOffset(startingOffset);
|
||||
setEndingOffset(endingOffset);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getTypeSpecifier()
|
||||
*/
|
||||
public IASTTypeSpecifier getTypeSpecifier()
|
||||
{
|
||||
return typeSpecifier;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration()
|
||||
*/
|
||||
public IASTTemplate getOwnerTemplateDeclaration()
|
||||
{
|
||||
return ownerTemplate;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||
*/
|
||||
public void setStartingOffset(int o)
|
||||
{
|
||||
offsets.setStartingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||
*/
|
||||
public void setEndingOffset(int o)
|
||||
{
|
||||
offsets.setEndingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||
*/
|
||||
public int getElementStartingOffset()
|
||||
{
|
||||
return offsets.getElementStartingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||
*/
|
||||
public int getElementEndingOffset()
|
||||
{
|
||||
return offsets.getElementEndingOffset();
|
||||
}
|
||||
private Offsets offsets = new Offsets();
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
|
||||
|
@ -22,11 +23,11 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
|||
|
||||
private final ASTAccessVisibility visibility;
|
||||
private final boolean isVirtual;
|
||||
private final IASTClassSpecifier parentClass;
|
||||
private final String parentClassName;
|
||||
|
||||
public ASTBaseSpecifier( IASTClassSpecifier classSpec, boolean v, ASTAccessVisibility a )
|
||||
public ASTBaseSpecifier( String className, boolean v, ASTAccessVisibility a )
|
||||
{
|
||||
parentClass = classSpec;
|
||||
parentClassName = className;
|
||||
isVirtual = v;
|
||||
visibility = a;
|
||||
}
|
||||
|
@ -47,8 +48,15 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParent()
|
||||
*/
|
||||
public IASTClassSpecifier getParent() {
|
||||
return parentClass;
|
||||
public String getParentClassName() {
|
||||
return parentClassName;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParentClassSpecifier()
|
||||
*/
|
||||
public IASTClassSpecifier getParentClassSpecifier() throws ASTNotImplementedException
|
||||
{
|
||||
throw new ASTNotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTClassSpecifier
|
||||
extends ASTQualifiedNamedDeclaration
|
||||
implements IASTQClassSpecifier, IASTQScope
|
||||
public class ASTClassSpecifier implements IASTQClassSpecifier, IASTQScope
|
||||
{
|
||||
|
||||
private final IASTScope scope;
|
||||
public ASTClassSpecifier(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
|
@ -36,15 +36,15 @@ public class ASTClassSpecifier
|
|||
ASTAccessVisibility access,
|
||||
IASTTemplate ownerTemplate)
|
||||
{
|
||||
super(scope, name );
|
||||
this.scope = scope;
|
||||
qualifiedNameElement = new ASTQualifiedNamedElement( scope, name );
|
||||
classNameType = type;
|
||||
classKind = kind;
|
||||
this.access = access;
|
||||
this.name = name;
|
||||
templateOwner = ownerTemplate;
|
||||
}
|
||||
|
||||
private IASTTemplate templateOwner = null;
|
||||
private final ASTQualifiedNamedElement qualifiedNameElement;
|
||||
private final String name;
|
||||
private List declarations = new ArrayList();
|
||||
private List baseClauses = new ArrayList();
|
||||
|
@ -104,17 +104,11 @@ public class ASTClassSpecifier
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o)
|
||||
public void setElementNameOffset(int o)
|
||||
{
|
||||
offsets.setNameOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration()
|
||||
*/
|
||||
public IASTTemplate getOwnerTemplateDeclaration()
|
||||
{
|
||||
return templateOwner;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||
*/
|
||||
|
@ -157,4 +151,26 @@ public class ASTClassSpecifier
|
|||
{
|
||||
baseClauses.add(baseSpecifier);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getFullyQualifiedName()
|
||||
{
|
||||
return qualifiedNameElement.getFullyQualifiedName();
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IASTScope getOwnerScope()
|
||||
{
|
||||
return scope;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#setCurrentVisibility(org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||
*/
|
||||
public void setCurrentVisibility(ASTAccessVisibility visibility)
|
||||
{
|
||||
this.access = visibility;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public class ASTDeclaration implements IASTDeclaration {
|
|||
public ASTDeclaration( IASTScope scope )
|
||||
{
|
||||
this.scope = scope;
|
||||
if( scope != null && scope instanceof IASTQScope )
|
||||
((IASTQScope)scope).addDeclaration(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ASTElaboratedTypeSpecifier implements IASTElaboratedTypeSpecifier
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier#getTypeName()
|
||||
*/
|
||||
public String getTypeName()
|
||||
public String getName()
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ASTEnumerationSpecifier
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o)
|
||||
public void setElementNameOffset(int o)
|
||||
{
|
||||
offsets.setNameOffset(o);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ASTEnumerator
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o)
|
||||
public void setElementNameOffset(int o)
|
||||
{
|
||||
offsets.setNameOffset(o);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
public ASTFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception,
|
||||
boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate )
|
||||
{
|
||||
super(scope);
|
||||
super(ownerTemplate != null ? null : scope );
|
||||
this.name = name;
|
||||
this.parms = parameters;
|
||||
this.returnType = returnType;
|
||||
|
@ -42,6 +42,8 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
this.isFriend = isFriend;
|
||||
this.isStatic = isStatic;
|
||||
this.ownerTemplateDeclaration = ownerTemplate;
|
||||
if( ownerTemplate != null )
|
||||
ownerTemplate.setOwnedDeclaration( this );
|
||||
offsets.setStartingOffset( startOffset );
|
||||
offsets.setNameOffset( nameOffset );
|
||||
}
|
||||
|
@ -115,7 +117,7 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o)
|
||||
public void setElementNameOffset(int o)
|
||||
{
|
||||
offsets.setNameOffset( o );
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -28,10 +29,11 @@ public class ASTLinkageSpecification
|
|||
|
||||
private final String linkage;
|
||||
|
||||
public ASTLinkageSpecification( IASTScope scope, String linkage )
|
||||
public ASTLinkageSpecification( IASTScope scope, String linkage, int startingOffset )
|
||||
{
|
||||
super( scope );
|
||||
this.linkage = linkage;
|
||||
setStartingOffset(startingOffset);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -56,4 +58,34 @@ public class ASTLinkageSpecification
|
|||
declarations.add( declaration );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||
*/
|
||||
public void setStartingOffset(int o)
|
||||
{
|
||||
offsets.setStartingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
|
||||
*/
|
||||
public void setEndingOffset(int o)
|
||||
{
|
||||
offsets.setEndingOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
|
||||
*/
|
||||
public int getElementStartingOffset()
|
||||
{
|
||||
return offsets.getElementStartingOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
|
||||
*/
|
||||
public int getElementEndingOffset()
|
||||
{
|
||||
return offsets.getElementEndingOffset();
|
||||
}
|
||||
private Offsets offsets = new Offsets();
|
||||
|
||||
}
|
||||
|
|
|
@ -23,14 +23,16 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTNamespaceDefinition extends ASTQualifiedNamedDeclaration implements IASTNamespaceDefinition, IASTQScope {
|
||||
public class ASTNamespaceDefinition extends ASTDeclaration implements IASTNamespaceDefinition, IASTQScope {
|
||||
|
||||
private final String name;
|
||||
private NamedOffsets offsets = new NamedOffsets();
|
||||
private NamedOffsets offsets = new NamedOffsets();
|
||||
private final ASTQualifiedNamedElement qualifiedNameElement;
|
||||
|
||||
public ASTNamespaceDefinition( IASTScope scope, String name )
|
||||
{
|
||||
super( scope, name );
|
||||
super( scope );
|
||||
qualifiedNameElement = new ASTQualifiedNamedElement( scope, name );
|
||||
this.name = name;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
@ -50,7 +52,7 @@ public class ASTNamespaceDefinition extends ASTQualifiedNamedDeclaration impleme
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
|
||||
*/
|
||||
public void setNameOffset(int o) {
|
||||
public void setElementNameOffset(int o) {
|
||||
offsets.setNameOffset( o );
|
||||
}
|
||||
|
||||
|
@ -96,4 +98,11 @@ public class ASTNamespaceDefinition extends ASTQualifiedNamedDeclaration impleme
|
|||
public void addDeclaration(IASTDeclaration declaration) {
|
||||
declarations.add( declaration );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getFullyQualifiedName()
|
||||
{
|
||||
return qualifiedNameElement.getFullyQualifiedName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTPointerToFunction
|
||||
extends ASTFunction
|
||||
implements IASTPointerToFunction
|
||||
{
|
||||
|
||||
private final ASTPointerOperator pointerOperator;
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param name
|
||||
* @param parameters
|
||||
* @param returnType
|
||||
* @param exception
|
||||
* @param isInline
|
||||
* @param isFriend
|
||||
* @param isStatic
|
||||
* @param startOffset
|
||||
* @param nameOffset
|
||||
* @param ownerTemplate
|
||||
*/
|
||||
public ASTPointerToFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, ASTPointerOperator pointerOperator)
|
||||
{
|
||||
super(
|
||||
scope,
|
||||
name,
|
||||
parameters,
|
||||
returnType,
|
||||
exception,
|
||||
isInline,
|
||||
isFriend,
|
||||
isStatic,
|
||||
startOffset,
|
||||
nameOffset,
|
||||
ownerTemplate);
|
||||
this.pointerOperator = pointerOperator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTPointerOperatorOwner#getPointerOperator()
|
||||
*/
|
||||
public ASTPointerOperator getPointerOperator()
|
||||
{
|
||||
return pointerOperator;
|
||||
}
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue