Browse Source

testcode and patches for pr141730 comments #13,14: "new handleprovider"

tags/V1_5_2rc1
aclement 18 years ago
parent
commit
abe25b0298

+ 11
- 8
asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java View File

@@ -35,13 +35,7 @@ public class AspectJElementHierarchy implements IHierarchy {
private Map typeMap = null;
public IProgramElement getElement(String handle) {
IProgramElement cachedEntry = (IProgramElement)handleMap.get(handle);
if (cachedEntry!=null) return cachedEntry;
IProgramElement ret = findElementForHandle(handle);
if (ret!=null) {
cache(handle,ret);
}
return ret;
return findElementForHandleOrCreate(handle, false);
}

public IProgramElement getRoot() {
@@ -332,13 +326,22 @@ public class AspectJElementHierarchy implements IHierarchy {
this.configFile = configFile;
}
// TODO: optimize this lookup
public IProgramElement findElementForHandle(String handle) {
return findElementForHandleOrCreate(handle,true);
}
// TODO: optimize this lookup
// only want to create a file node if can't find the IPE if called through
// findElementForHandle() to mirror behaviour before pr141730
private IProgramElement findElementForHandleOrCreate(String handle, boolean create) {
// try the cache first...
IProgramElement ret = (IProgramElement) handleMap.get(handle);
if (ret != null) return ret;
ret = findElementForHandle(root,handle);
if (ret == null && create) {
ret = createFileStructureNode(getFilename(handle));
}
if (ret != null) {
cache(handle,(ProgramElement)ret);
}

+ 1
- 0
asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java View File

@@ -75,6 +75,7 @@ public class FullPathHandleProvider implements IElementHandleProvider {
}

public String createHandleIdentifier(IProgramElement ipe) {
if (ipe == null) return null;
if (ipe.getHandleIdentifier(false) != null) {
return ipe.getHandleIdentifier(false);
}

+ 1
- 0
asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java View File

@@ -99,6 +99,7 @@ public class OptimizedFullPathHandleProvider implements IElementHandleProvider {
}

public String createHandleIdentifier(IProgramElement ipe) {
if (ipe == null) return null;
if (ipe.getHandleIdentifier(false) != null) {
return ipe.getHandleIdentifier(false);
}

+ 45
- 0
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java View File

@@ -17,12 +17,17 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;

import junit.framework.AssertionFailedError;


import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationshipMap;
import org.aspectj.asm.internal.Relationship;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
@@ -431,6 +436,46 @@ public class Ajc {
}
return ret;
}
public static void dumpAJDEStructureModel(String prefix) {
dumpAJDEStructureModel(prefix, false);
}
public static void dumpAJDEStructureModel(String prefix, boolean useHandles) {
System.out.println("======================================");//$NON-NLS-1$
System.out.println("start of AJDE structure model:"+prefix); //$NON-NLS-1$

IRelationshipMap asmRelMap = AsmManager.getDefault().getRelationshipMap();
for (Iterator iter = asmRelMap.getEntries().iterator(); iter.hasNext();) {
String sourceOfRelationship = (String) iter.next();
System.err.println("Examining source relationship handle: "+sourceOfRelationship);
List relationships = null;
if (useHandles) {
relationships = asmRelMap.get(sourceOfRelationship);
} else {
IProgramElement ipe = AsmManager.getDefault().getHierarchy()
.findElementForHandle(sourceOfRelationship);
relationships = asmRelMap.get(ipe);
}
if (relationships != null) {
for (Iterator iterator = relationships.iterator(); iterator.hasNext();) {
Relationship rel = (Relationship) iterator.next();
List targets = rel.getTargets();
for (Iterator iterator2 = targets.iterator(); iterator2.hasNext();) {
String t = (String) iterator2.next();
IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(t);
System.out.println(""); //$NON-NLS-1$
System.out.println(" sourceOfRelationship " + sourceOfRelationship); //$NON-NLS-1$
System.out.println(" relationship " + rel.getName()); //$NON-NLS-1$
System.out.println(" target " + link.getName()); //$NON-NLS-1$
}
}
}
}
System.out.println("End of AJDE structure model"); //$NON-NLS-1$
System.out.println("======================================");//$NON-NLS-1$
}
}

/*

+ 9
- 0
tests/bugs152/pr141730/aspectpath/MyBar.aj View File

@@ -0,0 +1,9 @@
package bar;

public aspect MyBar {

before() : call(* main(..)) {
System.out.println("about to call a main method");
}
}

+ 11
- 0
tests/bugs152/pr141730/aspectpath/MyFoo.java View File

@@ -0,0 +1,11 @@
package foo;

public class MyFoo {

public void callMain() {
new MyFoo().main();
}
public void main() {
}
}

BIN
tests/bugs152/pr141730/aspectpath/aspectpath.jar View File


+ 5
- 0
tests/bugs152/pr141730/inpath/MyAnnotation.java View File

@@ -0,0 +1,5 @@
package bar;

public @interface MyAnnotation {

}

+ 18
- 0
tests/bugs152/pr141730/inpath/MyBar.aj View File

@@ -0,0 +1,18 @@
package bar;

import foo.*;

public aspect MyBar {

before() : call(* main(..)) {}

declare warning: get( * System.out ) : "System.out should not be called";
declare parents : *Foo extends NewClass;
declare @type : *Foo* : @MyAnnotation;
declare @method : public * *Foo.anotMethod(..) : @MyAnnotation;
declare @constructor : *Foo.new(String) : @MyAnnotation;
declare @field : int *Foo.* : @MyAnnotation ;
}

+ 25
- 0
tests/bugs152/pr141730/inpath/MyFoo.java View File

@@ -0,0 +1,25 @@
package foo;

public class MyFoo {

public int i;
public MyFoo() {
super();
}
public MyFoo(String s) {
super();
}
public void callMain() {
new MyFoo().main();
}
public void main() {
System.out.println("blah");
}
public void anotMethod() {
}
}

+ 5
- 0
tests/bugs152/pr141730/inpath/NewClass.java View File

@@ -0,0 +1,5 @@
package bar;

public class NewClass {

}

BIN
tests/bugs152/pr141730/inpath/inpath.jar View File


+ 101
- 1
tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java View File

@@ -12,6 +12,7 @@ package org.aspectj.systemtest.ajc152;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import junit.framework.Test;
@@ -19,9 +20,11 @@ import junit.framework.Test;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationshipMap;
import org.aspectj.asm.internal.Relationship;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.util.CharOperation;
import org.aspectj.weaver.World;

public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {

@@ -185,8 +188,105 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
checkSignatureOfIPE("MyClass.MyClass()",IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
}

// if not filling in the model for aspects contained in jar files then
// want to ensure that the relationship map is correct and has nodes
// which can be used in AJDT - ensure no NPE occurs for the end of
// the relationship with aspectpath
public void testAspectPathRelWhenNotFillingInModel_pr141730() {
World.createInjarHierarchy = false;
try {
runTest("ensure aspectpath injar relationships are correct when not filling in model");
// expecting:
// sourceOfRelationship main in MyFoo.java
// relationship advised by
// target MyBar.aj
//
// and
//
// sourceOfRelationship MyBar.aj
// relationship advises
// target main in MyFoo.java

IHierarchy top = AsmManager.getDefault().getHierarchy();
IRelationshipMap asmRelMap = AsmManager.getDefault().getRelationshipMap();
assertEquals("expected two sources of relationships but only found "
+ asmRelMap.getEntries().size(),2,asmRelMap.getEntries().size());
for (Iterator iter = asmRelMap.getEntries().iterator(); iter.hasNext();) {
String sourceOfRelationship = (String) iter.next();
IProgramElement ipe = top.findElementForHandle(sourceOfRelationship);
List relationships = asmRelMap.get(ipe);
if (ipe.getName().equals("MyBar.aj")) {
assertEquals("expected MyBar.aj to have one relationships but found "
+ relationships.size(),1,relationships.size());
Relationship rel = (Relationship)relationships.get(0);
assertEquals("expected relationship to be 'advises' but was "
+ rel.getName(), "advises", rel.getName());
List targets = rel.getTargets();
assertEquals("expected one target but found " + targets.size(),1,targets.size());
IProgramElement link = top.findElementForHandle((String)targets.get(0));
assertEquals("expected target 'method-call(void foo.MyFoo.main())' but target " + link.getName(),
"method-call(void foo.MyFoo.main())",link.getName());
String fileName = link.getSourceLocation().getSourceFile().toString();
assertTrue("expected 'main' to be in class MyFoo.java but found it " +
"in " + fileName,fileName.indexOf("MyFoo.java") != -1);
} else if (ipe.getName().equals("method-call(void foo.MyFoo.main())")) {
String fileName = ipe.getSourceLocation().getSourceFile().toString();
assertTrue("expected 'method-call(void foo.MyFoo.main())' to be in " +
"class MyFoo.java but found it in"
+ fileName,fileName.indexOf("MyFoo.java") != -1);
assertEquals("expected 'method-call(void foo.MyFoo.main())' " +
"to have one relationships but found "
+ relationships.size(),1,relationships.size());
Relationship rel = (Relationship)relationships.get(0);
assertEquals("expected relationship to be 'advised by' but was "
+ rel.getName(), "advised by", rel.getName());
List targets = rel.getTargets();
assertEquals("expected one target but found " + targets.size(),1,targets.size());
IProgramElement link = top.findElementForHandle((String)targets.get(0));
assertEquals("expected target 'MyBar.aj' but target " + link.getName(),
"MyBar.aj",link.getName());
} else {
fail("unexpected element " + ipe.getName() + " in the relationship map");
}
}
} finally {
World.createInjarHierarchy = true;
}
}

// if not filling in the model for classes contained in jar files then
// want to ensure that the relationship map is correct and has nodes
// which can be used in AJDT - ensure no NPE occurs for the end of
// the relationship with inpath
public void testNoNPEWithInpathWhenNotFillingInModel_pr141730() {
World.createInjarHierarchy = false;
try {
runTest("ensure inpath injar relationships are correct when not filling in model");
// the aspect used for this test has advice, declare parents, deow,
// and declare @type, @constructor, @field and @method. We only expect
// there to be relationships in the map for declare parents and declare @type
// (provided the model isn't being filled in) because the logic in the other
// addXXXRelationship methods use AspectJElementHierarchy.findElementForType().
// This method which returns null because there is no such ipe. The relationship is
// therefore not added to the model. Adding declare @type and declare parents
// uses AspectJElementHierarchy.findElementForHandle() which returns the file
// node ipe if it can't find one for the given handle. Therefore the relationships
// are added against the file node. Before change to using ipe's to create handles
// we also had the deow relationship, however, now we don't because this also
// uses findElementForType to find the targetNode which in the inpath case is null.
// just check that the number of entries is what we expect:
// We expect 3 (the declare @type and declare parents statements plus the filenode)
IRelationshipMap relMap = AsmManager.getDefault().getRelationshipMap();
assertEquals("expected 3 entries in the relationship map but found "
+ relMap.getEntries().size(), 3, relMap.getEntries().size());
} finally {
World.createInjarHierarchy = true;
}
}
// public void testFunkyGenericErrorWithITDs_pr126355_2() {
// runTest("bizarre generic error with itds - 2");

+ 10
- 0
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml View File

@@ -667,6 +667,16 @@
</stderr>
</run>
</ajc-test>

<ajc-test dir="bugs152/pr141730/aspectpath" title="ensure aspectpath injar relationships are correct when not filling in model">
<compile files="MyFoo.java" aspectpath="aspectpath.jar" options="-emacssym"/>
</ajc-test>

<ajc-test dir="bugs152/pr141730/inpath" title="ensure inpath injar relationships are correct when not filling in model">
<compile files="MyBar.aj, MyAnnotation.java, NewClass.java" inpath="inpath.jar" options="-1.5 -emacssym">
<message kind="warning" line="20" text="System.out should not be called"/>
</compile>
</ajc-test>
<ajc-test dir="ltw" title="weaveinfo messages with include and exclude">
<compile files="EmptyTest1.java, EmptyTest2.java"/>

+ 3
- 34
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java View File

@@ -31,6 +31,7 @@ import org.aspectj.asm.IRelationship;
import org.aspectj.asm.IRelationshipMap;
import org.aspectj.asm.internal.Relationship;
import org.aspectj.bridge.IMessage;
import org.aspectj.tools.ajc.Ajc;
import org.aspectj.weaver.World;

/**
@@ -79,14 +80,14 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
configureBuildStructureModel(true);
initialiseProject("P4");
build("P4");
dumpAJDEStructureModel("after full build where advice is applying");
Ajc.dumpAJDEStructureModel("after full build where advice is applying");
// should be 4 relationship entries
// In inc1 the first advised line is 'commented out'
alter("P4","inc1");
build("P4");
checkWasntFullBuild();
dumpAJDEStructureModel("after inc build where first advised line is gone");
Ajc.dumpAJDEStructureModel("after inc build where first advised line is gone");
// should now be 2 relationship entries
// This will be the line 6 entry in C.java
@@ -1440,38 +1441,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
" in the aop.xml file but found " + aspectCount + " occurrences");
}
}
private void dumpAJDEStructureModel(String prefix) {
System.out.println("======================================");//$NON-NLS-1$
System.out.println("start of AJDE structure model:"+prefix); //$NON-NLS-1$

IRelationshipMap asmRelMap = AsmManager.getDefault().getRelationshipMap();
for (Iterator iter = asmRelMap.getEntries().iterator(); iter.hasNext();) {
String sourceOfRelationship = (String) iter.next();
IProgramElement ipe = AsmManager.getDefault().getHierarchy()
.findElementForHandle(sourceOfRelationship);
System.err.println("Examining source relationship handle: "+sourceOfRelationship);
List relationships = asmRelMap.get(ipe);
if (relationships != null) {
for (Iterator iterator = relationships.iterator(); iterator.hasNext();) {
Relationship rel = (Relationship) iterator.next();
List targets = rel.getTargets();
for (Iterator iterator2 = targets.iterator(); iterator2.hasNext();) {
String t = (String) iterator2.next();
IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(t);
System.out.println(""); //$NON-NLS-1$
System.out.println(" sourceOfRelationship " + sourceOfRelationship); //$NON-NLS-1$
System.out.println(" relationship " + rel.getName()); //$NON-NLS-1$
System.out.println(" target " + link.getName()); //$NON-NLS-1$
}
}
}
}
System.out.println("End of AJDE structure model"); //$NON-NLS-1$
System.out.println("======================================");//$NON-NLS-1$
}

private File getProjectRelativePath(String p,String filename) {
File projDir = new File(getWorkingDir(),p);

+ 81
- 86
weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java View File

@@ -54,27 +54,29 @@ public class AsmRelationshipProvider {
if (shadow.getSourceLocation() == null || checker.getSourceLocation() == null) return;
// Ensure a node for the target exists
IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(), shadow);
IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(),shadow);
if (targetNode == null) return;
String targetHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(targetNode);
if (targetHandle == null) return;

IProgramElement sourceNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(checker.getSourceLocation());
String sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
String targetHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(targetNode);
if (sourceHandle == null) return;
if (World.createInjarHierarchy) {
checker.createHierarchy();
}

IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
if (sourceHandle != null && targetHandle != null) {
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE, MATCHED_BY,false,true);
foreward.addTarget(targetHandle);
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE, MATCHED_BY,false,true);
foreward.addTarget(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE, MATCHES_DECLARE,false,true);
if (back != null && back.getTargets() != null) {
back.addTarget(sourceHandle);
}
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE, MATCHES_DECLARE,false,true);
if (back != null && back.getTargets() != null) {
back.addTarget(sourceHandle);
}
}

@@ -85,34 +87,32 @@ public class AsmRelationshipProvider {
ResolvedType originatingAspect) {

if (!AsmManager.isCreatingModel()) return;
String sourceHandle = "";
if (munger.getSourceLocation()!=null && munger.getSourceLocation().getOffset()!=-1) {
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(munger.getSourceLocation());
sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
} else {
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(originatingAspect.getSourceLocation());
sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
}
if (originatingAspect.getSourceLocation() != null) {
String sourceHandle = "";
if (munger.getSourceLocation()!=null && munger.getSourceLocation().getOffset()!=-1) {
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(munger.getSourceLocation());
sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
} else {
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(originatingAspect.getSourceLocation());
sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
}
if (sourceHandle == null) return;
IProgramElement targetNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(onType.getSourceLocation());
String targetHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(targetNode);
if (targetHandle == null) return;
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
if (sourceHandle != null && targetHandle != null) {
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
foreward.addTarget(targetHandle);
// foreward.getTargets().add(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
back.addTarget(sourceHandle);
// back.getTargets().add(sourceHandle);
}
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
foreward.addTarget(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
back.addTarget(sourceHandle);
}
}
@@ -123,20 +123,20 @@ public class AsmRelationshipProvider {
.findElementForSourceLine(decp);
String sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
if (sourceHandle == null) return;
IProgramElement targetNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(targetType.getSourceLocation());
String targetHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(targetNode);
if (targetHandle == null) return;
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
if (sourceHandle != null && targetHandle != null) {
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
foreward.addTarget(targetHandle);
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
foreward.addTarget(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
back.addTarget(sourceHandle);
}
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
back.addTarget(sourceHandle);
}
/**
@@ -150,20 +150,20 @@ public class AsmRelationshipProvider {
.findElementForSourceLine(declareAnnotationLocation);
String sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
if (sourceHandle == null) return;

IProgramElement targetNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(annotatedLocation);
String targetHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(targetNode);
if (targetHandle == null) return;
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
if (sourceHandle != null && targetHandle != null) {
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);
foreward.addTarget(targetHandle);
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);
foreward.addTarget(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);
back.addTarget(sourceHandle);
}
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);
back.addTarget(sourceHandle);
}
public void adviceMunger(IHierarchy model, Shadow shadow, ShadowMunger munger) {
@@ -179,12 +179,14 @@ public class AsmRelationshipProvider {

IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(), shadow);
if (targetNode == null) return;
boolean runtimeTest = ((BcelAdvice)munger).hasDynamicTests();
// Work out extra info to inform interested UIs !
IProgramElement.ExtraInformation ai = new IProgramElement.ExtraInformation();

String adviceHandle = advice.getHandle();
if (adviceHandle == null) return;
// What kind of advice is it?
// TODO: Prob a better way to do this but I just want to
@@ -195,27 +197,20 @@ public class AsmRelationshipProvider {
if (adviceElement != null) {
adviceElement.setExtraInfo(ai);
}
if (adviceHandle != null && targetNode != null) {
if (targetNode != null) {
String targetHandle = targetNode.getHandleIdentifier();
if (advice.getKind().equals(AdviceKind.Softener)) {
IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.DECLARE_SOFT, SOFTENS,runtimeTest,true);
if (foreward != null) foreward.addTarget(targetHandle);//foreward.getTargets().add(targetHandle);
String targetHandle = targetNode.getHandleIdentifier();
if (advice.getKind().equals(AdviceKind.Softener)) {
IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.DECLARE_SOFT, SOFTENS,runtimeTest,true);
if (foreward != null) foreward.addTarget(targetHandle);//foreward.getTargets().add(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE, SOFTENED_BY,runtimeTest,true);
if (back != null) back.addTarget(adviceHandle);//back.getTargets().add(adviceHandle);
} else {
IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.ADVICE, ADVISES,runtimeTest,true);
if (foreward != null) foreward.addTarget(targetHandle);//foreward.getTargets().add(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE, SOFTENED_BY,runtimeTest,true);
if (back != null) back.addTarget(adviceHandle);//back.getTargets().add(adviceHandle);
} else {
IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.ADVICE, ADVISES,runtimeTest,true);
if (foreward != null) foreward.addTarget(targetHandle);//foreward.getTargets().add(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.ADVICE, ADVISED_BY,runtimeTest,true);
if (back != null) back.addTarget(adviceHandle);//back.getTargets().add(adviceHandle);
}
}
}

IRelationship back = mapper.get(targetHandle, IRelationship.Kind.ADVICE, ADVISED_BY,runtimeTest,true);
if (back != null) back.addTarget(adviceHandle);//back.getTargets().add(adviceHandle);
}
}
}

@@ -381,22 +376,22 @@ public class AsmRelationshipProvider {
if (methodElem == null) return;
try {
String targetHandle = methodElem.getHandleIdentifier();
if (targetHandle == null) return;
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy().findElementForSourceLine(sourceLocation);
String sourceHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(sourceNode);
String targetHandle = methodElem.getHandleIdentifier();
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
if (sourceHandle != null && targetHandle != null) {
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);
foreward.addTarget(targetHandle);
if (sourceHandle == null) return;
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);
foreward.addTarget(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);
back.addTarget(sourceHandle);
}
} catch (Throwable t) { // I'm worried about that code above, this will make sure we don't explode if it plays up
t.printStackTrace(); // I know I know .. but I don't want to lose it!
}
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);
back.addTarget(sourceHandle);
} catch (Throwable t) { // I'm worried about that code above, this will make sure we don't explode if it plays up
t.printStackTrace(); // I know I know .. but I don't want to lose it!
}
}
/**
@@ -422,19 +417,19 @@ public class AsmRelationshipProvider {
IProgramElement fieldElem = AsmManager.getDefault().getHierarchy().findElementForSignature(typeElem,IProgramElement.Kind.FIELD,field.getName());
if (fieldElem== null) return;

IProgramElement sourceNode = AsmManager.getDefault().getHierarchy().findElementForSourceLine(sourceLocation);
String sourceHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(sourceNode);
String targetHandle = fieldElem.getHandleIdentifier();
if (targetHandle == null) return;
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy().findElementForSourceLine(sourceLocation);
String sourceHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(sourceNode);
if (sourceHandle == null) return;
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
if (sourceHandle != null && targetHandle != null) {
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);
foreward.addTarget(targetHandle);
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);
foreward.addTarget(targetHandle);
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);
back.addTarget(sourceHandle);
}
IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);
back.addTarget(sourceHandle);
}
}

Loading…
Cancel
Save