[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [ HEAD & ParserSymbol_Table ] PR 38380 partial fix.
|
CORE
Fix
Bug 38380 "Include" class public methods fails JUnit tests
Updated
CModel, DOM, Scanner and current Parser callback to set the information
appropriately.
TESTS
Moved
testBug23478A() & testBug23478B() from failed tests to TranslationUnitTests.java.
Removed
TranslationUnitFailedTests.java as it was empty.
I also had to apply Alain's partial
fix to the Parser_SymbolTable branch to get this working.
JohnC
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/ChangeLog,v
retrieving revision 1.51
diff -u -r1.51 ChangeLog
--- ChangeLog 5 May 2003 20:51:37 -0000 1.51
+++ ChangeLog 5 Jun 2003 19:50:57 -0000
@@ -1,3 +1,7 @@
+2003-06-05 John Camelon
+ Moved testBug23478A() & testBug23478B() from failed tests to TranslationUnitTests.java.
+ Removed TranslationUnitFailedTests.java as it was empty.
+
2003-05-05 John Camelon/Andrew Niefer
Added CrossReferenceTests to ParserTestSuite to test symbol-table/DOM interworking.
Index: failures/org/eclipse/cdt/core/model/failedTests/TranslationUnitFailedTests.java
===================================================================
RCS file: failures/org/eclipse/cdt/core/model/failedTests/TranslationUnitFailedTests.java
diff -N failures/org/eclipse/cdt/core/model/failedTests/TranslationUnitFailedTests.java
--- failures/org/eclipse/cdt/core/model/failedTests/TranslationUnitFailedTests.java 26 May 2003 16:59:50 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,206 +0,0 @@
-package org.eclipse.cdt.core.model.failedTests;
-
-/**********************************************************************
- * 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:
- * Rational Software - Initial API and implementation
-***********************************************************************/
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IInclude;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.testplugin.CProjectHelper;
-import org.eclipse.cdt.testplugin.util.ExpectedStrings;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-
-
-
-/**
- * @author Peter Graves
- *
- * This file contains a set of generic tests for the core C model's TranslationUnit
- * class. There is nothing exotic here, mostly just sanity type tests
- *
- */
-public class TranslationUnitFailedTests extends TestCase {
- IWorkspace workspace;
- IWorkspaceRoot root;
- ICProject testProject;
- IFile cfile, exefile, libfile, archfile, objfile;
- Path cpath, exepath, libpath, archpath, objpath;
- NullProgressMonitor monitor;
-
- /* This is a list of elements in the test .c file. It will be used
- * in a number of places in the tests
- */
- String[] expectedStringList= {"stdio.h", "unistd.h", "func2p",
- "globalvar", "myenum", "mystruct", "mystruct_t", "myunion", "mytype",
- "func1", "func2", "main", "func3"};
- int[] expectedLines={ 12,14,17,20,23,28,32,35,42,47,53,58,65};
- /* This is a list of that the types of the above list of elements is
- * expected to be.
- */
- int[] expectedTypes= { ICElement.C_INCLUDE, ICElement.C_INCLUDE,
- ICElement.C_FUNCTION_DECLARATION, ICElement.C_VARIABLE,
- ICElement.C_ENUMERATION, ICElement.C_STRUCT, ICElement.C_TYPEDEF,
- ICElement.C_UNION, ICElement.C_TYPEDEF, ICElement.C_FUNCTION,
- ICElement.C_FUNCTION, ICElement.C_FUNCTION,ICElement.C_FUNCTION};
-
-
- /**
- * Constructor for TranslationUnitTests
- * @param name
- */
- public TranslationUnitFailedTests(String name) {
- super(name);
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- protected void setUp() throws CoreException,FileNotFoundException {
- /***
- * The rest of the tests assume that they have a working workspace
- * and workspace root object to use to create projects/files in,
- * so we need to get them setup first.
- */
- IWorkspaceDescription desc;
- String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.ui.tests").find(new Path("/")).getFile();
- workspace= ResourcesPlugin.getWorkspace();
- root= workspace.getRoot();
- monitor = new NullProgressMonitor();
- if (workspace==null)
- fail("Workspace was not setup");
- if (root==null)
- fail("Workspace root was not setup");
-
- desc=workspace.getDescription();
- desc.setAutoBuilding(false);
- workspace.setDescription(desc);
-
- /***
- * Setup the various files, paths and projects that are needed by the
- * tests
- */
-
- testProject=CProjectHelper.createCProject("filetest", "none");
- if (testProject==null)
- fail("Unable to create project");
-
- cfile = testProject.getProject().getFile("exetest.c");
- if (!cfile.exists()) {
- cfile.create(new FileInputStream(pluginRoot+"model/org/eclipse/cdt/core/model/tests/resources/cfiles/TranslationUnits.c"),false, monitor);
-
- }
- cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
-
- objfile = testProject.getProject().getFile("exetest.o");
- if (!objfile.exists()) {
- objfile.create(new FileInputStream(pluginRoot+"model/org/eclipse/cdt/core/model/tests/resources/exe/x86/o.g/main.o"),false, monitor);
-
- }
- objpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.o");
-
- exefile = testProject.getProject().getFile("test_g");
- if (!exefile.exists()) {
- exefile.create(new FileInputStream(pluginRoot+"model/org/eclipse/cdt/core/model/tests/resources/exe/x86/o.g/exe_g"),false, monitor);
-
- }
- exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
-
- archfile = testProject.getProject().getFile("libtestlib_g.a");
- if (!archfile.exists()) {
- archfile.create(new FileInputStream(pluginRoot+"model/org/eclipse/cdt/core/model/tests/resources/testlib/x86/a.g/libtestlib_g.a"),false, monitor);
-
- }
- libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
-
- libfile = testProject.getProject().getFile("libtestlib_g.so");
- if (!libfile.exists()) {
- libfile.create(new FileInputStream(pluginRoot+"model/org/eclipse/cdt/core/model/tests/resources/testlib/x86/so.g/libtestlib_g.so"),false, monitor);
-
- }
- archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
-
-
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- protected void tearDown() throws CoreException {
- // release resources here and clean-up
- testProject.getProject().delete(true,true,monitor);
- }
-
-
- /***
- * Simple sanity tests for the getInclude call
- */
- public void testBug23478A() {
- IInclude myInclude;
- int x;
- String includes[]={"stdio.h", "unistd.h"};
- ITranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
-
- for (x=0; x < includes.length; x++) {
- myInclude=myTranslationUnit.getInclude(includes[x]);
- if (myInclude==null)
- fail("Unable to get include: " + includes[x]);
- else {
- // Failed test: Include.getIncludeName() always returns "";
- // assertTrue
- assertFalse("PR:23478 Expected:"+ new String("") +" Got:"+ myInclude.getIncludeName(), includes[x].equals(myInclude.getIncludeName()));
- }
- }
-
-
- }
- /***
- * Simple sanity tests for the getIncludes call
- */
- public void testBug23478B() throws CModelException {
- IInclude myIncludes[];
- String includes[]={"stdio.h", "unistd.h"};
- ExpectedStrings myExp= new ExpectedStrings(includes);
- int x;
- ITranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
-
- myIncludes=myTranslationUnit.getIncludes();
- for (x=0; x < myIncludes.length; x++) {
- myExp.foundString(myIncludes[x].getIncludeName());
- }
- // Failed test: Include.getIncludeName() always returns "";
- // assertTrue
- assertFalse(myExp.getMissingString(), myExp.gotAll());
- assertFalse(myExp.getExtraString(), !myExp.gotExtra());
- }
-
-}
Index: model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java,v
retrieving revision 1.6
diff -u -r1.6 TranslationUnitTests.java
--- model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java 26 May 2003 16:59:50 -0000 1.6
+++ model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java 5 Jun 2003 19:50:57 -0000
@@ -232,6 +232,51 @@
}
}
+
+ /***
+ * Simple sanity tests for the getInclude call
+ */
+ public void testBug23478A() {
+ IInclude myInclude;
+ int x;
+ String includes[]={"stdio.h", "unistd.h"};
+ ITranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
+
+ for (x=0; x < includes.length; x++) {
+ myInclude=myTranslationUnit.getInclude(includes[x]);
+ if (myInclude==null)
+ fail("Unable to get include: " + includes[x]);
+ else {
+ // Failed test: Include.getIncludeName() always returns "";
+ // assertTrue
+ assertTrue("PR:23478 Expected:"+ new String("") +" Got:"+ myInclude.getIncludeName(), includes[x].equals(myInclude.getIncludeName()));
+ }
+ }
+
+
+ }
+ /***
+ * Simple sanity tests for the getIncludes call
+ */
+ public void testBug23478B() throws CModelException {
+ IInclude myIncludes[];
+ String includes[]={"stdio.h", "unistd.h"};
+ ExpectedStrings myExp= new ExpectedStrings(includes);
+ int x;
+ ITranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
+
+ myIncludes=myTranslationUnit.getIncludes();
+ for (x=0; x < myIncludes.length; x++) {
+ myExp.foundString(myIncludes[x].getIncludeName());
+ }
+ // Failed test: Include.getIncludeName() always returns "";
+ // assertTrue
+ assertTrue(myExp.getMissingString(), myExp.gotAll());
+ assertTrue(myExp.getExtraString(), !myExp.gotExtra());
+ }
+
+
+
/***
* Simple sanity tests for the getElementAtLine() call
*/
Index: suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java,v
retrieving revision 1.1
diff -u -r1.1 AutomatedIntegrationSuite.java
--- suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java 26 May 2003 16:59:50 -0000 1.1
+++ suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java 5 Jun 2003 19:50:57 -0000
@@ -83,7 +83,6 @@
suite.addTestSuite(ScannerFailedTest.class);
suite.addTestSuite(STLFailedTests.class);
suite.addTestSuite(CModelElementsFailedTests.class);
- suite.addTestSuite(TranslationUnitFailedTests.class);
// Last test to trigger report generation
suite.addTest(suite.new GenerateReport("testGenerateReport"));
Index: dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java,v
retrieving revision 1.31
diff -u -r1.31 DOMBuilder.java
--- dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java 6 May 2003 15:33:32 -0000 1.31
+++ dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java 5 Jun 2003 19:50:24 -0000
@@ -161,8 +161,13 @@
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#inclusionBegin(java.lang.String)
*/
- public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
- Inclusion inclusion = new Inclusion( includeFile, offset, inclusionBeginOffset, offset - inclusionBeginOffset + includeFile.length() + 1 );
+ public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset, boolean local) {
+ Inclusion inclusion = new Inclusion(
+ includeFile,
+ offset,
+ inclusionBeginOffset,
+ offset - inclusionBeginOffset + includeFile.length() + 1,
+ local );
translationUnit.addInclusion( inclusion );
return inclusion;
}
Index: dom/org/eclipse/cdt/internal/core/dom/Inclusion.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Inclusion.java,v
retrieving revision 1.1
diff -u -r1.1 Inclusion.java
--- dom/org/eclipse/cdt/internal/core/dom/Inclusion.java 8 Apr 2003 03:41:05 -0000 1.1
+++ dom/org/eclipse/cdt/internal/core/dom/Inclusion.java 5 Jun 2003 19:50:24 -0000
@@ -18,8 +18,18 @@
*/
public class Inclusion extends PreprocessorStatement {
- public Inclusion( String name, int nameOffset, int startingOffset, int totalLength )
+ private final boolean local;
+
+ public Inclusion( String name, int nameOffset, int startingOffset, int totalLength, boolean local )
{
super( name, nameOffset, startingOffset, totalLength );
+ this.local = local;
}
+ /**
+ * @return
+ */
+ public boolean isLocal() {
+ return local;
+ }
+
}
Index: dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java,v
retrieving revision 1.1
diff -u -r1.1 LineNumberedDOMBuilder.java
--- dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java 21 Apr 2003 18:34:39 -0000 1.1
+++ dom/org/eclipse/cdt/internal/core/dom/LineNumberedDOMBuilder.java 5 Jun 2003 19:50:24 -0000
@@ -91,8 +91,8 @@
public Object inclusionBegin(
String includeFile,
int offset,
- int inclusionBeginOffset) {
- Object inclusion = super.inclusionBegin(includeFile, offset, inclusionBeginOffset);
+ int inclusionBeginOffset, boolean local) {
+ Object inclusion = super.inclusionBegin(includeFile, offset, inclusionBeginOffset, local);
setLineNumber( (IOffsetable)inclusion, inclusionBeginOffset, true );
setLineNumber( (IOffsetable)inclusion, offset + includeFile.length() + 1, false );
return inclusion;
Index: model/org/eclipse/cdt/internal/core/model/Include.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Include.java,v
retrieving revision 1.2
diff -u -r1.2 Include.java
--- model/org/eclipse/cdt/internal/core/model/Include.java 5 Jun 2003 14:14:44 -0000 1.2
+++ model/org/eclipse/cdt/internal/core/model/Include.java 5 Jun 2003 19:50:25 -0000
@@ -10,8 +10,11 @@
public class Include extends SourceManipulation implements IInclude {
- public Include(ICElement parent, String name) {
+ private final boolean standard;
+
+ public Include(ICElement parent, String name, boolean isStandard) {
super(parent, name, CElement.C_INCLUDE);
+ standard = isStandard;
}
public String getIncludeName() {
@@ -19,7 +22,7 @@
}
public boolean isStandard() {
- return true;
+ return standard;
}
protected CElementInfo createElementInfo () {
Index: model/org/eclipse/cdt/internal/core/model/ModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ModelBuilder.java,v
retrieving revision 1.1
diff -u -r1.1 ModelBuilder.java
--- model/org/eclipse/cdt/internal/core/model/ModelBuilder.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/ModelBuilder.java 5 Jun 2003 19:50:25 -0000
@@ -28,7 +28,7 @@
}
public void includeDecl(String name, int startPos, int endPos, int startLine, int endLine) {
- Include elem= new Include(fCurrFile, name);
+ Include elem= new Include(fCurrFile, name, true ); // assume standard inclusion
elem.setPos(startPos, fixLength(startPos, endPos));
elem.setIdPos(startPos, fixLength(startPos, endPos));
elem.setLines(startLine, endLine);
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.48
diff -u -r1.48 ChangeLog
--- parser/ChangeLog 5 May 2003 20:31:08 -0000 1.48
+++ parser/ChangeLog 5 Jun 2003 19:50:25 -0000
@@ -1,3 +1,6 @@
+2003-06-05 John Camelon
+ Fix Bug 38380 "Include" class public methods fails JUnit tests
+
2003-05-05 John Camelon/Andrew Niefer
Added Symboltable infrastructure into main parser.
Index: parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.23
diff -u -r1.23 CModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 1 May 2003 19:46:41 -0000 1.23
+++ parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 5 Jun 2003 19:50:26 -0000
@@ -249,7 +249,7 @@
}
protected Include createInclusion(Parent parent, Inclusion inclusion){
// create element
- Include element = new Include((CElement)parent, inclusion.getName());
+ Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal());
// add to parent
parent.addChild((CElement) element);
// set position
Index: parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java,v
retrieving revision 1.24
diff -u -r1.24 ExpressionEvaluator.java
--- parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 5 May 2003 20:31:08 -0000 1.24
+++ parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 5 Jun 2003 19:50:26 -0000
@@ -125,7 +125,7 @@
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
*/
- public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
+ public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset, boolean local) {
return null;
}
/**
Index: parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java,v
retrieving revision 1.23
diff -u -r1.23 IParserCallback.java
--- parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java 5 May 2003 20:31:08 -0000 1.23
+++ parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java 5 Jun 2003 19:50:26 -0000
@@ -17,7 +17,7 @@
public Object translationUnitBegin();
public void translationUnitEnd(Object unit);
- public Object inclusionBegin(String includeFile, int nameBeginOffset, int inclusionBeginOffset);
+ 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);
Index: parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java,v
retrieving revision 1.23
diff -u -r1.23 NullParserCallback.java
--- parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java 5 May 2003 20:31:08 -0000 1.23
+++ parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java 5 Jun 2003 19:50:26 -0000
@@ -18,7 +18,7 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
*/
- public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
+ public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset, boolean local) {
return null;
}
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.26
diff -u -r1.26 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003 20:04:51 -0000 1.26
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 5 Jun 2003 19:50:27 -0000
@@ -1664,7 +1664,7 @@
if( callback != null )
{
offset = contextStack.getCurrentContext().getOffset() - f.length() - 1; // -1 for the end quote
- callback.inclusionEnd(callback.inclusionBegin( f, offset, beginningOffset ));
+ callback.inclusionEnd(callback.inclusionBegin( f, offset, beginningOffset, !useIncludePath ));
}
}
else