diff options
author | aclement <aclement> | 2006-03-18 11:59:16 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-03-18 11:59:16 +0000 |
commit | 7e4b7dafc0b6d20fb2b17e9bc4a12fd7d8934471 (patch) | |
tree | 912f029abebbf3d1219eefd862fba9c554fdbeab /asm | |
parent | 9dca72e7c63a5623f3d442bf43bb88810368a65a (diff) | |
download | aspectj-7e4b7dafc0b6d20fb2b17e9bc4a12fd7d8934471.tar.gz aspectj-7e4b7dafc0b6d20fb2b17e9bc4a12fd7d8934471.zip |
128650: more memory stuff
Diffstat (limited to 'asm')
7 files changed, 63 insertions, 23 deletions
diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java index 46f347dcf..bc63e881b 100644 --- a/asm/src/org/aspectj/asm/AsmManager.java +++ b/asm/src/org/aspectj/asm/AsmManager.java @@ -64,6 +64,8 @@ public class AsmManager { private static String dumpFilename = ""; private static boolean reporting = false; + private static boolean completingTypeBindings = false; + // static { // setReporting("c:/model.nfo",true,true,true,true); // } @@ -72,7 +74,7 @@ public class AsmManager { hierarchy = new AspectJElementHierarchy(); // List relationships = new ArrayList(); mapper = new RelationshipMap(hierarchy); - handleProvider = new FullPathHandleProvider(); + handleProvider = new OptimizedFullPathHandleProvider(); } public void createNewASM() { @@ -845,5 +847,11 @@ public class AsmManager { */ public static boolean isCreatingModel() { return creatingModel;} + public static void setCompletingTypeBindings(boolean b) { + completingTypeBindings = b; + } + + public static boolean isCompletingTypeBindings() { return completingTypeBindings; } + } diff --git a/asm/src/org/aspectj/asm/IElementHandleProvider.java b/asm/src/org/aspectj/asm/IElementHandleProvider.java index 97902abf9..8cef1acec 100644 --- a/asm/src/org/aspectj/asm/IElementHandleProvider.java +++ b/asm/src/org/aspectj/asm/IElementHandleProvider.java @@ -53,4 +53,6 @@ public interface IElementHandleProvider { */ public int getLineNumberForHandle(String handle); + public int getOffSetForHandle(String handle); + } diff --git a/asm/src/org/aspectj/asm/IHierarchy.java b/asm/src/org/aspectj/asm/IHierarchy.java index 481147cd8..02a4a18f8 100644 --- a/asm/src/org/aspectj/asm/IHierarchy.java +++ b/asm/src/org/aspectj/asm/IHierarchy.java @@ -91,6 +91,7 @@ public interface IHierarchy extends Serializable { * @return a new structure node for the file if it was not found in the model */ public IProgramElement findElementForSourceLine(String sourceFilePath, int lineNumber); + public IProgramElement findElementForOffSet(String sourceFilePath, int lineNumber, int offSet); public String getConfigFile(); diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java index 1e8c4f5dd..7839b3abd 100644 --- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java +++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java @@ -43,11 +43,12 @@ public class AspectJElementHierarchy implements IHierarchy { // int col = new Integer(st.nextToken()).intValue(); TODO: use column number when available String file = AsmManager.getDefault().getHandleProvider().getFileForHandle(handle); // st.nextToken(); int line = AsmManager.getDefault().getHandleProvider().getLineNumberForHandle(handle); // st.nextToken(); + int offSet = AsmManager.getDefault().getHandleProvider().getOffSetForHandle(handle); String canonicalSFP = AsmManager.getDefault().getCanonicalFilePath(new File(file)); - IProgramElement ret = findNodeForSourceLineHelper(root,canonicalSFP, line); + IProgramElement ret = findNodeForSourceLineHelper(root,canonicalSFP, line, offSet); if (ret!=null) { - handleMap.put(handle,ret); + cache(handle,ret); } return ret; } @@ -245,7 +246,18 @@ public class AspectJElementHierarchy implements IHierarchy { public IProgramElement findElementForSourceLine(String sourceFilePath, int lineNumber) { String canonicalSFP = AsmManager.getDefault().getCanonicalFilePath( new File(sourceFilePath)); - IProgramElement node = findNodeForSourceLineHelper(root, canonicalSFP, lineNumber); + IProgramElement node = findNodeForSourceLineHelper(root, canonicalSFP, lineNumber, -1); + if (node != null) { + return node; + } else { + return createFileStructureNode(sourceFilePath); + } + } + + public IProgramElement findElementForOffSet(String sourceFilePath, int lineNumber, int offSet) { + String canonicalSFP = AsmManager.getDefault().getCanonicalFilePath( + new File(sourceFilePath)); + IProgramElement node = findNodeForSourceLineHelper(root, canonicalSFP, lineNumber, offSet); if (node != null) { return node; } else { @@ -267,9 +279,9 @@ public class AspectJElementHierarchy implements IHierarchy { } - private IProgramElement findNodeForSourceLineHelper(IProgramElement node, String sourceFilePath, int lineNumber) { - if (matches(node, sourceFilePath, lineNumber) - && !hasMoreSpecificChild(node, sourceFilePath, lineNumber)) { + private IProgramElement findNodeForSourceLineHelper(IProgramElement node, String sourceFilePath, int lineNumber, int offSet) { + if (matches(node, sourceFilePath, lineNumber, offSet) + && !hasMoreSpecificChild(node, sourceFilePath, lineNumber, offSet)) { return node; } @@ -278,15 +290,16 @@ public class AspectJElementHierarchy implements IHierarchy { IProgramElement foundNode = findNodeForSourceLineHelper( (IProgramElement)it.next(), sourceFilePath, - lineNumber); + lineNumber, + offSet); if (foundNode != null) return foundNode; } } return null; } - - private boolean matches(IProgramElement node, String sourceFilePath, int lineNumber) { + + private boolean matches(IProgramElement node, String sourceFilePath, int lineNumber, int offSet) { // try { // if (node != null && node.getSourceLocation() != null) // System.err.println("====\n1: " + @@ -296,6 +309,8 @@ public class AspectJElementHierarchy implements IHierarchy { return node != null && node.getSourceLocation() != null && node.getSourceLocation().getSourceFile().getAbsolutePath().equals(sourceFilePath) + && ((offSet != -1 && node.getSourceLocation().getOffset() == offSet) + || offSet == -1 ) && ((node.getSourceLocation().getLine() <= lineNumber && node.getSourceLocation().getEndLine() >= lineNumber) || @@ -307,10 +322,10 @@ public class AspectJElementHierarchy implements IHierarchy { // } } - private boolean hasMoreSpecificChild(IProgramElement node, String sourceFilePath, int lineNumber) { + private boolean hasMoreSpecificChild(IProgramElement node, String sourceFilePath, int lineNumber, int offSet) { for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { IProgramElement child = (IProgramElement)it.next(); - if (matches(child, sourceFilePath, lineNumber)) return true; + if (matches(child, sourceFilePath, lineNumber, offSet)) return true; } return false; } @@ -336,8 +351,9 @@ public class AspectJElementHierarchy implements IHierarchy { // TODO: use column number when available String file = AsmManager.getDefault().getHandleProvider().getFileForHandle(handle); // st.nextToken(); int line = AsmManager.getDefault().getHandleProvider().getLineNumberForHandle(handle); // st.nextToken(); + int offSet = AsmManager.getDefault().getHandleProvider().getOffSetForHandle(handle); - ret = findElementForSourceLine(file, line); + ret = findElementForOffSet(file, line, offSet); if (ret != null) { cache(handle,(ProgramElement)ret); } @@ -371,9 +387,11 @@ public class AspectJElementHierarchy implements IHierarchy { // } // return null; // } - - protected void cache(String handle, ProgramElement pe) { - handleMap.put(handle,pe); + + protected void cache(String handle, IProgramElement pe) { + if (!AsmManager.isCompletingTypeBindings()) { + handleMap.put(handle,pe); + } } public void flushTypeMap() { diff --git a/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java b/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java index 0a32af207..060cf0e5d 100644 --- a/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java +++ b/asm/src/org/aspectj/asm/internal/FullPathHandleProvider.java @@ -62,4 +62,12 @@ public class FullPathHandleProvider implements IElementHandleProvider { st.nextToken(); // skip over the file return new Integer(st.nextToken()).intValue(); } + + public int getOffSetForHandle(String handle) { + StringTokenizer st = new StringTokenizer(handle, ID_DELIM); + st.nextToken(); // skip over the file + st.nextToken(); // skip over the line number + st.nextToken(); // skip over the column + return new Integer(st.nextToken()).intValue(); + } } diff --git a/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java b/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java index 5e78a1fce..b13b1755e 100644 --- a/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java +++ b/asm/src/org/aspectj/asm/internal/OptimizedFullPathHandleProvider.java @@ -88,4 +88,12 @@ public class OptimizedFullPathHandleProvider implements IElementHandleProvider { st.nextToken(); // skip over the file return new Integer(st.nextToken()).intValue(); } + + public int getOffSetForHandle(String handle) { + StringTokenizer st = new StringTokenizer(handle, ID_DELIM); + st.nextToken(); // skip over the file + st.nextToken(); // skip over the line number + st.nextToken(); // skip over the column + return new Integer(st.nextToken()).intValue(); + } } diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index b78b3bbda..3334d63fd 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -78,13 +78,11 @@ public class ProgramElement implements IProgramElement { public ProgramElement (String name, IProgramElement.Kind kind, ISourceLocation sourceLocation, int modifiers, String comment, List children) { this(name, kind, children); - this.sourceLocation = //ISourceLocation.EMPTY; - sourceLocation; + this.sourceLocation = sourceLocation; setFormalComment(comment); // if (comment!=null && comment.length()>0) formalComment = comment; this.modifiers = modifiers; // this.accessibility = genAccessibility(modifiers); - cacheByHandle(); } /** @@ -104,9 +102,7 @@ public class ProgramElement implements IProgramElement { boolean member) { this(name, kind, children); - this.sourceLocation = - //ISourceLocation.EMPTY; - sourceLocation; + this.sourceLocation = sourceLocation; this.kind = kind; this.modifiers = modifiers; // this.accessibility = accessibility; @@ -116,7 +112,6 @@ public class ProgramElement implements IProgramElement { // if (comment!=null && comment.length()>0) formalComment = comment; if (relations!=null && relations.size()!=0) setRelations(relations); // this.relations = relations; - cacheByHandle(); } public List getModifiers() { |