Browse Source

polish

tags/V1_9_2RC3
Andy Clement 5 years ago
parent
commit
de731d49ba

ajde.core/.isJava5 → ajde.core/.isJava8 View File


+ 14
- 7
ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java View File

@@ -223,10 +223,12 @@ public class AjdeCoreBuildManager {
if (configFile.exists() && configFile.isFile()) {
args = new String[] { "@" + configFile.getAbsolutePath() };
} else {
List<String> l = compilerConfig.getProjectSourceFiles();
if (l == null) {
List<String> projectSourceFiles = compilerConfig.getProjectSourceFiles();
if (projectSourceFiles == null) {
return null;
}
List<String> l = new ArrayList<>();
l.addAll(projectSourceFiles);
// If the processor options are specified build the command line options for the JDT compiler to see
String processor = compilerConfig.getProcessor();
if (processor != null && processor.length() != 0) {
@@ -238,20 +240,25 @@ public class AjdeCoreBuildManager {
l.add("-processorpath");
l.add(processorPath);
}
if (compilerConfig.getOutputLocationManager() != null &&
compilerConfig.getOutputLocationManager().getDefaultOutputLocation() != null) {
l.add("-d");
l.add(compilerConfig.getOutputLocationManager().getDefaultOutputLocation().toString());
}
List<String> xmlfiles = compilerConfig.getProjectXmlConfigFiles();
if (xmlfiles != null && !xmlfiles.isEmpty()) {
args = new String[l.size() + xmlfiles.size() + 1];
// TODO speedup
int p = 0;
for (int i = 0; i < l.size(); i++) {
args[p++] = (String) l.get(i);
args[p++] = l.get(i);
}
for (int i = 0; i < xmlfiles.size(); i++) {
args[p++] = (String) xmlfiles.get(i);
args[p++] = xmlfiles.get(i);
}
args[p++] = "-xmlConfigured";
} else {
args = (String[]) l.toArray(new String[l.size()]);
args = l.toArray(new String[l.size()]);
}
}

@@ -320,7 +327,7 @@ public class AjdeCoreBuildManager {
// Process the JAVA OPTIONS MAP
Map<String,String> jom = compilerConfig.getJavaOptionsMap();
if (jom != null) {
String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
String version = jom.get(CompilerOptions.OPTION_Compliance);
if (version != null && !version.equals(CompilerOptions.VERSION_1_4)) {
config.setBehaveInJava5Way(true);
}
@@ -383,7 +390,7 @@ public class AjdeCoreBuildManager {
} else {
tokens.addAll(tokenizeString(nonStdOptions));
}
String[] args = (String[]) tokens.toArray(new String[] {});
String[] args = tokens.toArray(new String[] {});

// set the non-standard options in an alternate build config
// (we don't want to lose the settings we already have)

+ 12
- 3
ajde.core/testsrc/org/aspectj/ajde/core/TestOutputLocationManager.java View File

@@ -27,28 +27,31 @@ public class TestOutputLocationManager implements IOutputLocationManager {
private File classOutputLoc;
private File resourceOutputLoc;
private List<File> allOutputLocations;
private Map inpathMap = Collections.EMPTY_MAP;
private Map<File,String> inpathMap = Collections.emptyMap();

public TestOutputLocationManager(String testProjectPath) {
this.testProjectOutputPath = testProjectPath + File.separator + "bin";
}

public TestOutputLocationManager(String string, Map inpathMap) {
public TestOutputLocationManager(String string, Map<File,String> inpathMap) {
this(string);
this.inpathMap = inpathMap;
}

@Override
public File getOutputLocationForClass(File compilationUnit) {
initLocations();
return classOutputLoc;
}

@Override
public File getOutputLocationForResource(File resource) {
initLocations();
return resourceOutputLoc;
}

public Map getInpathMap() {
@Override
public Map<File,String> getInpathMap() {
return inpathMap;
}

@@ -61,6 +64,7 @@ public class TestOutputLocationManager implements IOutputLocationManager {
resourceOutputLoc = f;
}

@Override
public List<File> getAllOutputLocations() {
if (allOutputLocations == null) {
allOutputLocations = new ArrayList<File>();
@@ -73,6 +77,7 @@ public class TestOutputLocationManager implements IOutputLocationManager {
return allOutputLocations;
}

@Override
public File getDefaultOutputLocation() {
initLocations();
return classOutputLoc;
@@ -87,16 +92,20 @@ public class TestOutputLocationManager implements IOutputLocationManager {
}
}

@Override
public String getSourceFolderForFile(File sourceFile) {
return null;
}

@Override
public void reportFileWrite(String outputfile, int filetype) {
}

@Override
public void reportFileRemove(String outputfile, int filetype) {
}

@Override
public int discoverChangesSince(File dir, long buildtime) {
// TODO Auto-generated method stub
return 0;

+ 8
- 6
ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java View File

@@ -35,6 +35,7 @@ public class AjConfigTests extends AjdeCoreTestCase {
private TestCompilerConfiguration compilerConfig;
private AjdeCoreBuildManager ajdeBuildManager;

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("SimpleProject");
@@ -42,6 +43,7 @@ public class AjConfigTests extends AjdeCoreTestCase {
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
ajdeBuildManager = null;
@@ -52,8 +54,8 @@ public class AjConfigTests extends AjdeCoreTestCase {
Map<String,String> options = JavaOptions.getDefaultJavaOptions();
options.put(JavaOptions.WARN_DEPRECATION, JavaOptions.WARNING);
compilerConfig.setJavaOptions(options);
Map found = genAjBuildConfig().getOptions().getMap();
String warning = (String) found.get(JavaOptions.WARN_DEPRECATION);
Map<String,String> found = genAjBuildConfig().getOptions().getMap();
String warning = found.get(JavaOptions.WARN_DEPRECATION);
assertEquals("expected to be warning on deprecation but found setting " + " was " + warning, JavaOptions.WARNING, warning);
}

@@ -136,7 +138,7 @@ public class AjConfigTests extends AjdeCoreTestCase {
for (Iterator<String> i = found.keySet().iterator(); i.hasNext();) {
String resource = i.next();
assertEquals("expected to find resource with name newFile.txt but " + "found " + resource, "newFile.txt", resource);
File from = (File) buildConfig.getSourcePathResources().get(resource);
File from = buildConfig.getSourcePathResources().get(resource);
assertEquals("expected to find resource with file " + getWorkingDir() + "but found " + from, getWorkingDir(), from);
}
}
@@ -146,7 +148,7 @@ public class AjConfigTests extends AjdeCoreTestCase {
List<String> found = genAjBuildConfig().getClasspath();
StringBuffer sb = new StringBuffer();
for (Iterator<String> iterator = found.iterator(); iterator.hasNext();) {
String name = (String) iterator.next();
String name = iterator.next();
sb.append(name);
if (iterator.hasNext()) {
sb.append(File.pathSeparator);
@@ -182,11 +184,11 @@ public class AjConfigTests extends AjdeCoreTestCase {

public void testProjectSourceFiles() throws IOException {
String f = getAbsoluteProjectDir() + File.separator + "C.java";
List files = new ArrayList();
List<String> files = new ArrayList<>();
files.add(f);
compilerConfig.setProjectSourceFiles(files);
AjBuildConfig buildConfig = genAjBuildConfig();
String found = ((File) buildConfig.getFiles().get(0)).getCanonicalPath();// AbsolutePath();
String found = buildConfig.getFiles().get(0).getCanonicalPath();// AbsolutePath();
assertEquals("expected source file " + f + ", but found " + found, f, found);
}


+ 6
- 3
ajde.core/testsrc/org/aspectj/ajde/core/tests/InpathTests.java View File

@@ -31,6 +31,7 @@ import org.aspectj.util.FileUtil;
public class InpathTests extends AjdeCoreTestCase {

public static final FileFilter aspectjResourceFileFilter = new FileFilter() {
@Override
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
return (!name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"));
@@ -49,6 +50,7 @@ public class InpathTests extends AjdeCoreTestCase {
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("InpathTest");
@@ -56,6 +58,7 @@ public class InpathTests extends AjdeCoreTestCase {
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
@@ -258,7 +261,7 @@ public class InpathTests extends AjdeCoreTestCase {
* Ensure -outjar contains all non-Java resouces from source and injars
*/
public void compareSourceToOutjar(String indirName, File outjarFile) {
HashSet resources = new HashSet();
HashSet<String> resources = new HashSet<>();
listSourceResources(indirName, resources);

try {
@@ -285,7 +288,7 @@ public class InpathTests extends AjdeCoreTestCase {
/*
* Ensure bin contains all non-Java resouces from source and injars
*/
public void compareIndirToBin(File indirFile, String sourceDir, String outdirName, Set expectedOutdirContents) {
public void compareIndirToBin(File indirFile, String sourceDir, String outdirName, Set<String> expectedOutdirContents) {

// byte[] inManifest = null;

@@ -302,7 +305,7 @@ public class InpathTests extends AjdeCoreTestCase {
assertTrue("Missing resources: " + expectedOutdirContents.toString(), expectedOutdirContents.isEmpty());
}

private void listSourceResources(String indirName, Set resources) {
private void listSourceResources(String indirName, Set<String> resources) {
File srcBase = openFile(indirName);
File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter);
for (int i = 0; i < fromResources.length; i++) {

+ 11
- 8
ajde.core/testsrc/org/aspectj/ajde/core/tests/ResourceCopyTests.java View File

@@ -45,6 +45,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {

private String[] config2 = new String[] { "src" + File.separator + "aspects" + File.separator + "Logging.java" };

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject(PROJECT_DIR);
@@ -52,6 +53,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
@@ -91,9 +93,9 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
doBuild(true);
assertFalse("Expected compiler errors or warnings but didn't find any", handler.getMessages().isEmpty());

List msgs = handler.getMessages();
List<TestMessageHandler.TestMessage> msgs = handler.getMessages();
String exp = "duplicate resource: ";
String found = ((TestMessageHandler.TestMessage) msgs.get(0)).getContainedMessage().getMessage();
String found = msgs.get(0).getContainedMessage().getMessage();
assertTrue("Expected message to start with 'duplicate resource:' but found" + " message " + found, found.startsWith(exp));
compareJars(injar1, "src", outjar);
}
@@ -150,7 +152,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
File binBase = openFile(outdirName);
File[] toResources = FileUtil.listFiles(binBase, aspectjResourceFileFilter);

HashSet resources = new HashSet();
HashSet<String> resources = new HashSet<>();
listSourceResources(indirName, resources);

for (int i = 0; i < toResources.length; i++) {
@@ -162,7 +164,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
}

private void listSourceResources(String indirName, Set resources) {
private void listSourceResources(String indirName, Set<String> resources) {
File srcBase = openFile(indirName);
File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter);
for (int i = 0; i < fromResources.length; i++) {
@@ -174,6 +176,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
}

public static final FileFilter aspectjResourceFileFilter = new FileFilter() {
@Override
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
boolean isCVSRelated = name.indexOf("/cvs/") != -1;
@@ -186,7 +189,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
*/
public void compareJars(File injarFile, String indirName, File outjarFile) {

HashSet resources = new HashSet();
HashSet<String> resources = new HashSet<>();

try {
assertTrue(
@@ -224,7 +227,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
* Ensure -outjar conatins all non-Java resouces from source and injars
*/
public void compareSourceToOutjar(String indirName, File outjarFile) {
HashSet resources = new HashSet();
HashSet<String> resources = new HashSet<>();
listSourceResources(indirName, resources);

try {
@@ -252,7 +255,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
*/
public void compareInjarsToBin(File injarFile, String indirName, String outdirName) {

HashSet resources = new HashSet();
HashSet<String> resources = new HashSet<>();

try {
byte[] inManifest = listJarResources(injarFile, resources, false);
@@ -286,7 +289,7 @@ public class ResourceCopyTests extends AjdeCoreTestCase {
* @param wantDirectories should any directories found in the jar be included
* @return the byte data for any discovered manifest
*/
private byte[] listJarResources(File injarFile, Set resources, boolean wantDirectories) {
private byte[] listJarResources(File injarFile, Set<String> resources, boolean wantDirectories) {
byte[] manifest = null;

try {

+ 8
- 6
ajde.core/testsrc/org/aspectj/ajde/core/tests/ReweavableTests.java View File

@@ -36,6 +36,7 @@ public class ReweavableTests extends AjdeCoreTestCase {
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("ReweavableTest");
@@ -44,6 +45,7 @@ public class ReweavableTests extends AjdeCoreTestCase {
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
@@ -220,7 +222,7 @@ public class ReweavableTests extends AjdeCoreTestCase {

if (debugTests)
System.out.println("\ntestReweavableSimpleCompile: Building with Reweavable2.lst");
Set paths = new HashSet();
Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
String[] newFiles = new String[] { "SecondAspect.aj" };
@@ -269,7 +271,7 @@ public class ReweavableTests extends AjdeCoreTestCase {

if (debugTests)
System.out.println("\ntestForReweavableSimpleErrorCompile: Building with Reweavable2.lst");
Set paths = new HashSet();
Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
String[] newFiles = new String[] { "SecondAspect.aj" };
@@ -319,10 +321,10 @@ public class ReweavableTests extends AjdeCoreTestCase {

if (debugTests)
System.out.println("\ntestErrorScenario2: Building with TJP2.lst");
Set paths = new HashSet();
Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
compilerConfig.setProjectSourceFiles(new ArrayList());
compilerConfig.setProjectSourceFiles(new ArrayList<String>());
doBuild(true);

String expMessage = "aspect tjp.GetInfo cannot be found when reweaving tjp.Demo";
@@ -351,10 +353,10 @@ public class ReweavableTests extends AjdeCoreTestCase {

if (debugTests)
System.out.println("\ntestWorkingScenario2: Building with TJP2.lst");
Set paths = new HashSet();
Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
compilerConfig.setProjectSourceFiles(new ArrayList());
compilerConfig.setProjectSourceFiles(new ArrayList<String>());
doBuild(true);

String expMessage = "successfully verified type tjp.GetInfo exists";

+ 15
- 14
ajde.core/testsrc/org/aspectj/ajde/core/tests/ShowWeaveMessagesTests.java View File

@@ -83,6 +83,7 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject(PROJECT_DIR);
@@ -92,6 +93,7 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
compilerConfig.setNonStandardOptions("-showWeaveInfo");
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
@@ -303,10 +305,10 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
public void testWeaveMessagesBinaryITDNoDebugInfo() {
if (debugTests)
System.out.println("\ntestWeaveMessagesBinaryITD: Simple.jar + AspectITD.jar");
Set inpath = new HashSet();
Set<File> inpath = new HashSet<>();
inpath.add(openFile("Simple_nodebug.jar"));
compilerConfig.setInpath(inpath);
Set aspectpath = new HashSet();
Set<File> aspectpath = new HashSet<>();
aspectpath.add(openFile("AspectITD_nodebug.jar"));
compilerConfig.setAspectPath(aspectpath);
doBuild();
@@ -360,7 +362,7 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
* Compare weaving messages with what is in the file
*/
private void compareWeaveMessages(File f) {
List fileContents = new ArrayList();
List<String> fileContents = new ArrayList<>();
BufferedReader fr;
try {
// Load the file in
@@ -368,14 +370,14 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
String line = null;
while ((line = fr.readLine()) != null)
fileContents.add(line);
List originalFileContents = new ArrayList();
List<String> originalFileContents = new ArrayList<>();
originalFileContents.addAll(fileContents);

// See if the messages match
int msgCount = 0;
List l = handler.getMessages();
for (Iterator iter = l.iterator(); iter.hasNext();) {
IMessage msg = ((TestMessageHandler.TestMessage) iter.next()).getContainedMessage();
List<TestMessageHandler.TestMessage> l = handler.getMessages();
for (Iterator<TestMessageHandler.TestMessage> iter = l.iterator(); iter.hasNext();) {
IMessage msg = iter.next().getContainedMessage();
if (debugTests)
System.out.println("Looking at [" + msg + "]");
if (msg.getKind().equals(IMessage.WEAVEINFO)) {
@@ -396,10 +398,9 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
}
}

private String stringify(List l) {
private String stringify(List<String> l) {
StringBuffer result = new StringBuffer();
for (Iterator iter = l.iterator(); iter.hasNext();) {
String str = (String) iter.next();
for (String str: l) {
result.append(str);
result.append("\n");
}
@@ -414,9 +415,9 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
FileWriter fw;
try {
fw = new FileWriter(f);
List l = handler.getMessages();
for (Iterator iter = l.iterator(); iter.hasNext();) {
IMessage msg = ((TestMessageHandler.TestMessage) iter.next()).getContainedMessage();
List<TestMessageHandler.TestMessage> l = handler.getMessages();
for (Iterator<TestMessageHandler.TestMessage> iter = l.iterator(); iter.hasNext();) {
IMessage msg = iter.next().getContainedMessage();
if (msg.getKind().equals(IMessage.WEAVEINFO)) {
fw.write(msg.getMessage() + "\n");
}
@@ -428,7 +429,7 @@ public class ShowWeaveMessagesTests extends AjdeCoreTestCase {
}

private void setRunIn15Mode() {
Map m = new Hashtable();
Map<String, String> m = new Hashtable<>();
m.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_15);
m.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_15);
m.put(JavaOptions.TARGET_COMPATIBILITY_LEVEL, JavaOptions.VERSION_15);

+ 10
- 8
ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmRelationshipsTests.java View File

@@ -28,6 +28,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {

private TestCompilerConfiguration compilerConfig;

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("coverage");
@@ -37,6 +38,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
manager = AsmManager.lastActiveStructureModel;
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
compilerConfig = null;
@@ -77,7 +79,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
assertNotNull(dp);
/* List relations = */manager.getRelationshipMap().get(dp);

List rels = manager.getRelationshipMap().get(dp);
List<IRelationship> rels = manager.getRelationshipMap().get(dp);
assertTrue(rels.size() > 0);

// assertTrue(rel.getTargets().size() > 0);
@@ -115,7 +117,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.DECLARE, forwardRelName);
assertTrue(rel.getTargets().size() > 0);
String handle = (String) rel.getTargets().get(0);
String handle = rel.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);

IProgramElement clazz = manager.getHierarchy().findElementForType(null, toType);
@@ -124,7 +126,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.CODE, set);
assertNotNull(setNode);
IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.DECLARE, backRelName);
String handle2 = (String) rel2.getTargets().get(0);
String handle2 = rel2.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}

@@ -138,7 +140,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
for (Iterator<String> it = rel.getTargets().iterator(); it.hasNext();) {
String currHandle = (String) it.next();
String currHandle = it.next();
if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(to))
return;
}
@@ -154,7 +156,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
String handle = (String) rel.getTargets().get(0);
String handle = rel.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);

IProgramElement clazz = manager.getHierarchy().findElementForType(null, toType);
@@ -163,7 +165,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.METHOD, set);
assertNotNull(setNode);
IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.ADVICE, backRelName);
String handle2 = (String) rel2.getTargets().get(0);
String handle2 = rel2.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}

@@ -176,7 +178,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
IProgramElement fromNode = manager.getHierarchy().findElementForLabel(aspect, declareKind, beforeExec);
assertNotNull(fromNode);
IRelationship rel = manager.getRelationshipMap().get(fromNode, IRelationship.Kind.DECLARE_INTER_TYPE, forwardRelName);
String handle = (String) rel.getTargets().get(0);
String handle = rel.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);

IProgramElement clazz = manager.getHierarchy().findElementForType(null, toType);
@@ -185,7 +187,7 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase {
IRelationship rel2 = manager.getRelationshipMap().get(clazz, IRelationship.Kind.DECLARE_INTER_TYPE, backRelName);
// String handle2 = (String)rel2.getTargets().get(0);
for (Iterator<String> it = rel2.getTargets().iterator(); it.hasNext();) {
String currHandle = (String) it.next();
String currHandle = it.next();
if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(from))
return;
}

+ 8
- 4
ajde.core/testsrc/org/aspectj/ajde/core/tests/model/SavedModelConsistencyTests.java View File

@@ -32,6 +32,7 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;

@Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("coverage");
@@ -48,6 +49,7 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty());
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
@@ -55,7 +57,7 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
}

public void testInterfaceIsSameInBoth() {
AsmManager asm = AsmManager.createNewStructureModel(Collections.EMPTY_MAP);
AsmManager asm = AsmManager.createNewStructureModel(Collections.<File,String>emptyMap());
asm.readStructureModel(getAbsoluteProjectDir());

IHierarchy model = asm.getHierarchy();
@@ -79,14 +81,15 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
}

public void testModelIsSamePreAndPostBuild() {
AsmManager asm = AsmManager.createNewStructureModel(Collections.EMPTY_MAP);
AsmManager asm = AsmManager.createNewStructureModel(Collections.<File,String>emptyMap());
asm.readStructureModel(getAbsoluteProjectDir());
// AsmManager.getDefault().readStructureModel(getAbsoluteProjectDir());
IHierarchy model = asm.getHierarchy();
assertTrue("model exists", model != null);

final List preBuildKinds = new ArrayList();
final List<IProgramElement.Kind> preBuildKinds = new ArrayList<>();
HierarchyWalker walker = new HierarchyWalker() {
@Override
public void preProcess(IProgramElement node) {
preBuildKinds.add(node.getKind());
}
@@ -97,8 +100,9 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
doBuild();
assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty());

final List postBuildKinds = new ArrayList();
final List<IProgramElement.Kind> postBuildKinds = new ArrayList<>();
HierarchyWalker walker2 = new HierarchyWalker() {
@Override
public void preProcess(IProgramElement node) {
postBuildKinds.add(node.getKind());
}

Loading…
Cancel
Save