Procházet zdrojové kódy

cope with change to package bindings (import without the .* now)

tags/V1_7_0RC1
aclement před 12 roky
rodič
revize
8116c118f6

+ 14
- 20
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java Zobrazit soubor

/** /**
* Reset for every compilation unit. * Reset for every compilation unit.
*/ */
protected Stack stack;
protected Stack<IProgramElement> stack;


protected ImportReference packageDecl = null; protected ImportReference packageDecl = null;


IProgramElement root = structureModel.getHierarchy().getRoot(); IProgramElement root = structureModel.getHierarchy().getRoot();
// Check if already there // Check if already there
IProgramElement sourceFolderNode = null; 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(); IProgramElement child = (IProgramElement) iterator.next();
if (child.getKind() == IProgramElement.Kind.SOURCE_FOLDER && child.getName().equals(sourceFolder)) { if (child.getKind() == IProgramElement.Kind.SOURCE_FOLDER && child.getName().equals(sourceFolder)) {
sourceFolderNode = child; sourceFolderNode = child;


IProgramElement pkgNode = null; IProgramElement pkgNode = null;
if (structureModel != null && structureModel.getHierarchy().getRoot() != null && rootForSource.getChildren() != 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(); IProgramElement currNode = (IProgramElement) it.next();
if (pkgName.equals(currNode.getName())) { if (pkgName.equals(currNode.getName())) {
pkgNode = currNode; pkgNode = currNode;
peNode.setFormalComment(generateJavadocComment(typeDeclaration)); peNode.setFormalComment(generateJavadocComment(typeDeclaration));
peNode.setAnnotationStyleDeclaration(isAnnotationStyleAspect); peNode.setAnnotationStyleDeclaration(isAnnotationStyleAspect);


((IProgramElement) stack.peek()).addChild(peNode);
stack.peek().addChild(peNode);
stack.push(peNode); stack.push(peNode);
return true; return true;
} }
if (packageDecl != null) { if (packageDecl != null) {
int dotIndex = packageDecl.toString().lastIndexOf('.'); int dotIndex = packageDecl.toString().lastIndexOf('.');
String packageString = packageDecl.toString(); String packageString = packageDecl.toString();
if (dotIndex != -1) {
packageString = packageDecl.toString().substring(0, dotIndex);
}
ProgramElement packageDeclaration = new ProgramElement(activeStructureModel, packageString, ProgramElement packageDeclaration = new ProgramElement(activeStructureModel, packageString,
IProgramElement.Kind.PACKAGE_DECLARATION, makeLocation(packageDecl), 0, null, null); IProgramElement.Kind.PACKAGE_DECLARATION, makeLocation(packageDecl), 0, null, null);
StringBuffer packageSourceDeclaration = new StringBuffer(); StringBuffer packageSourceDeclaration = new StringBuffer();
} }


public boolean visit(ImportReference importRef, CompilationUnitScope scope) { 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; packageDecl = importRef;
} else { } else {


} }


public void endVisit(ImportReference importRef, CompilationUnitScope scope) { 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(); stack.pop();
} }
} }

Načítá se…
Zrušit
Uložit