diff options
author | aclement <aclement> | 2006-06-19 10:17:28 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-06-19 10:17:28 +0000 |
commit | abe25b029852a8c8e1c682a9a59413896d18dd2b (patch) | |
tree | 04eada1bb3d2e225f1f2986f1b6c3a48a7240ea5 /asm | |
parent | fdbae3fda3e572ea35ac4a73373896b9b5cff8f7 (diff) | |
download | aspectj-abe25b029852a8c8e1c682a9a59413896d18dd2b.tar.gz aspectj-abe25b029852a8c8e1c682a9a59413896d18dd2b.zip |
testcode and patches for pr141730 comments #13,14: "new handleprovider"
Diffstat (limited to 'asm')
3 files changed, 13 insertions, 8 deletions
diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java index 8c525b083..cb483acd0 100644 --- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java +++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java @@ -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); } diff --git a/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java b/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java index 6ab254d45..cd7f350b7 100644 --- a/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java +++ b/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java @@ -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); } diff --git a/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java b/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java index e7b364241..c8a849905 100644 --- a/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java +++ b/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java @@ -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); } |