mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 16:56:04 +02:00
Removed most usage of internal classes in favor of public interfaces. Removed some invalid tests. Come code formating cleanups.
This commit is contained in:
parent
1fc9b37e74
commit
3b3e71a2a1
5 changed files with 289 additions and 593 deletions
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.testplugin.util.*;
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.*;
|
||||||
import org.eclipse.core.resources.*;
|
import org.eclipse.core.resources.*;
|
||||||
import org.eclipse.core.runtime.*;
|
import org.eclipse.core.runtime.*;
|
||||||
import org.eclipse.cdt.internal.core.model.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,109 +131,9 @@ public class ArchiveTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
* This is a simple test to make sure we can not create an Archive with
|
|
||||||
* a non-archive Ifile/IPath
|
|
||||||
* Note: This test is of questionable merit, as people should always be
|
|
||||||
* getting their binaries from the project, not creating them themselves
|
|
||||||
|
|
||||||
*/
|
|
||||||
public void testArchive() throws CoreException {
|
|
||||||
Archive myArchive;
|
|
||||||
boolean caught;
|
|
||||||
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, cfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("PR:23601 Created an archive with a C file", caught);
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, cpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a C file", caught);
|
|
||||||
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, objfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a .o file", caught);
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, objpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a .o file", caught);
|
|
||||||
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, exefile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a exe file", caught);
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, exepath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a exe file", caught);
|
|
||||||
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, libfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a .so file", caught);
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, libpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a .so file", caught);
|
|
||||||
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, archfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a .a file", !caught);
|
|
||||||
myArchive=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myArchive=new Archive(testProject, archpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an archive with a .a file", !caught);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void testGetBinaries() throws CoreException,FileNotFoundException {
|
public void testGetBinaries() throws CoreException,FileNotFoundException {
|
||||||
Archive myArchive;
|
IArchive myArchive;
|
||||||
IBinary[] bins;
|
IBinary[] bins;
|
||||||
ICElement[] elements;
|
ICElement[] elements;
|
||||||
ExpectedStrings expBin, expObj[];
|
ExpectedStrings expBin, expObj[];
|
||||||
|
@ -287,7 +187,7 @@ public class ArchiveTests extends TestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testIsArchive() throws CoreException,FileNotFoundException {
|
public void testIsArchive() throws CoreException,FileNotFoundException {
|
||||||
Archive myArchive;
|
IArchive myArchive;
|
||||||
myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
|
myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
|
||||||
|
|
||||||
assertTrue("A archive", myArchive.isArchive());
|
assertTrue("A archive", myArchive.isArchive());
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.testplugin.util.*;
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.*;
|
||||||
import org.eclipse.core.resources.*;
|
import org.eclipse.core.resources.*;
|
||||||
import org.eclipse.core.runtime.*;
|
import org.eclipse.core.runtime.*;
|
||||||
import org.eclipse.cdt.internal.core.model.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,112 +176,12 @@ public class BinaryTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
* This is a simple test to make sure we can not create a Binary with
|
|
||||||
* a non-binary Ifile/IPath
|
|
||||||
* Note: This test is of questionable merit, as people should always be
|
|
||||||
* getting their archives from the project, not creating them themselves
|
|
||||||
*/
|
|
||||||
public void testBinary() throws CoreException {
|
|
||||||
Binary myBinary;
|
|
||||||
boolean caught;
|
|
||||||
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, cfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("PR:23601 Created an Binary with a C file", caught);
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, cpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a C file", caught);
|
|
||||||
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, objfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue("Created an Binary with a .o file", !caught);
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, objpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a .o file", !caught);
|
|
||||||
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, exefile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a exe file", !caught);
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, exepath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a exe file", !caught);
|
|
||||||
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, libfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a .so file", caught);
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, libpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a .so file", caught);
|
|
||||||
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, archfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a .a file", !caught);
|
|
||||||
myBinary=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myBinary=new Binary(testProject, archpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an Binary with a .a file", !caught);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* Simple tests to make sure we can get all of a binarys children
|
* Simple tests to make sure we can get all of a binarys children
|
||||||
*/
|
*/
|
||||||
public void testGetChildren() throws CoreException,FileNotFoundException {
|
public void testGetChildren() throws CoreException,FileNotFoundException {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
ICElement[] elements;
|
ICElement[] elements;
|
||||||
ExpectedStrings expSyms;
|
ExpectedStrings expSyms;
|
||||||
String[] myStrings = {"atexit", "exit", "_init_libc", "printf", "_fini",
|
String[] myStrings = {"atexit", "exit", "_init_libc", "printf", "_fini",
|
||||||
|
@ -290,7 +190,7 @@ public class BinaryTests extends TestCase {
|
||||||
expSyms=new ExpectedStrings(myStrings);
|
expSyms=new ExpectedStrings(myStrings);
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Grab the Binary we want to test, and find all the elements in all
|
* Grab the IBinary we want to test, and find all the elements in all
|
||||||
* the binarie and make sure we get everything we expect.
|
* the binarie and make sure we get everything we expect.
|
||||||
*/
|
*/
|
||||||
myBinary=CProjectHelper.findBinary(testProject, "test_g");
|
myBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||||
|
@ -307,7 +207,7 @@ public class BinaryTests extends TestCase {
|
||||||
* A quick check to make sure the getBSS function works as expected.
|
* A quick check to make sure the getBSS function works as expected.
|
||||||
*/
|
*/
|
||||||
public void testGetBss(){
|
public void testGetBss(){
|
||||||
Binary bigBinary,littleBinary;
|
IBinary bigBinary,littleBinary;
|
||||||
bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||||
littleBinary=CProjectHelper.findBinary(testProject, "test_g");
|
littleBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||||
|
|
||||||
|
@ -318,7 +218,7 @@ public class BinaryTests extends TestCase {
|
||||||
* A quick check to make sure the getBSS function works as expected.
|
* A quick check to make sure the getBSS function works as expected.
|
||||||
*/
|
*/
|
||||||
public void testGetData(){
|
public void testGetData(){
|
||||||
Binary bigBinary,littleBinary;
|
IBinary bigBinary,littleBinary;
|
||||||
bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||||
littleBinary=CProjectHelper.findBinary(testProject, "test_g");
|
littleBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||||
if (false) {
|
if (false) {
|
||||||
|
@ -340,11 +240,11 @@ public class BinaryTests extends TestCase {
|
||||||
* This is not a in depth test at all.
|
* This is not a in depth test at all.
|
||||||
*/
|
*/
|
||||||
public void testGetCpu() {
|
public void testGetCpu() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||||
|
|
||||||
assertTrue("Expected: x86 Got: " + myBinary.getCPU(),myBinary.getCPU().equals("x86"));
|
assertTrue("Expected: x86 Got: " + myBinary.getCPU(),myBinary.getCPU().equals("x86"));
|
||||||
myBinary=new Binary(testProject, ppcexefile);
|
myBinary=CProjectHelper.findBinary(testProject, ppcexefile.toString());
|
||||||
assertTrue("Expected: ppcbe Got: " + myBinary.getCPU(),myBinary.getCPU().equals("ppcbe"));
|
assertTrue("Expected: ppcbe Got: " + myBinary.getCPU(),myBinary.getCPU().equals("ppcbe"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -353,7 +253,7 @@ public class BinaryTests extends TestCase {
|
||||||
* A set of simple tests to make sute getNeededSharedLibs seems to be sane
|
* A set of simple tests to make sute getNeededSharedLibs seems to be sane
|
||||||
*/
|
*/
|
||||||
public void testGetNeededSharedLibs() {
|
public void testGetNeededSharedLibs() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
String[] exelibs={"libsocket.so.2", "libc.so.2"};
|
String[] exelibs={"libsocket.so.2", "libc.so.2"};
|
||||||
String[] bigexelibs={"libc.so.2"};
|
String[] bigexelibs={"libc.so.2"};
|
||||||
String[] gotlibs;
|
String[] gotlibs;
|
||||||
|
@ -393,7 +293,7 @@ public class BinaryTests extends TestCase {
|
||||||
* Simple tests for the getSoname method;
|
* Simple tests for the getSoname method;
|
||||||
*/
|
*/
|
||||||
public void testGetSoname() {
|
public void testGetSoname() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
String name;
|
String name;
|
||||||
myBinary=CProjectHelper.findBinary(testProject, "test_g");
|
myBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||||
assertTrue(myBinary.getSoname().equals(""));
|
assertTrue(myBinary.getSoname().equals(""));
|
||||||
|
@ -410,9 +310,9 @@ public class BinaryTests extends TestCase {
|
||||||
* Simple tests for getText
|
* Simple tests for getText
|
||||||
*/
|
*/
|
||||||
public void testGetText() {
|
public void testGetText() {
|
||||||
Binary bigBinary,littleBinary;
|
IBinary bigBinary,littleBinary;
|
||||||
bigBinary=new Binary(testProject, bigexe);
|
bigBinary=CProjectHelper.findBinary(testProject, bigexe.toString());
|
||||||
littleBinary=new Binary(testProject, exefile);
|
littleBinary=CProjectHelper.findBinary(testProject, exefile.toString());
|
||||||
if (false) {
|
if (false) {
|
||||||
/****
|
/****
|
||||||
* Since there is no comment on this function, I have no idea what
|
* Since there is no comment on this function, I have no idea what
|
||||||
|
@ -431,7 +331,7 @@ public class BinaryTests extends TestCase {
|
||||||
* Simple tests for the hadDebug call
|
* Simple tests for the hadDebug call
|
||||||
*/
|
*/
|
||||||
public void testHasDebug() {
|
public void testHasDebug() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
myBinary = CProjectHelper.findBinary(testProject, "test_g");
|
myBinary = CProjectHelper.findBinary(testProject, "test_g");
|
||||||
assertTrue(myBinary.hasDebug());
|
assertTrue(myBinary.hasDebug());
|
||||||
myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
|
myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
|
||||||
|
@ -444,7 +344,7 @@ public class BinaryTests extends TestCase {
|
||||||
* Sanity - isBinary and isReadonly should always return true;
|
* Sanity - isBinary and isReadonly should always return true;
|
||||||
*/
|
*/
|
||||||
public void testisBinRead() {
|
public void testisBinRead() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
myBinary =CProjectHelper.findBinary(testProject, "test_g");
|
myBinary =CProjectHelper.findBinary(testProject, "test_g");
|
||||||
assertTrue(myBinary.isBinary());
|
assertTrue(myBinary.isBinary());
|
||||||
assertTrue(myBinary.isReadOnly());
|
assertTrue(myBinary.isReadOnly());
|
||||||
|
@ -455,7 +355,7 @@ public class BinaryTests extends TestCase {
|
||||||
* Quick tests to make sure isObject works as expected.
|
* Quick tests to make sure isObject works as expected.
|
||||||
*/
|
*/
|
||||||
public void testIsObject() {
|
public void testIsObject() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
||||||
assertTrue(myBinary.isObject());
|
assertTrue(myBinary.isObject());
|
||||||
|
|
||||||
|
@ -475,7 +375,7 @@ public class BinaryTests extends TestCase {
|
||||||
* Quick tests to make sure isSharedLib works as expected.
|
* Quick tests to make sure isSharedLib works as expected.
|
||||||
*/
|
*/
|
||||||
public void testIsSharedLib() {
|
public void testIsSharedLib() {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
|
|
||||||
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
||||||
assertTrue(!myBinary.isSharedLib());
|
assertTrue(!myBinary.isSharedLib());
|
||||||
|
@ -496,7 +396,7 @@ public class BinaryTests extends TestCase {
|
||||||
* Quick tests to make sure isExecutable works as expected.
|
* Quick tests to make sure isExecutable works as expected.
|
||||||
*/
|
*/
|
||||||
public void testIsExecutable() throws InterruptedException {
|
public void testIsExecutable() throws InterruptedException {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
||||||
assertTrue(!myBinary.isExecutable());
|
assertTrue(!myBinary.isExecutable());
|
||||||
|
|
||||||
|
@ -517,7 +417,7 @@ public class BinaryTests extends TestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testIsBinary() throws CoreException,FileNotFoundException,Exception {
|
public void testIsBinary() throws CoreException,FileNotFoundException,Exception {
|
||||||
Binary myBinary;
|
IBinary myBinary;
|
||||||
|
|
||||||
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||||
assertTrue("A Binary", myBinary.isBinary());
|
assertTrue("A Binary", myBinary.isBinary());
|
||||||
|
|
|
@ -10,8 +10,9 @@ package org.eclipse.cdt.core.model.tests;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.Flags;
|
||||||
import org.eclipse.cdt.internal.core.model.*;
|
import org.eclipse.cdt.internal.core.model.IConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Peter Graves
|
* @author Peter Graves
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
@ -18,7 +17,7 @@ import org.eclipse.cdt.testplugin.util.*;
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.*;
|
||||||
import org.eclipse.core.resources.*;
|
import org.eclipse.core.resources.*;
|
||||||
import org.eclipse.core.runtime.*;
|
import org.eclipse.core.runtime.*;
|
||||||
import org.eclipse.cdt.internal.core.model.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,101 +154,6 @@ public class TranslationUnitTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
* This is a simple test to make sure we can not create an TranslationUnit with
|
|
||||||
* a non-TranslationUnit Ifile/IPath
|
|
||||||
*/
|
|
||||||
public void testTranslationUnit() throws CoreException {
|
|
||||||
TranslationUnit myTranslationUnit;
|
|
||||||
boolean caught;
|
|
||||||
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, cfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a C file", !caught);
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, cpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a C file", !caught);
|
|
||||||
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, objfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("PR:23601 Created an TranslationUnit with a .o file", caught);
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, objpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a .o file", caught);
|
|
||||||
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, exefile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a exe file", caught);
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, exepath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a exe file", caught);
|
|
||||||
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, libfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a .so file", caught);
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, libpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a .so file", caught);
|
|
||||||
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, archfile);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a .a file", caught);
|
|
||||||
myTranslationUnit=null;
|
|
||||||
caught=false;
|
|
||||||
try {
|
|
||||||
myTranslationUnit=new TranslationUnit(testProject, archpath);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
caught=true;
|
|
||||||
}
|
|
||||||
assertTrue("Created an TranslationUnit with a .a file", caught);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@ -257,7 +161,7 @@ public class TranslationUnitTests extends TestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testIsTranslationUnit() throws CoreException,FileNotFoundException {
|
public void testIsTranslationUnit() throws CoreException,FileNotFoundException {
|
||||||
TranslationUnit myTranslationUnit;
|
ITranslationUnit myTranslationUnit;
|
||||||
|
|
||||||
myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
||||||
assertTrue("A TranslationUnit", myTranslationUnit.isTranslationUnit());
|
assertTrue("A TranslationUnit", myTranslationUnit.isTranslationUnit());
|
||||||
|
@ -269,7 +173,7 @@ public class TranslationUnitTests extends TestCase {
|
||||||
* basicly work
|
* basicly work
|
||||||
*/
|
*/
|
||||||
public void testGetChildern() {
|
public void testGetChildern() {
|
||||||
TranslationUnit myTranslationUnit;
|
ITranslationUnit myTranslationUnit;
|
||||||
ICElement[] elements;
|
ICElement[] elements;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
@ -292,8 +196,8 @@ public class TranslationUnitTests extends TestCase {
|
||||||
/***
|
/***
|
||||||
* Simple sanity tests for the getElement() call
|
* Simple sanity tests for the getElement() call
|
||||||
*/
|
*/
|
||||||
public void testGetElement() {
|
public void testGetElement() throws CModelException {
|
||||||
TranslationUnit myTranslationUnit;
|
ITranslationUnit myTranslationUnit;
|
||||||
ICElement myElement;
|
ICElement myElement;
|
||||||
Stack missing=new Stack();
|
Stack missing=new Stack();
|
||||||
int x;
|
int x;
|
||||||
|
@ -321,7 +225,7 @@ public class TranslationUnitTests extends TestCase {
|
||||||
* Simple sanity tests for the getElementAtLine() call
|
* Simple sanity tests for the getElementAtLine() call
|
||||||
*/
|
*/
|
||||||
public void testGetElementAtLine() throws CoreException {
|
public void testGetElementAtLine() throws CoreException {
|
||||||
TranslationUnit myTranslationUnit;
|
ITranslationUnit myTranslationUnit;
|
||||||
ICElement myElement;
|
ICElement myElement;
|
||||||
Stack missing=new Stack();
|
Stack missing=new Stack();
|
||||||
int x;
|
int x;
|
||||||
|
@ -355,13 +259,13 @@ public class TranslationUnitTests extends TestCase {
|
||||||
* Simple sanity tests for the getInclude call
|
* Simple sanity tests for the getInclude call
|
||||||
*/
|
*/
|
||||||
public void testGetInclude() {
|
public void testGetInclude() {
|
||||||
Include myInclude;
|
IInclude myInclude;
|
||||||
int x;
|
int x;
|
||||||
String includes[]={"stdio.h", "unistd.h"};
|
String includes[]={"stdio.h", "unistd.h"};
|
||||||
TranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
ITranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
||||||
|
|
||||||
for (x=0;x<includes.length;x++) {
|
for (x=0;x<includes.length;x++) {
|
||||||
myInclude=(Include)myTranslationUnit.getInclude(includes[x]);
|
myInclude=myTranslationUnit.getInclude(includes[x]);
|
||||||
if (myInclude==null)
|
if (myInclude==null)
|
||||||
fail("Unable to get include: " + includes[x]);
|
fail("Unable to get include: " + includes[x]);
|
||||||
else
|
else
|
||||||
|
@ -378,7 +282,7 @@ public class TranslationUnitTests extends TestCase {
|
||||||
String includes[]={"stdio.h", "unistd.h"};
|
String includes[]={"stdio.h", "unistd.h"};
|
||||||
ExpectedStrings myExp= new ExpectedStrings(includes);
|
ExpectedStrings myExp= new ExpectedStrings(includes);
|
||||||
int x;
|
int x;
|
||||||
TranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
ITranslationUnit myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
||||||
fail("PR:23478 Unable to test because we can't get the name of an include file");
|
fail("PR:23478 Unable to test because we can't get the name of an include file");
|
||||||
|
|
||||||
myIncludes=myTranslationUnit.getIncludes();
|
myIncludes=myTranslationUnit.getIncludes();
|
||||||
|
|
|
@ -7,14 +7,13 @@ import java.util.zip.ZipFile;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICFolder;
|
import org.eclipse.cdt.core.model.ICFolder;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.model.Archive;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.model.Binary;
|
|
||||||
import org.eclipse.cdt.internal.core.model.BinaryContainer;
|
|
||||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.core.model.ArchiveContainer;
|
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
@ -36,278 +35,270 @@ import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
|
||||||
* Helper methods to set up a IJavaProject.
|
* Helper methods to set up a IJavaProject.
|
||||||
*/
|
*/
|
||||||
public class CProjectHelper {
|
public class CProjectHelper {
|
||||||
|
|
||||||
public static final IPath RT_STUBS= new Path("testresources/rtstubs.jar");
|
public static final IPath RT_STUBS= new Path("testresources/rtstubs.jar");
|
||||||
public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip");
|
public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip");
|
||||||
|
|
||||||
public static final IPath MYLIB= new Path("testresources/mylib.jar");
|
public static final IPath MYLIB= new Path("testresources/mylib.jar");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ICProject.
|
* Creates a ICProject.
|
||||||
*/
|
*/
|
||||||
public static ICProject createCProject(String projectName, String binFolderName) throws CoreException {
|
public static ICProject createCProject(String projectName, String binFolderName) throws CoreException {
|
||||||
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IProject project= root.getProject(projectName);
|
IProject project= root.getProject(projectName);
|
||||||
if (!project.exists()) {
|
if (!project.exists()) {
|
||||||
project.create(null);
|
project.create(null);
|
||||||
} else {
|
} else {
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!project.isOpen()) {
|
if (!project.isOpen()) {
|
||||||
project.open(null);
|
project.open(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICProject cproject = CCorePlugin.getDefault().getCoreModel().create(project);
|
ICProject cproject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||||
|
|
||||||
return cproject;
|
return cproject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a ICProject.
|
* Removes a ICProject.
|
||||||
*/
|
*/
|
||||||
public static void delete(ICProject cproject) throws CoreException {
|
public static void delete(ICProject cproject) throws CoreException {
|
||||||
performDummySearch();
|
performDummySearch();
|
||||||
cproject.getProject().delete(true, true, null);
|
cproject.getProject().delete(true, true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performDummySearch() throws CModelException {
|
public static void performDummySearch() throws CModelException {
|
||||||
/* SearchEngine().searchAllTypeNames(
|
/* SearchEngine().searchAllTypeNames(
|
||||||
ResourcesPlugin.getWorkspace(),
|
ResourcesPlugin.getWorkspace(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
IJavaSearchConstants.EXACT_MATCH,
|
IJavaSearchConstants.EXACT_MATCH,
|
||||||
IJavaSearchConstants.CASE_SENSITIVE,
|
IJavaSearchConstants.CASE_SENSITIVE,
|
||||||
IJavaSearchConstants.CLASS,
|
IJavaSearchConstants.CLASS,
|
||||||
SearchEngine.createJavaSearchScope(new IJavaElement[0]),
|
SearchEngine.createJavaSearchScope(new IJavaElement[0]),
|
||||||
new Requestor(),
|
new Requestor(),
|
||||||
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||||
null); */
|
null); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a source container to a ICProject.
|
* Adds a source container to a ICProject.
|
||||||
*/
|
*/
|
||||||
public static ICFolder addSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
public static ICFolder addSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
||||||
IProject project= cproject.getProject();
|
IProject project= cproject.getProject();
|
||||||
IContainer container= null;
|
IContainer container= null;
|
||||||
if (containerName == null || containerName.length() == 0) {
|
if (containerName == null || containerName.length() == 0) {
|
||||||
container= project;
|
container= project;
|
||||||
} else {
|
} else {
|
||||||
IFolder folder= project.getFolder(containerName);
|
IFolder folder= project.getFolder(containerName);
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.create(false, true, null);
|
folder.create(false, true, null);
|
||||||
}
|
}
|
||||||
container= folder;
|
container= folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ICFolder)container;
|
return (ICFolder)container;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a source container to a ICProject and imports all files contained
|
* Adds a source container to a ICProject and imports all files contained
|
||||||
* in the given Zip file.
|
* in the given Zip file.
|
||||||
*/
|
*/
|
||||||
public static ICFolder addSourceContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile) throws InvocationTargetException, CoreException {
|
public static ICFolder addSourceContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile) throws InvocationTargetException, CoreException {
|
||||||
ICFolder root= addSourceContainer(cproject, containerName);
|
ICFolder root= addSourceContainer(cproject, containerName);
|
||||||
importFilesFromZip(zipFile, root.getPath(), null);
|
importFilesFromZip(zipFile, root.getPath(), null);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a source folder from a IJavaProject.
|
* Removes a source folder from a IJavaProject.
|
||||||
*/
|
*/
|
||||||
public static void removeSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
public static void removeSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
||||||
IFolder folder= cproject.getProject().getFolder(containerName);
|
IFolder folder= cproject.getProject().getFolder(containerName);
|
||||||
folder.delete(true, null);
|
folder.delete(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a required project entry.
|
* Adds a required project entry.
|
||||||
*/
|
*/
|
||||||
public static void addRequiredProject(ICProject cproject, ICProject required) throws CModelException {
|
public static void addRequiredProject(ICProject cproject, ICProject required) throws CModelException {
|
||||||
//IClasspathEntry cpe= JavaCore.newProjectEntry(required.getProject().getFullPath());
|
//IClasspathEntry cpe= JavaCore.newProjectEntry(required.getProject().getFullPath());
|
||||||
//addToClasspath(cproject, cpe);
|
//addToClasspath(cproject, cpe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find an archive with the given name in the workspace
|
* Attempts to find an archive with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static Archive findArchive(ICProject testProject,String name) {
|
public static IArchive findArchive(ICProject testProject,String name) {
|
||||||
int x;
|
int x;
|
||||||
IArchive[] myArchives;
|
IArchive[] myArchives;
|
||||||
ArchiveContainer archCont;
|
IArchiveContainer archCont;
|
||||||
/***
|
/***
|
||||||
* Since ArchiveContainer.getArchives does not wait until
|
* Since ArchiveContainer.getArchives does not wait until
|
||||||
* all the archives in the project have been parsed before
|
* all the archives in the project have been parsed before
|
||||||
* returning the list, we have to do a sync ArchiveContainer.getChildren
|
* returning the list, we have to do a sync ArchiveContainer.getChildren
|
||||||
* first to make sure we find all the archives.
|
* first to make sure we find all the archives.
|
||||||
*/
|
*/
|
||||||
archCont=(ArchiveContainer)testProject.getArchiveContainer();
|
archCont=testProject.getArchiveContainer();
|
||||||
archCont.getChildren(true);
|
|
||||||
myArchives=testProject.getArchiveContainer().getArchives();
|
|
||||||
if (myArchives.length<1)
|
|
||||||
return(null);
|
|
||||||
for (x=0;x<myArchives.length;x++) {
|
|
||||||
if (myArchives[x].getElementName().equals(name))
|
|
||||||
if (myArchives[x] instanceof Archive) {
|
|
||||||
return((Archive) myArchives[x]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Attempts to find a binary with the given name in the workspace
|
|
||||||
*/
|
|
||||||
public static Binary findBinary(ICProject testProject,String name) {
|
|
||||||
BinaryContainer binCont;
|
|
||||||
int x;
|
|
||||||
IBinary[] myBinaries;
|
|
||||||
binCont=(BinaryContainer)testProject.getBinaryContainer();
|
|
||||||
/* Make sure we wait for the childern to be parsed, see comment about
|
|
||||||
* ArchiveContainer.getArchives() above */
|
|
||||||
binCont.getChildren(true);
|
|
||||||
myBinaries=binCont.getBinaries();
|
|
||||||
if (myBinaries.length<1)
|
|
||||||
return(null);
|
|
||||||
for (x=0;x<myBinaries.length;x++) {
|
|
||||||
if (myBinaries[x].getElementName().equals(name))
|
|
||||||
if (myBinaries[x] instanceof Binary) {
|
|
||||||
return((Binary) myBinaries[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
myArchives=archCont.getArchives();
|
||||||
* Attempts to find an object with the given name in the workspace
|
if (myArchives.length<1)
|
||||||
*/
|
return(null);
|
||||||
public static Binary findObject(ICProject testProject,String name) {
|
for (x=0;x<myArchives.length;x++) {
|
||||||
int x;
|
if (myArchives[x].getElementName().equals(name))
|
||||||
ICElement[] myElements;
|
return(myArchives[x]);
|
||||||
myElements=testProject.getChildren();
|
|
||||||
if (myElements.length<1)
|
}
|
||||||
return(null);
|
return(null);
|
||||||
for (x=0;x<myElements.length;x++) {
|
}
|
||||||
if (myElements[x].getElementName().equals(name))
|
/**
|
||||||
if (myElements[x] instanceof ICElement) {
|
* Attempts to find a binary with the given name in the workspace
|
||||||
if (myElements[x] instanceof Binary) {
|
*/
|
||||||
return((Binary) myElements[x]);
|
public static IBinary findBinary(ICProject testProject,String name) {
|
||||||
}
|
IBinaryContainer binCont;
|
||||||
}
|
int x;
|
||||||
}
|
IBinary[] myBinaries;
|
||||||
return(null);
|
binCont=testProject.getBinaryContainer();
|
||||||
}
|
|
||||||
/**
|
myBinaries=binCont.getBinaries();
|
||||||
* Attempts to find a TranslationUnit with the given name in the workspace
|
if (myBinaries.length<1)
|
||||||
*/
|
return(null);
|
||||||
public static TranslationUnit findTranslationUnit(ICProject testProject,String name) {
|
for (x=0;x<myBinaries.length;x++) {
|
||||||
int x;
|
if (myBinaries[x].getElementName().equals(name))
|
||||||
ICElement[] myElements;
|
return(myBinaries[x]);
|
||||||
myElements=testProject.getChildren();
|
|
||||||
if (myElements.length<1)
|
|
||||||
return(null);
|
}
|
||||||
for (x=0;x<myElements.length;x++) {
|
return(null);
|
||||||
if (myElements[x].getElementName().equals(name))
|
}
|
||||||
if (myElements[x] instanceof ICElement) {
|
|
||||||
if (myElements[x] instanceof TranslationUnit) {
|
/**
|
||||||
return((TranslationUnit) myElements[x]);
|
* Attempts to find an object with the given name in the workspace
|
||||||
}
|
*/
|
||||||
}
|
public static IBinary findObject(ICProject testProject,String name) {
|
||||||
}
|
int x;
|
||||||
return(null);
|
ICElement[] myElements;
|
||||||
}
|
myElements=testProject.getChildren();
|
||||||
|
if (myElements.length<1)
|
||||||
|
return(null);
|
||||||
|
for (x=0;x<myElements.length;x++) {
|
||||||
|
if (myElements[x].getElementName().equals(name))
|
||||||
|
if (myElements[x] instanceof ICElement) {
|
||||||
|
if (myElements[x] instanceof IBinary) {
|
||||||
|
return((IBinary) myElements[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Attempts to find a TranslationUnit with the given name in the workspace
|
||||||
|
*/
|
||||||
|
public static ITranslationUnit findTranslationUnit(ICProject testProject,String name) {
|
||||||
|
int x;
|
||||||
|
ICElement[] myElements;
|
||||||
|
myElements=testProject.getChildren();
|
||||||
|
if (myElements.length<1)
|
||||||
|
return(null);
|
||||||
|
for (x=0;x<myElements.length;x++) {
|
||||||
|
if (myElements[x].getElementName().equals(name))
|
||||||
|
if (myElements[x] instanceof ICElement) {
|
||||||
|
if (myElements[x] instanceof ITranslationUnit) {
|
||||||
|
return((ITranslationUnit) myElements[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find an element with the given name in the workspace
|
* Attempts to find an element with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static ICElement findElement(ICProject testProject,String name) {
|
public static ICElement findElement(ICProject testProject,String name) {
|
||||||
int x;
|
int x;
|
||||||
ICElement[] myElements;
|
ICElement[] myElements;
|
||||||
myElements=testProject.getChildren();
|
myElements=testProject.getChildren();
|
||||||
if (myElements.length<1)
|
if (myElements.length<1)
|
||||||
return(null);
|
return(null);
|
||||||
for (x=0;x<myElements.length;x++) {
|
for (x=0;x<myElements.length;x++) {
|
||||||
if (myElements[x].getElementName().equals(name))
|
if (myElements[x].getElementName().equals(name))
|
||||||
if (myElements[x] instanceof ICElement) {
|
if (myElements[x] instanceof ICElement) {
|
||||||
return((ICElement) myElements[x]);
|
return((ICElement) myElements[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to find rt.jar
|
* Try to find rt.jar
|
||||||
*/
|
*/
|
||||||
public static IPath[] findRtJar() {
|
public static IPath[] findRtJar() {
|
||||||
File rtStubs= CTestPlugin.getDefault().getFileInPlugin(RT_STUBS);
|
File rtStubs= CTestPlugin.getDefault().getFileInPlugin(RT_STUBS);
|
||||||
if (rtStubs != null && rtStubs.exists()) {
|
if (rtStubs != null && rtStubs.exists()) {
|
||||||
return new IPath[] {
|
return new IPath[] {
|
||||||
new Path(rtStubs.getPath()),
|
new Path(rtStubs.getPath()),
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IVMInstall vmInstall= JavaRuntime.getDefaultVMInstall();
|
IVMInstall vmInstall= JavaRuntime.getDefaultVMInstall();
|
||||||
if (vmInstall != null) {
|
if (vmInstall != null) {
|
||||||
LibraryLocation loc= vmInstall.getVMInstallType().getDefaultLibraryLocation(vmInstall.getInstallLocation());
|
LibraryLocation loc= vmInstall.getVMInstallType().getDefaultLibraryLocation(vmInstall.getInstallLocation());
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
return new IPath[] {
|
return new IPath[] {
|
||||||
new Path(loc.getSystemLibrary().getPath()),
|
new Path(loc.getSystemLibrary().getPath()),
|
||||||
new Path(loc.getSystemLibrarySource().getPath()),
|
new Path(loc.getSystemLibrarySource().getPath()),
|
||||||
loc.getPackageRootPath()
|
loc.getPackageRootPath()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
||||||
IProjectDescription description = proj.getDescription();
|
IProjectDescription description = proj.getDescription();
|
||||||
String[] prevNatures= description.getNatureIds();
|
String[] prevNatures= description.getNatureIds();
|
||||||
String[] newNatures= new String[prevNatures.length + 1];
|
String[] newNatures= new String[prevNatures.length + 1];
|
||||||
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
|
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
|
||||||
newNatures[prevNatures.length]= natureId;
|
newNatures[prevNatures.length]= natureId;
|
||||||
description.setNatureIds(newNatures);
|
description.setNatureIds(newNatures);
|
||||||
proj.setDescription(description, monitor);
|
proj.setDescription(description, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
|
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
|
||||||
ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
|
ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
|
||||||
try {
|
try {
|
||||||
ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
|
ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
|
||||||
op.run(monitor);
|
op.run(monitor);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// should not happen
|
// should not happen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
||||||
public String queryOverwrite(String file) {
|
public String queryOverwrite(String file) {
|
||||||
return ALL;
|
return ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue