summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoraclement <aclement>2011-12-10 01:02:25 +0000
committeraclement <aclement>2011-12-10 01:02:25 +0000
commit8116c118f6a03f248f79bc45e3975a40be8233cd (patch)
treef784979993fe89f672c0da44c2368d5b56f2792e /org.aspectj.ajdt.core
parentb72204bd4f5775380bef3c5dc268fa854ad04376 (diff)
downloadaspectj-8116c118f6a03f248f79bc45e3975a40be8233cd.tar.gz
aspectj-8116c118f6a03f248f79bc45e3975a40be8233cd.zip
cope with change to package bindings (import without the .* now)
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java34
1 files changed, 14 insertions, 20 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index 88c2c21cd..08366dbb1 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -102,7 +102,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
/**
* Reset for every compilation unit.
*/
- protected Stack stack;
+ protected Stack<IProgramElement> stack;
protected ImportReference packageDecl = null;
@@ -207,8 +207,8 @@ public class AsmHierarchyBuilder extends ASTVisitor {
IProgramElement root = structureModel.getHierarchy().getRoot();
// Check if already there
IProgramElement sourceFolderNode = null;
- List kids = root.getChildren();
- for (Iterator iterator = kids.iterator(); iterator.hasNext();) {
+ List<IProgramElement> kids = root.getChildren();
+ for (Iterator<IProgramElement> iterator = kids.iterator(); iterator.hasNext();) {
IProgramElement child = (IProgramElement) iterator.next();
if (child.getKind() == IProgramElement.Kind.SOURCE_FOLDER && child.getName().equals(sourceFolder)) {
sourceFolderNode = child;
@@ -265,7 +265,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
IProgramElement pkgNode = null;
if (structureModel != null && structureModel.getHierarchy().getRoot() != null && rootForSource.getChildren() != null) {
- for (Iterator it = rootForSource.getChildren().iterator(); it.hasNext();) {
+ for (Iterator<IProgramElement> it = rootForSource.getChildren().iterator(); it.hasNext();) {
IProgramElement currNode = (IProgramElement) it.next();
if (pkgName.equals(currNode.getName())) {
pkgNode = currNode;
@@ -348,7 +348,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
peNode.setFormalComment(generateJavadocComment(typeDeclaration));
peNode.setAnnotationStyleDeclaration(isAnnotationStyleAspect);
- ((IProgramElement) stack.peek()).addChild(peNode);
+ stack.peek().addChild(peNode);
stack.push(peNode);
return true;
}
@@ -358,9 +358,6 @@ public class AsmHierarchyBuilder extends ASTVisitor {
if (packageDecl != null) {
int dotIndex = packageDecl.toString().lastIndexOf('.');
String packageString = packageDecl.toString();
- if (dotIndex != -1) {
- packageString = packageDecl.toString().substring(0, dotIndex);
- }
ProgramElement packageDeclaration = new ProgramElement(activeStructureModel, packageString,
IProgramElement.Kind.PACKAGE_DECLARATION, makeLocation(packageDecl), 0, null, null);
StringBuffer packageSourceDeclaration = new StringBuffer();
@@ -771,12 +768,11 @@ public class AsmHierarchyBuilder extends ASTVisitor {
}
public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
- int dotIndex = importRef.toString().lastIndexOf('.');
- String currPackageImport = "";
- if (dotIndex != -1) {
- currPackageImport = importRef.toString().substring(0, dotIndex);
- }
- if (((IProgramElement) stack.peek()).getPackageName().equals(currPackageImport)) {
+ // 3.3 compiler used to represent the package statement in such a way that toString() would return 'foo.*' for 'package foo;'
+ // 3.7 compiler doesn't create an 'ondemand' import reference so it is purely toString()'d as 'foo'
+ String currPackageImport = importRef.toString();
+ String stackPackageName = stack.peek().getPackageName();
+ if (stackPackageName.equals(currPackageImport)) {
packageDecl = importRef;
} else {
@@ -807,12 +803,10 @@ public class AsmHierarchyBuilder extends ASTVisitor {
}
public void endVisit(ImportReference importRef, CompilationUnitScope scope) {
- int dotIndex = importRef.toString().lastIndexOf('.');
- String currPackageImport = "";
- if (dotIndex != -1) {
- currPackageImport = importRef.toString().substring(0, dotIndex);
- }
- if (!((IProgramElement) stack.peek()).getPackageName().equals(currPackageImport)) {
+ // 3.3 compiler used to represent the package statement in such a way that toString() would return 'foo.*' for 'package foo;'
+ // 3.7 compiler doesn't create an 'ondemand' import reference so it is purely toString()'d as 'foo'
+ String currPackageImport = importRef.toString();
+ if (!stack.peek().getPackageName().equals(currPackageImport)) {
stack.pop();
}
}