aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:06:37 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:06:37 +0200
commit72194b7982ddfa8e9864d0a9934905bb76b90f33 (patch)
treeebed806c358c1a3960c5d6be4c13b26ca41809df /org.aspectj.ajdt.core
parentc3289ab86bfb2c97cf34147239b3dde46de92a7c (diff)
downloadaspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.tar.gz
aspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.zip
'for' loop replaceable with enhanced 'for' loop
Reports for loops which iterate over collections or arrays, and can be replaced with an enhanced for loop (i.e. the foreach iteration syntax). Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java16
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java12
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/ConfigParser.java8
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java16
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java40
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java8
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java6
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java3
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java36
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java10
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java3
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java16
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/Proceed.java6
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java6
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java38
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java93
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java5
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java8
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java11
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java17
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java48
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java13
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java19
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java8
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java4
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java21
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java14
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java328
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java159
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java14
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java12
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java10
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseSourceContext.java11
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java7
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java13
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java95
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java60
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java7
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java3
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java8
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java30
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java9
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java8
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java31
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java10
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java88
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java114
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java6
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java28
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java4
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java24
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java32
59 files changed, 769 insertions, 855 deletions
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
index 27553cf7d..25de41c2d 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
@@ -44,19 +44,19 @@ public class AjdtCommand implements ICommand {
buildManager = new AjBuildManager(handler);
savedArgs = new String[args.length];
System.arraycopy(args, 0, savedArgs, 0, savedArgs.length);
- for (int i = 0; i < args.length; i++) {
+ for (String arg : args) {
// AMC - PR58681. No need to abort on -help as the Eclipse compiler does the right thing.
// if ("-help".equals(args[i])) {
// // should be info, but handler usually suppresses
// MessageUtil.abort(handler, BuildArgParser.getUsage());
// return true;
-// } else
- if ("-X".equals(args[i])) {
- // should be info, but handler usually suppresses
- MessageUtil.abort(handler, BuildArgParser.getXOptionUsage());
- return true;
- }
- }
+// } else
+ if ("-X".equals(arg)) {
+ // should be info, but handler usually suppresses
+ MessageUtil.abort(handler, BuildArgParser.getXOptionUsage());
+ return true;
+ }
+ }
return doCommand(handler, false);
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
index 1b18b980d..57af301f2 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
@@ -190,8 +190,8 @@ public class BuildArgParser extends Main {
}
if (buildConfig.getSourceRoots() != null) {
- for (Iterator i = buildConfig.getSourceRoots().iterator(); i.hasNext();) {
- fileList.addAll(collectSourceRootFiles((File) i.next()));
+ for (File file : buildConfig.getSourceRoots()) {
+ fileList.addAll(collectSourceRootFiles(file));
}
}
@@ -416,8 +416,8 @@ public class BuildArgParser extends Main {
if (parser.classpath == null) {
addClasspath(System.getProperty("java.class.path", ""), ret);
List fixedList = new ArrayList();
- for (Iterator it = ret.iterator(); it.hasNext();) {
- String entry = (String) it.next();
+ for (Object o : ret) {
+ String entry = (String) o;
if (!entry.endsWith("aspectjtools.jar")) {
fixedList.add(entry);
}
@@ -438,8 +438,8 @@ public class BuildArgParser extends Main {
File dirFile = new File(tokenizer.nextToken());
if (dirFile.canRead() && dirFile.isDirectory()) {
File[] files = dirFile.listFiles(FileUtil.ZIP_FILTER);
- for (int i = 0; i < files.length; i++) {
- classpathCollector.add(files[i].getAbsolutePath());
+ for (File file : files) {
+ classpathCollector.add(file.getAbsolutePath());
}
} else {
// XXX alert on invalid -extdirs entries
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/ConfigParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/ConfigParser.java
index 1bbd3327b..bdb87cb2b 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/ConfigParser.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/ConfigParser.java
@@ -42,8 +42,8 @@ public class ConfigParser {
public void parseCommandLine(String[] argsArray) throws ParseException {
location = new CommandLineLocation();
LinkedList<Arg> args = new LinkedList<Arg>();
- for (int i = 0; i < argsArray.length; i++) {
- args.add(new Arg(argsArray[i], location));
+ for (String s : argsArray) {
+ args.add(new Arg(s, location));
}
String aspectjOptions = null;
try {
@@ -188,8 +188,8 @@ public class ConfigParser {
showWarning("no matching files found in: " + dir);
}
- for (int i = 0; i < files.length; i++) {
- addFile(files[i]);
+ for (File file : files) {
+ addFile(file);
}
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java
index a23eb05f0..e58b57ea7 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java
@@ -180,8 +180,8 @@ public class AjCompilerAdapter extends AbstractCompilerAdapter {
try {
// not great ... but one more check before we continue, see pr132314
if (!reportedErrors && units != null) {
- for (int i = 0; i < units.length; i++) {
- if (units[i] != null && units[i].compilationResult != null && units[i].compilationResult.hasErrors()) {
+ for (CompilationUnitDeclaration unit : units) {
+ if (unit != null && unit.compilationResult != null && unit.compilationResult.hasErrors()) {
reportedErrors = true;
break;
}
@@ -273,8 +273,8 @@ public class AjCompilerAdapter extends AbstractCompilerAdapter {
private List getBinarySourcesFrom(Map binarySourceEntries) {
// Map is fileName |-> List<UnwovenClassFile>
List ret = new ArrayList();
- for (Iterator binIter = binarySourceEntries.keySet().iterator(); binIter.hasNext();) {
- String sourceFileName = (String) binIter.next();
+ for (Object o : binarySourceEntries.keySet()) {
+ String sourceFileName = (String) o;
List unwovenClassFiles = (List) binarySourceEntries.get(sourceFileName);
// XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit"
CompilationResult result = new CompilationResult(sourceFileName.toCharArray(), 0, 0, Integer.MAX_VALUE);
@@ -286,16 +286,16 @@ public class AjCompilerAdapter extends AbstractCompilerAdapter {
}
private void notifyRequestor() {
- for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) {
- InterimCompilationResult iresult = (InterimCompilationResult) iter.next();
+ for (Object o : resultsPendingWeave) {
+ InterimCompilationResult iresult = (InterimCompilationResult) o;
compiler.requestor.acceptResult(iresult.result().tagAsAccepted());
}
}
private void weave() throws IOException {
// ensure weaver state is set up correctly
- for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) {
- InterimCompilationResult iresult = (InterimCompilationResult) iter.next();
+ for (Object o : resultsPendingWeave) {
+ InterimCompilationResult iresult = (InterimCompilationResult) o;
for (int i = 0; i < iresult.unwovenClassFiles().length; i++) {
weaver.addClassFile(iresult.unwovenClassFiles()[i], false);
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java
index 77410281b..6ea878265 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java
@@ -191,8 +191,8 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
}
if (!reportedErrors && units != null) {
- for (int i = 0; i < units.length; i++) {
- if (units[i] != null && units[i].compilationResult != null && units[i].compilationResult.hasErrors()) {
+ for (CompilationUnitDeclaration unit : units) {
+ if (unit != null && unit.compilationResult != null && unit.compilationResult.hasErrors()) {
reportedErrors = true;
break; // TODO break or exit here?
}
@@ -202,11 +202,11 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
// Break the units into two lists...
List<CompilationUnitDeclaration> aspects = new ArrayList<CompilationUnitDeclaration>();
List<CompilationUnitDeclaration> nonaspects = new ArrayList<CompilationUnitDeclaration>();
- for (int i = 0; i < units.length; i++) {
- if (containsAnAspect(units[i])) {
- aspects.add(units[i]);
+ for (CompilationUnitDeclaration unit : units) {
+ if (containsAnAspect(unit)) {
+ aspects.add(unit);
} else {
- nonaspects.add(units[i]);
+ nonaspects.add(unit);
}
}
@@ -347,8 +347,8 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
int sourceStart = md.sourceStart;
int[] separators = md.compilationResult.lineSeparatorPositions;
int declarationStartLine = 1;
- for (int i = 0; i < separators.length; i++) {
- if (sourceStart < separators[i]) {
+ for (int separator : separators) {
+ if (sourceStart < separator) {
break;
}
declarationStartLine++;
@@ -385,8 +385,8 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
try {
// not great ... but one more check before we continue, see pr132314
if (!reportedErrors && units != null) {
- for (int i = 0; i < units.length; i++) {
- if (units[i] != null && units[i].compilationResult != null && units[i].compilationResult.hasErrors()) {
+ for (CompilationUnitDeclaration unit : units) {
+ if (unit != null && unit.compilationResult != null && unit.compilationResult.hasErrors()) {
reportedErrors = true;
break;
}
@@ -476,8 +476,7 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<UnwovenClassFile>> binarySourceEntries) {
// Map is fileName |-> List<UnwovenClassFile>
List<InterimCompilationResult> ret = new ArrayList<InterimCompilationResult>();
- for (Iterator<String> binIter = binarySourceEntries.keySet().iterator(); binIter.hasNext();) {
- String sourceFileName = binIter.next();
+ for (String sourceFileName : binarySourceEntries.keySet()) {
List<UnwovenClassFile> unwovenClassFiles = binarySourceEntries.get(sourceFileName);
// XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit"
CompilationResult result = new CompilationResult(sourceFileName.toCharArray(), 0, 0, Integer.MAX_VALUE);
@@ -489,8 +488,7 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
}
private void notifyRequestor() {
- for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) {
- InterimCompilationResult iresult = (InterimCompilationResult) iter.next();
+ for (InterimCompilationResult iresult : resultsPendingWeave) {
compiler.requestor.acceptResult(iresult.result().tagAsAccepted());
}
}
@@ -500,8 +498,7 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
if (debugPipeline) {
System.err.println(">.weaveQueuedEntries()");
}
- for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) {
- InterimCompilationResult iresult = (InterimCompilationResult) iter.next();
+ for (InterimCompilationResult iresult : resultsPendingWeave) {
for (int i = 0; i < iresult.unwovenClassFiles().length; i++) {
weaver.addClassFile(iresult.unwovenClassFiles()[i], false);
}
@@ -602,15 +599,14 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
private boolean containsAnAspect(CompilationUnitDeclaration cud) {
TypeDeclaration[] typeDecls = cud.types;
if (typeDecls != null) {
- for (int i = 0; i < typeDecls.length; i++) { // loop through top level types in the file
- TypeDeclaration declaration = typeDecls[i];
+ for (TypeDeclaration declaration : typeDecls) { // loop through top level types in the file
if (isAspect(declaration)) {
return true;
}
if (declaration.memberTypes != null) {
TypeDeclaration[] memberTypes = declaration.memberTypes;
- for (int j = 0; j < memberTypes.length; j++) { // loop through inner types
- if (containsAnAspect(memberTypes[j])) {
+ for (TypeDeclaration memberType : memberTypes) { // loop through inner types
+ if (containsAnAspect(memberType)) {
return true;
}
}
@@ -626,8 +622,8 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
}
if (tDecl.memberTypes != null) {
TypeDeclaration[] memberTypes = tDecl.memberTypes;
- for (int j = 0; j < memberTypes.length; j++) { // loop through inner types
- if (containsAnAspect(memberTypes[j])) {
+ for (TypeDeclaration memberType : memberTypes) { // loop through inner types
+ if (containsAnAspect(memberType)) {
return true;
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java
index dcee93802..77872416a 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java
@@ -42,13 +42,13 @@ public class ClassFileBasedByteCodeProvider
ClassFile[] cfs = result.getClassFiles();
UnwovenClassFile[] ret = new UnwovenClassFile[result.compiledTypes.size()];
int i=0;
- for (Iterator iterator = result.compiledTypes.keySet().iterator(); iterator.hasNext();) {
- char[] className = (char[])iterator.next();
- ClassFile cf = (ClassFile)result.compiledTypes.get(className);
+ for (Object o : result.compiledTypes.keySet()) {
+ char[] className = (char[]) o;
+ ClassFile cf = (ClassFile) result.compiledTypes.get(className);
// OPTIMIZE use char[] for classname
ClassFileBasedByteCodeProvider p = new ClassFileBasedByteCodeProvider(cf);
String fileName = nameProvider.getOutputClassFileName(cf.fileName(), result);
- ret[i++] = new UnwovenClassFileWithThirdPartyManagedBytecode(fileName,new String(className).replace('/','.'),p);
+ ret[i++] = new UnwovenClassFileWithThirdPartyManagedBytecode(fileName, new String(className).replace('/', '.'), p);
}
return ret;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java
index cfdc9da0a..9ba3a697a 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java
@@ -168,8 +168,8 @@ public class CommonPrinter {
protected StringBuilder printAnnotations(Annotation[] annotations) {
int length = annotations.length;
- for (int i = 0; i < length; i++) {
- printAnnotation(annotations[i]);
+ for (Annotation annotation : annotations) {
+ printAnnotation(annotation);
output.append(" "); //$NON-NLS-1$
}
return output;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java
index ebb82372f..83d528a90 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java
@@ -234,8 +234,8 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera
return true;
}
char[] victim = null;
- for (Iterator iter = aMap.keySet().iterator(); iter.hasNext();) {
- char[] thisKey = (char[]) iter.next();
+ for (Object o : aMap.keySet()) {
+ char[] thisKey = (char[]) o;
if (CharOperation.equals(thisKey, key)) {
// if (skey.equals(new String(thisKey))) {
victim = thisKey;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
index 78238afe7..eb5ca53d9 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
@@ -211,10 +211,10 @@ public class WeaverMessageHandler implements IMessageHandler {
boolean usedBinarySourceFileName) {
List<IProblem> ret = new ArrayList<IProblem>();
- for (int i = 0; i < sourceLocations.size(); i++) {
- ISourceLocation loc = (ISourceLocation) sourceLocations.get(i);
+ for (Object sourceLocation : sourceLocations) {
+ ISourceLocation loc = (ISourceLocation) sourceLocation;
if (loc != null) {
- DefaultProblem dp = new DefaultProblem(loc.getSourceFile().getPath().toCharArray(), "see also", 0, new String[] {},
+ DefaultProblem dp = new DefaultProblem(loc.getSourceFile().getPath().toCharArray(), "see also", 0, new String[]{},
ProblemSeverities.Ignore, getStartPos(loc, null), getEndPos(loc, null), loc.getLine(), loc.getColumn());
ret.add(dp);
} else {
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
index 2d2dd999c..91d998692 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
@@ -145,8 +145,7 @@ public class AdviceDeclaration extends AjMethodDeclaration {
proceedInInners = false;
declaredExceptions = new UnresolvedType[0];
- for (int i = 0; i < n; i++) {
- Proceed call = proceedCalls.get(i);
+ for (Proceed call : proceedCalls) {
if (call.inInner) {
// System.err.println("proceed in inner: " + call);
proceedInInners = true;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
index 8e9c04d16..247c7618f 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
@@ -48,8 +48,8 @@ public class AjConstructorDeclaration extends ConstructorDeclaration {
int[] separators = compilationResult().lineSeparatorPositions;
int declarationStartLine = 1;
- for (int i = 0; i < separators.length; i++) {
- if (sourceStart < separators[i]) break;
+ for (int separator : separators) {
+ if (sourceStart < separator) break;
declarationStartLine++;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
index f2a938c4e..8130d3ef4 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
@@ -66,8 +66,8 @@ public class AjMethodDeclaration extends MethodDeclaration {
int[] separators = compilationResult().lineSeparatorPositions;
int declarationStartLine = 1;
- for (int i = 0; i < separators.length; i++) {
- if (sourceStart < separators[i]) break;
+ for (int separator : separators) {
+ if (sourceStart < separator) break;
declarationStartLine++;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
index deea7f3f4..78cca38c0 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
@@ -317,9 +317,9 @@ public class AspectDeclaration extends TypeDeclaration {
}
}
if (memberTypes != null) {
- for (int i = 0; i < memberTypes.length; i++) {
- if (memberTypes[i] instanceof IntertypeMemberClassDeclaration) {
- IntertypeMemberClassDeclaration itdMemberClassDeclaration = (IntertypeMemberClassDeclaration) memberTypes[i];
+ for (TypeDeclaration memberType : memberTypes) {
+ if (memberType instanceof IntertypeMemberClassDeclaration) {
+ IntertypeMemberClassDeclaration itdMemberClassDeclaration = (IntertypeMemberClassDeclaration) memberType;
AjAttribute attribute = itdMemberClassDeclaration.getAttribute();
if (attribute != null) {
classFile.extraAttributes.add(new EclipseAttributeAdapter(attribute));
@@ -340,8 +340,8 @@ public class AspectDeclaration extends TypeDeclaration {
*/
@SuppressWarnings("unchecked")
private void addVersionAttributeIfNecessary(ClassFile classFile) {
- for (Iterator iter = classFile.extraAttributes.iterator(); iter.hasNext();) {
- EclipseAttributeAdapter element = (EclipseAttributeAdapter) iter.next();
+ for (Object o : classFile.extraAttributes) {
+ EclipseAttributeAdapter element = (EclipseAttributeAdapter) o;
if (CharOperation.equals(element.getNameChars(), weaverVersionChars)) {
return;
}
@@ -352,12 +352,10 @@ public class AspectDeclaration extends TypeDeclaration {
private static char[] weaverVersionChars = "org.aspectj.weaver.WeaverVersion".toCharArray();
private void generateInlineAccessMembers(ClassFile classFile) {
- for (Iterator<SuperAccessMethodPair> i = superAccessForInline.values().iterator(); i.hasNext();) {
- AccessForInlineVisitor.SuperAccessMethodPair pair = i.next();
+ for (SuperAccessMethodPair pair : superAccessForInline.values()) {
generateSuperAccessMethod(classFile, pair.accessMethod, pair.originalMethod);
}
- for (Iterator<Map.Entry<ResolvedMember, Binding>> i = accessForInline.entrySet().iterator(); i.hasNext();) {
- Map.Entry<ResolvedMember, Binding> e = i.next();
+ for (Map.Entry<ResolvedMember, Binding> e : accessForInline.entrySet()) {
generateInlineAccessMethod(classFile, e.getValue(), e.getKey());
}
}
@@ -1140,9 +1138,9 @@ public class AspectDeclaration extends TypeDeclaration {
public void processIntertypeMemberTypes(ClassScope classScope) {
factory = EclipseFactory.fromScopeLookupEnvironment(scope);
if (memberTypes != null) {
- for (int i = 0; i < memberTypes.length; i++) {
- if (memberTypes[i] instanceof IntertypeMemberClassDeclaration) {
- EclipseTypeMunger m = ((IntertypeMemberClassDeclaration) memberTypes[i]).build(classScope);
+ for (TypeDeclaration memberType : memberTypes) {
+ if (memberType instanceof IntertypeMemberClassDeclaration) {
+ EclipseTypeMunger m = ((IntertypeMemberClassDeclaration) memberType).build(classScope);
if (m != null) {
mungeNewInnerClass(m, factory);
concreteName.typeMungers.add(m);
@@ -1166,14 +1164,14 @@ public class AspectDeclaration extends TypeDeclaration {
buildPerClause(scope);
if (methods != null) {
- for (int i = 0; i < methods.length; i++) {
- if (methods[i] instanceof InterTypeDeclaration) {
- EclipseTypeMunger m = ((InterTypeDeclaration) methods[i]).build(classScope);
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration method : methods) {
+ if (method instanceof InterTypeDeclaration) {
+ EclipseTypeMunger m = ((InterTypeDeclaration) method).build(classScope);
if (m != null) {
concreteName.typeMungers.add(m);
}
- } else if (methods[i] instanceof DeclareDeclaration) {
- Declare d = ((DeclareDeclaration) methods[i]).build(classScope);
+ } else if (method instanceof DeclareDeclaration) {
+ Declare d = ((DeclareDeclaration) method).build(classScope);
if (d != null) {
concreteName.declares.add(d);
}
@@ -1257,8 +1255,8 @@ public class AspectDeclaration extends TypeDeclaration {
// TODO should probably avoid putting it onto BTBs at all (since already there)
if (!(targetSourceTypeBinding instanceof BinaryTypeBinding)) {
ReferenceBinding[] existingMemberTypes = targetSourceTypeBinding.memberTypes();
- for (int i = 0; i < existingMemberTypes.length; i++) {
- char[] compounded = CharOperation.concatWith(existingMemberTypes[i].compoundName, '.');
+ for (ReferenceBinding existingMemberType : existingMemberTypes) {
+ char[] compounded = CharOperation.concatWith(existingMemberType.compoundName, '.');
if (CharOperation.endsWith(compounded, mungerMemberTypeName)) {
scope.problemReporter().signalError(sourceStart(), sourceEnd(),
"target type already declares a member type with the name '" + munger.getMemberTypeName() + "'");
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
index fddcc3b90..1afb46a7c 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
@@ -131,12 +131,12 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
private boolean suppressingNoExplicitConstructorCall() {
if (this.annotations == null)
return false;
- for (int i = 0; i < this.annotations.length; i++) {
- if (new String(this.annotations[i].resolvedType.signature()).equals(SUPPRESSAJWARNINGS)) {
- if (this.annotations[i] instanceof MarkerAnnotation) {
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation : this.annotations) {
+ if (new String(annotation.resolvedType.signature()).equals(SUPPRESSAJWARNINGS)) {
+ if (annotation instanceof MarkerAnnotation) {
return true;
- } else if (this.annotations[i] instanceof SingleMemberAnnotation) {
- SingleMemberAnnotation sma = (SingleMemberAnnotation) this.annotations[i];
+ } else if (annotation instanceof SingleMemberAnnotation) {
+ SingleMemberAnnotation sma = (SingleMemberAnnotation) annotation;
if (sma.memberValue instanceof ArrayInitializer) {
ArrayInitializer memberValue = (ArrayInitializer) sma.memberValue;
for (int j = 0; j < memberValue.expressions.length; j++) {
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
index 89d2482c7..bbff3e136 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
@@ -358,8 +358,8 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration {
ParameterizedSingleTypeReference paramRef = (ParameterizedSingleTypeReference) onType;
TypeReference[] rb = paramRef.typeArguments;
typeVariableAliases = new ArrayList();
- for (int i = 0; i < rb.length; i++) {
- typeVariableAliases.add(CharOperation.toString(rb[i].getTypeName()));
+ for (TypeReference typeReference : rb) {
+ typeVariableAliases.add(CharOperation.toString(typeReference.getTypeName()));
}
} else if (onType instanceof ParameterizedQualifiedTypeReference) {
ParameterizedQualifiedTypeReference paramRef = (ParameterizedQualifiedTypeReference) onType;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
index 9b6d7ddcc..89e066df5 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
@@ -341,8 +341,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
} else {
if (!onTypeBinding.isInterface()) {
FieldBinding[] existingFields = onTypeBinding.fields();
- for (int f = 0; f < existingFields.length; f++) {
- FieldBinding fieldBinding = existingFields[f];
+ for (FieldBinding fieldBinding : existingFields) {
if (CharOperation.equals(fieldBinding.name, sig.getName().toCharArray())) {
fieldMunger.version = NewFieldTypeMunger.VersionOne;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
index 01e975a63..70811e090 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
@@ -162,9 +162,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
ReferenceBinding supertype = onTypeBinding.superclass();
while (supertype != null && reportError) {
MethodBinding[] possibles = supertype.getMethods(declaredSelector);
- for (int i = 0; i < possibles.length; i++) {
- MethodBinding mb = possibles[i];
-
+ for (MethodBinding mb : possibles) {
boolean couldBeMatch = true;
if (mb.parameters.length != realthing.parameters.length)
couldBeMatch = false;
@@ -290,11 +288,11 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
Argument[] itdArgs = this.arguments;
if (itdArgs != null) {
- for (int a = 0; a < itdArgs.length; a++) {
- LocalVariableBinding lvb = itdArgs[a].binding;
+ for (Argument itdArg : itdArgs) {
+ LocalVariableBinding lvb = itdArg.binding;
LocalVariableBinding lvbCopy = new LocalVariableBinding(lvb.name, lvb.type, lvb.modifiers, true);
// e37: have to create a declaration so that the check in ClassFile (line 2538) won't skip it
- lvbCopy.declaration = new LocalDeclaration(itdArgs[a].name,0,0);
+ lvbCopy.declaration = new LocalDeclaration(itdArg.name, 0, 0);
codeStream.record(lvbCopy);
lvbCopy.recordInitializationStartPC(0);
lvbCopy.resolvedPosition = lvb.resolvedPosition;
@@ -311,9 +309,9 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
codeStream.aload_0();
resolvedPosition = 1;
}
- for (int i = 0; i < length; i++) {
- codeStream.load(parameters[i], resolvedPosition);
- if ((parameters[i] == TypeBinding.DOUBLE) || (parameters[i] == TypeBinding.LONG))
+ for (TypeBinding parameter : parameters) {
+ codeStream.load(parameter, resolvedPosition);
+ if ((parameter == TypeBinding.DOUBLE) || (parameter == TypeBinding.LONG))
resolvedPosition += 2;
else
resolvedPosition++;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
index 087e87d6c..70a610950 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
@@ -268,8 +268,8 @@ public class PointcutDeclaration extends AjMethodDeclaration {
* is added. So, this method adds the attribute if someone else hasn't already.
*/
private void addVersionAttributeIfNecessary(ClassFile classFile) {
- for (Iterator iter = classFile.extraAttributes.iterator(); iter.hasNext();) {
- EclipseAttributeAdapter element = (EclipseAttributeAdapter) iter.next();
+ for (Object o : classFile.extraAttributes) {
+ EclipseAttributeAdapter element = (EclipseAttributeAdapter) o;
if (CharOperation.equals(element.getNameChars(), weaverVersionChars))
return;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/Proceed.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/Proceed.java
index bd8e4db35..743e8c204 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/Proceed.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/Proceed.java
@@ -104,9 +104,9 @@ public class Proceed extends MessageSend {
}
boolean argsContainCast = false;
- for (int i=0; i<arguments.length;i++) {
- if (arguments[i] instanceof CastExpression) argsContainCast = true;
- // if (arguments[i].constant==null) arguments[i].constant=Constant.NotAConstant;
+ for (Expression argument : arguments) {
+ if (argument instanceof CastExpression) argsContainCast = true;
+ // if (arguments[i].constant==null) arguments[i].constant=Constant.NotAConstant;
}
// TypeBinding[] argumentTypes = Binding.NO_PARAMETERS;
// if (this.arguments != null) {
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java
index 4777d0faf..8e0f2a635 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java
@@ -153,8 +153,8 @@ public class PseudoTokens extends ASTNode {
public void postParse(TypeDeclaration typeDec, MethodDeclaration enclosingDec) {
int counter = 0; // Counter can be used by postParse as a value to compute uniqueness (if required)
- for (int i=0, len=tokens.length; i < len; i++) {
- counter+=tokens[i].postParse(typeDec, enclosingDec, counter);
+ for (PseudoToken token : tokens) {
+ counter += token.postParse(typeDec, enclosingDec, counter);
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
index 96f0d3227..79f31f94e 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
@@ -63,9 +63,9 @@ public class SuperFixerVisitor extends ASTVisitor {
localTypeDeclaration.binding.modifiers |=Modifier.PUBLIC;
MethodBinding[] bindings = localTypeDeclaration.binding.methods;
if (bindings!=null) {
- for (int i=0,max=bindings.length;i<max;i++) {
- if (CharOperation.equals(bindings[i].selector,ctor)) {
- bindings[i].modifiers|=Modifier.PUBLIC;
+ for (MethodBinding binding : bindings) {
+ if (CharOperation.equals(binding.selector, ctor)) {
+ binding.modifiers |= Modifier.PUBLIC;
}
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java
index 90ca34c45..6698787f0 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java
@@ -370,8 +370,8 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor {
if (arguments == null) {
return names;
} else {
- for (int i = 0; i < arguments.length; i++) {
- names.add(new String(arguments[i].name));
+ for (Argument argument : arguments) {
+ names.add(new String(argument.name));
}
return names;
}
@@ -486,10 +486,10 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor {
MemberValuePair[] mvps = ann.memberValuePairs;
if (mvps == null)
return null;
- for (int i = 0; i < mvps.length; i++) {
- if (CharOperation.equals(memberName.toCharArray(), mvps[i].name)) {
- if (mvps[i].value instanceof StringLiteral) {
- StringLiteral sv = (StringLiteral) mvps[i].value;
+ for (MemberValuePair mvp : mvps) {
+ if (CharOperation.equals(memberName.toCharArray(), mvp.name)) {
+ if (mvp.value instanceof StringLiteral) {
+ StringLiteral sv = (StringLiteral) mvp.value;
location[0] = sv.sourceStart;
location[1] = sv.sourceEnd;
return new String(sv.source());
@@ -686,45 +686,45 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor {
public AspectJAnnotations(Annotation[] annotations) {
if (annotations == null)
return;
- for (int i = 0; i < annotations.length; i++) {
- if (annotations[i].resolvedType == null)
+ for (Annotation annotation : annotations) {
+ if (annotation.resolvedType == null)
continue; // user messed up annotation declaration
- char[] sig = annotations[i].resolvedType.signature();
+ char[] sig = annotation.resolvedType.signature();
if (CharOperation.equals(afterAdviceSig, sig)) {
adviceKind = AdviceKind.After;
- addAdviceAnnotation(annotations[i]);
+ addAdviceAnnotation(annotation);
} else if (CharOperation.equals(afterReturningAdviceSig, sig)) {
adviceKind = AdviceKind.AfterReturning;
- addAdviceAnnotation(annotations[i]);
+ addAdviceAnnotation(annotation);
} else if (CharOperation.equals(afterThrowingAdviceSig, sig)) {
adviceKind = AdviceKind.AfterThrowing;
- addAdviceAnnotation(annotations[i]);
+ addAdviceAnnotation(annotation);
} else if (CharOperation.equals(beforeAdviceSig, sig)) {
adviceKind = AdviceKind.Before;
- addAdviceAnnotation(annotations[i]);
+ addAdviceAnnotation(annotation);
} else if (CharOperation.equals(aroundAdviceSig, sig)) {
adviceKind = AdviceKind.Around;
- addAdviceAnnotation(annotations[i]);
+ addAdviceAnnotation(annotation);
} else if (CharOperation.equals(adviceNameSig, sig)) {
hasAdviceNameAnnotation = true;
- adviceNameAnnotation = annotations[i];
+ adviceNameAnnotation = annotation;
} else if (CharOperation.equals(declareParentsSig, sig)) {
hasDeclareParents = true;
} else if (CharOperation.equals(aspectSig, sig)) {
if (hasAspectAnnotation) {
hasMultipleAspectAnnotations = true;
- duplicateAspectAnnotation = annotations[i];
+ duplicateAspectAnnotation = annotation;
} else {
hasAspectAnnotation = true;
- aspectAnnotation = annotations[i];
+ aspectAnnotation = annotation;
}
} else if (CharOperation.equals(pointcutSig, sig)) {
if (hasPointcutAnnotation) {
hasMultiplePointcutAnnotations = true;
- duplicatePointcutAnnotation = annotations[i];
+ duplicatePointcutAnnotation = annotation;
} else {
hasPointcutAnnotation = true;
- pointcutAnnotation = annotations[i];
+ pointcutAnnotation = annotation;
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
index efd1a2ba2..0384617f9 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
@@ -172,12 +172,12 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
// them in the factory
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
- for (int j = 0; j < b.length; j++) {
- factory.addSourceTypeBinding(b[j], units[i]);
- if (b[j].superclass instanceof MissingTypeBinding) {
+ for (SourceTypeBinding sourceTypeBinding : b) {
+ factory.addSourceTypeBinding(sourceTypeBinding, units[i]);
+ if (sourceTypeBinding.superclass instanceof MissingTypeBinding) {
// e37: Undoing the work in ClassScope.connectSuperClass() as it will lead to cascade errors
// TODO allow MissingTypeBinding through here and cope with it in all situations later?
- b[j].superclass = units[i].scope.getJavaLangObject();
+ sourceTypeBinding.superclass = units[i].scope.getJavaLangObject();
}
}
}
@@ -195,8 +195,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
CompilationUnitScope cus = units[i].scope;
SourceTypeBinding[] stbs = cus.topLevelTypes;
- for (int j = 0; j < stbs.length; j++) {
- SourceTypeBinding stb = stbs[j];
+ for (SourceTypeBinding stb : stbs) {
typesToProcess.add(stb);
TypeDeclaration typeDeclaration = stb.scope.referenceContext;
if (typeDeclaration instanceof AspectDeclaration) {
@@ -255,8 +254,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
CompilationUnitScope cus = units[i].scope;
SourceTypeBinding[] stbs = cus.topLevelTypes;
- for (int j = 0; j < stbs.length; j++) {
- SourceTypeBinding stb = stbs[j];
+ for (SourceTypeBinding stb : stbs) {
typesToProcess.add(stb);
}
}
@@ -287,20 +285,20 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
- for (int j = 0; j < b.length; j++) {
+ for (SourceTypeBinding sourceTypeBinding : b) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.RESOLVING_POINTCUT_DECLARATIONS, b[j].sourceName);
- resolvePointcutDeclarations(b[j].scope);
+ CompilationAndWeavingContext.RESOLVING_POINTCUT_DECLARATIONS, sourceTypeBinding.sourceName);
+ resolvePointcutDeclarations(sourceTypeBinding.scope);
CompilationAndWeavingContext.leavingPhase(tok);
}
}
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
- for (int j = 0; j < b.length; j++) {
+ for (SourceTypeBinding sourceTypeBinding : b) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.ADDING_DECLARE_WARNINGS_AND_ERRORS, b[j].sourceName);
- addAdviceLikeDeclares(b[j].scope);
+ CompilationAndWeavingContext.ADDING_DECLARE_WARNINGS_AND_ERRORS, sourceTypeBinding.sourceName);
+ addAdviceLikeDeclares(sourceTypeBinding.scope);
CompilationAndWeavingContext.leavingPhase(tok);
}
}
@@ -390,8 +388,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
// now check our membertypes (pr119570)
ReferenceBinding[] memberTypes = sourceType.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- SourceTypeBinding rb = (SourceTypeBinding) memberTypes[i];
+ for (ReferenceBinding memberType : memberTypes) {
+ SourceTypeBinding rb = (SourceTypeBinding) memberType;
if (!rb.superclass().equals(sourceType)) {
doSupertypesFirst(rb.superclass(), yetToProcess);
}
@@ -424,16 +422,14 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
// Then look at the superinterface list
ReferenceBinding[] interfaceTypes = typeToWeave.superInterfaces();
- for (int i = 0; i < interfaceTypes.length; i++) {
- ReferenceBinding binding = interfaceTypes[i];
+ for (ReferenceBinding binding : interfaceTypes) {
if (typesToProcess.contains(binding) && binding instanceof SourceTypeBinding) {
// System.err.println("Recursing to superinterface "+new
// String(binding.getFileName()));
weaveIntertypes(typesToProcess, (SourceTypeBinding) binding, typeMungers, declareParents, declareAnnotationOnTypes,
mode);
- }
- else if (binding instanceof ParameterizedTypeBinding && (((ParameterizedTypeBinding)binding).type instanceof SourceTypeBinding) && typesToProcess.contains(((ParameterizedTypeBinding)binding).type)) {
- weaveIntertypes(typesToProcess, (SourceTypeBinding) ((ParameterizedTypeBinding)binding).type, typeMungers, declareParents, declareAnnotationOnTypes, mode);
+ } else if (binding instanceof ParameterizedTypeBinding && (((ParameterizedTypeBinding) binding).type instanceof SourceTypeBinding) && typesToProcess.contains(((ParameterizedTypeBinding) binding).type)) {
+ weaveIntertypes(typesToProcess, (SourceTypeBinding) ((ParameterizedTypeBinding) binding).type, typeMungers, declareParents, declareAnnotationOnTypes, mode);
}
}
weaveInterTypeDeclarations(typeToWeave, typeMungers, declareParents, declareAnnotationOnTypes, false, mode);
@@ -460,8 +456,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
SourceTypeBinding sourceType = s.referenceContext.binding;
ReferenceBinding[] memberTypes = sourceType.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- addAdviceLikeDeclares(((SourceTypeBinding) memberTypes[i]).scope);
+ for (ReferenceBinding memberType : memberTypes) {
+ addAdviceLikeDeclares(((SourceTypeBinding) memberType).scope);
}
}
@@ -479,8 +475,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
SourceTypeBinding sourceType = s.referenceContext.binding;
ReferenceBinding[] memberTypes = sourceType.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- addCrosscuttingStructures(((SourceTypeBinding) memberTypes[i]).scope);
+ for (ReferenceBinding memberType : memberTypes) {
+ addCrosscuttingStructures(((SourceTypeBinding) memberType).scope);
}
}
@@ -491,14 +487,14 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
AbstractMethodDeclaration[] methods = dec.methods;
boolean initializedMethods = false;
if (methods != null) {
- for (int i = 0; i < methods.length; i++) {
- if (methods[i] instanceof PointcutDeclaration) {
+ for (AbstractMethodDeclaration method : methods) {
+ if (method instanceof PointcutDeclaration) {
hasPointcuts = true;
if (!initializedMethods) {
sourceType.methods(); // force initialization
initializedMethods = true;
}
- ((PointcutDeclaration) methods[i]).resolvePointcut(s);
+ ((PointcutDeclaration) method).resolvePointcut(s);
}
}
}
@@ -510,8 +506,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
ReferenceBinding[] memberTypes = sourceType.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- resolvePointcutDeclarations(((SourceTypeBinding) memberTypes[i]).scope);
+ for (ReferenceBinding memberType : memberTypes) {
+ resolvePointcutDeclarations(((SourceTypeBinding) memberType).scope);
}
}
@@ -567,8 +563,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
System.err.println("Unexpectedly found null for memberTypes of " + sourceType.debugName());
}
if (memberTypes != null) {
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- buildInterTypeAndPerClause(((SourceTypeBinding) memberTypes[i]).scope);
+ for (ReferenceBinding memberType : memberTypes) {
+ buildInterTypeAndPerClause(((SourceTypeBinding) memberType).scope);
}
}
}
@@ -713,8 +709,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
// Check if the type we are looking at is the topMostImplementor of a
// dangerous interface -
// report a problem if it is.
- for (Iterator i = dangerousInterfaces.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
+ for (Object o : dangerousInterfaces.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
ResolvedType interfaceType = (ResolvedType) entry.getKey();
if (onType.isTopmostImplementor(interfaceType)) {
factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null);
@@ -804,8 +800,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
}
if (mode == 0 || mode == 2) {
- for (Iterator<ConcreteTypeMunger> i = typeMungers.iterator(); i.hasNext();) {
- EclipseTypeMunger munger = (EclipseTypeMunger) i.next();
+ for (ConcreteTypeMunger typeMunger : typeMungers) {
+ EclipseTypeMunger munger = (EclipseTypeMunger) typeMunger;
if (munger.matches(onType)) {
// if (needOldStyleWarning) {
// factory.showMessage(IMessage.WARNING, "The class for " + onType
@@ -827,8 +823,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
onType.checkInterTypeMungers();
- for (Iterator i = onType.getInterTypeMungers().iterator(); i.hasNext();) {
- EclipseTypeMunger munger = (EclipseTypeMunger) i.next();
+ for (ConcreteTypeMunger concreteTypeMunger : onType.getInterTypeMungers()) {
+ EclipseTypeMunger munger = (EclipseTypeMunger) concreteTypeMunger;
if (munger.getMunger() == null || munger.getMunger().getKind() != ResolvedTypeMunger.InnerClass) {
if (munger.munge(sourceType, onType)) {
if (factory.pushinCollector != null) {
@@ -860,9 +856,9 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
ReferenceBinding[] memberTypes = sourceType.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- if (memberTypes[i] instanceof SourceTypeBinding) {
- weaveInterTypeDeclarations((SourceTypeBinding) memberTypes[i], typeMungers, declareParents,
+ for (ReferenceBinding memberType : memberTypes) {
+ if (memberType instanceof SourceTypeBinding) {
+ weaveInterTypeDeclarations((SourceTypeBinding) memberType, typeMungers, declareParents,
declareAnnotationOnTypes, false, mode);
}
}
@@ -878,8 +874,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
private void processTypeMungersFromExistingWeaverState(SourceTypeBinding sourceType, ResolvedType onType) {
List<ConcreteTypeMunger> previouslyAppliedMungers = onType.getWeaverState().getTypeMungers(onType);
- for (Iterator<ConcreteTypeMunger> i = previouslyAppliedMungers.iterator(); i.hasNext();) {
- ConcreteTypeMunger m = i.next();
+ for (ConcreteTypeMunger m : previouslyAppliedMungers) {
EclipseTypeMunger munger = factory.makeEclipseTypeMunger(m);
if (munger.munge(sourceType, onType)) {
if (onType.isInterface() && munger.getMunger().needsAccessToTopmostImplementor()) {
@@ -899,8 +894,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
ResolvedType resolvedSourceType = factory.fromEclipse(sourceType);
List<ResolvedType> newParents = declareParents.findMatchingNewParents(resolvedSourceType, false);
if (!newParents.isEmpty()) {
- for (Iterator<ResolvedType> i = newParents.iterator(); i.hasNext();) {
- ResolvedType parent = i.next();
+ for (ResolvedType parent : newParents) {
if (dangerousInterfaces.containsKey(parent)) {
ResolvedType onType = factory.fromEclipse(sourceType);
factory.showMessage(IMessage.ERROR, onType + ": " + dangerousInterfaces.get(parent),
@@ -1128,8 +1122,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
Annotation currentAnnotations[] = sourceType.scope.referenceContext.annotations;
if (currentAnnotations != null) {
- for (int i = 0; i < currentAnnotations.length; i++) {
- Annotation annotation = currentAnnotations[i];
+ for (Annotation annotation : currentAnnotations) {
String a = CharOperation.toString(annotation.type.getTypeName());
String b = CharOperation.toString(toAdd[0].type.getTypeName());
// FIXME asc we have a lint for attempting to add an annotation
@@ -1209,9 +1202,9 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
ResolvedMember[] methods = rt.getDeclaredMethods();
ResolvedMember decaMethod = null;
String nameToLookFor = decA.getAnnotationMethod();
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().equals(nameToLookFor)) {
- decaMethod = methods[i];
+ for (ResolvedMember method : methods) {
+ if (method.getName().equals(nameToLookFor)) {
+ decaMethod = method;
break;
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
index a520124da..3d2fb727f 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
@@ -73,14 +73,13 @@ public class EclipseAnnotationConvertor {
MemberValuePair[] memberValuePairs = normalAnnotation.memberValuePairs;
if (memberValuePairs != null) {
int memberValuePairsLength = memberValuePairs.length;
- for (int i = 0; i < memberValuePairsLength; i++) {
- MemberValuePair memberValuePair = memberValuePairs[i];
+ for (MemberValuePair memberValuePair : memberValuePairs) {
MethodBinding methodBinding = memberValuePair.binding;
if (methodBinding == null) {
// is this just a marker annotation?
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation [" + annotation
- + "]");
+ + "]");
} else {
AnnotationValue av = generateElementValue(memberValuePair.value, methodBinding.returnType);
AnnotationNameValuePair anvp = new AnnotationNameValuePair(new String(memberValuePair.name), av);
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index 47357df67..6e9fafff9 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -654,8 +654,8 @@ public class EclipseFactory {
}
UnresolvedType[] typeArguments = typeX.getTypeParameters();
if (typeArguments != null) {
- for (int i = 0; i < typeArguments.length; i++) {
- if (typeArguments[i].isTypeVariableReference()) {
+ for (UnresolvedType typeArgument : typeArguments) {
+ if (typeArgument.isTypeVariableReference()) {
return true;
}
}
@@ -1177,8 +1177,8 @@ public class EclipseFactory {
}
ReferenceBinding[] memberTypes = binding.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++) {
- addSourceTypeBinding((SourceTypeBinding) memberTypes[i], unit);
+ for (ReferenceBinding memberType : memberTypes) {
+ addSourceTypeBinding((SourceTypeBinding) memberType, unit);
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java
index ecd4f3ddd..3fa41b1ea 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java
@@ -80,8 +80,7 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
if (annotationTypes == null) {
return false;
}
- for (int i = 0; i < annotationTypes.length; i++) {
- ResolvedType type = annotationTypes[i];
+ for (ResolvedType type : annotationTypes) {
if (type.equals(ofType)) {
return true;
}
@@ -126,8 +125,7 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
if (annos == null) {
return null;
}
- for (int i = 0; i < annos.length; i++) {
- Annotation anno = annos[i];
+ for (Annotation anno : annos) {
UnresolvedType ut = UnresolvedType.forSignature(new String(anno.resolvedType.signature()));
if (w.resolve(ut).equals(ofType)) {
// Found the one
@@ -335,10 +333,9 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
// Grab the set of bindings with matching selector
MethodBinding[] mb = ((MethodBinding) realBinding).declaringClass.getMethods(methodBinding.selector);
if (mb != null) {
- for (int m = 0, max = mb.length; m < max; m++) {
- MethodBinding candidate = mb[m];
+ for (MethodBinding candidate : mb) {
if (candidate instanceof InterTypeMethodBinding) {
- if (InterTypeMemberFinder.matches(mb[m], methodBinding)) {
+ if (InterTypeMemberFinder.matches(candidate, methodBinding)) {
InterTypeMethodBinding intertypeMethodBinding = (InterTypeMethodBinding) candidate;
Annotation[] annos = intertypeMethodBinding.sourceMethod.annotations;
return annos;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java
index 2b3467ea3..26c260628 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java
@@ -181,8 +181,7 @@ public class EclipseScope implements IScope {
}
ImportBinding[] imports = cuScope.imports;
- for (int i = 0; i < imports.length; i++) {
- ImportBinding importBinding = imports[i];
+ for (ImportBinding importBinding : imports) {
String importName = new String(CharOperation.concatWith(importBinding.compoundName, '.'));
// XXX wrong behavior for java.util.Map.*
@@ -194,8 +193,8 @@ public class EclipseScope implements IScope {
}
TypeBinding[] topTypes = cuScope.topLevelTypes;
- for (int i = 0; i < topTypes.length; i++) {
- importedNamesList.add(world.fromBinding(topTypes[i]).getName());
+ for (TypeBinding topType : topTypes) {
+ importedNamesList.add(world.fromBinding(topType).getName());
}
importedNames = importedNamesList.toArray(new String[importedNamesList.size()]);
@@ -211,8 +210,8 @@ public class EclipseScope implements IScope {
addClassAndParentsToPrefixes(binding.superclass(), importedPrefixesList);
ReferenceBinding[] superinterfaces = binding.superInterfaces();
if (superinterfaces != null) {
- for (int i = 0; i < superinterfaces.length; i++) {
- addClassAndParentsToPrefixes(superinterfaces[i], importedPrefixesList);
+ for (ReferenceBinding superinterface : superinterfaces) {
+ addClassAndParentsToPrefixes(superinterface, importedPrefixesList);
}
}
}
@@ -233,9 +232,9 @@ public class EclipseScope implements IScope {
// XXX add good errors when would bind to extra parameters
@Override
public FormalBinding lookupFormal(String name) {
- for (int i = 0, len = bindings.length; i < len; i++) {
- if (bindings[i].getName().equals(name))
- return bindings[i];
+ for (FormalBinding binding : bindings) {
+ if (binding.getName().equals(name))
+ return binding;
}
return null;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
index 349758e36..efd4fb0db 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
@@ -176,8 +176,8 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
return false;
}
ResolvedType[] annotations = getAnnotationTypes();
- for (int i = 0; i < annotations.length; i++) {
- if ("org.aspectj.lang.annotation.Aspect".equals(annotations[i].getName())) {
+ for (ResolvedType annotation : annotations) {
+ if ("org.aspectj.lang.annotation.Aspect".equals(annotation.getName())) {
return true;
}
}
@@ -190,19 +190,19 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
if (ans == null) {
return "";
}
- for (int i = 0; i < ans.length; i++) {
- if (ans[i].resolvedType == null) {
+ for (Annotation an : ans) {
+ if (an.resolvedType == null) {
continue; // XXX happens if we do this very early from
}
// buildInterTypeandPerClause
// may prevent us from resolving references made in @Pointcuts to
// an @Pointcut in a code-style aspect
- char[] sig = ans[i].resolvedType.signature();
+ char[] sig = an.resolvedType.signature();
if (CharOperation.equals(pointcutSig, sig)) {
- if (ans[i].memberValuePairs().length == 0) {
+ if (an.memberValuePairs().length == 0) {
return ""; // empty pointcut expression
}
- Expression expr = ans[i].memberValuePairs()[0].value;
+ Expression expr = an.memberValuePairs()[0].value;
if (expr instanceof StringLiteral) {
StringLiteral sLit = ((StringLiteral) expr);
return new String(sLit.source());
@@ -223,14 +223,14 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
if (annotations == null) {
return false;
}
- for (int i = 0; i < annotations.length; i++) {
- if (annotations[i].resolvedType == null) {
+ for (Annotation annotation : annotations) {
+ if (annotation.resolvedType == null) {
continue; // XXX happens if we do this very early from
}
// buildInterTypeandPerClause
// may prevent us from resolving references made in @Pointcuts to
// an @Pointcut in a code-style aspect
- char[] sig = annotations[i].resolvedType.signature();
+ char[] sig = annotation.resolvedType.signature();
if (CharOperation.equals(pointcutSig, sig)) {
return true;
}
@@ -266,8 +266,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
// sure bindings are completed
AbstractMethodDeclaration[] methods = declaration.methods;
if (methods != null) {
- for (int i = 0, len = methods.length; i < len; i++) {
- AbstractMethodDeclaration amd = methods[i];
+ for (AbstractMethodDeclaration amd : methods) {
if (amd == null || amd.ignoreFurtherInvestigation) {
continue;
}
@@ -326,16 +325,15 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
if (isEnum()) {
// The bindings for the eclipse binding will include values/valueof
- for (int m=0,len=ms.length;m<len;m++) {
- MethodBinding mb = ms[m];
+ for (MethodBinding mb : ms) {
if ((mb instanceof SyntheticMethodBinding) && mb.isStatic()) { // cannot use .isSynthetic() because it isn't truly synthetic
- if (CharOperation.equals(mb.selector,valuesCharArray) && mb.parameters.length==0 && mb.returnType.isArrayType() && ((ArrayBinding)mb.returnType).leafComponentType()==binding) {
+ if (CharOperation.equals(mb.selector, valuesCharArray) && mb.parameters.length == 0 && mb.returnType.isArrayType() && ((ArrayBinding) mb.returnType).leafComponentType() == binding) {
// static <EnumType>[] values()
ResolvedMember valuesMember = factory.makeResolvedMember(mb);
valuesMember.setSourceContext(new EclipseSourceContext(unit.compilationResult, 0));
valuesMember.setPosition(0, 0);
declaredMethods.add(valuesMember);
- } else if (CharOperation.equals(mb.selector,valueOfCharArray) && mb.parameters.length==1 && CharOperation.equals(mb.parameters[0].signature(),jlString) && mb.returnType==binding) {
+ } else if (CharOperation.equals(mb.selector, valueOfCharArray) && mb.parameters.length == 1 && CharOperation.equals(mb.parameters[0].signature(), jlString) && mb.returnType == binding) {
// static <EnumType> valueOf(String)
ResolvedMember valueOfMember = factory.makeResolvedMember(mb);
valueOfMember.setSourceContext(new EclipseSourceContext(unit.compilationResult, 0));
@@ -347,8 +345,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
}
FieldBinding[] fields = binding.fields();
- for (int i = 0, len = fields.length; i < len; i++) {
- FieldBinding f = fields[i];
+ for (FieldBinding f : fields) {
declaredFields.add(factory.makeResolvedMember(f));
}
@@ -677,8 +674,8 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
@Override
public boolean hasAnnotation(UnresolvedType ofType) {
ensureAnnotationTypesResolved();
- for (int a = 0, max = annotationTypes.length; a < max; a++) {
- if (ofType.equals(annotationTypes[a])) {
+ for (ResolvedType annotationType : annotationTypes) {
+ if (ofType.equals(annotationType)) {
return true;
}
}
@@ -763,8 +760,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
MemberValuePair[] memberValuePairs = normalAnnotation.memberValuePairs;
if (memberValuePairs != null) {
int memberValuePairsLength = memberValuePairs.length;
- for (int i = 0; i < memberValuePairsLength; i++) {
- MemberValuePair memberValuePair = memberValuePairs[i];
+ for (MemberValuePair memberValuePair : memberValuePairs) {
MethodBinding methodBinding = memberValuePair.binding;
if (methodBinding == null) {
// is this just a marker annotation?
@@ -947,8 +943,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
ajAnnotationType.isAnnotationWithRuntimeRetention());
MemberValuePair[] pairs = normalAnnotation.memberValuePairs;
if (pairs != null) {
- for (int p = 0; p < pairs.length; p++) {
- MemberValuePair pair = pairs[p];
+ for (MemberValuePair pair : pairs) {
Expression valueEx = pair.value;
AnnotationValue pairValue = null;
if (valueEx instanceof Literal) {
@@ -1068,8 +1063,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
// Can happen if an aspect is extending a regular class
return null;
}
- for (int i = 0; i < annotations.length; i++) {
- Annotation annotation = annotations[i];
+ for (Annotation annotation : annotations) {
if (annotation != null && annotation.resolvedType != null
&& CharOperation.equals(aspectSig, annotation.resolvedType.signature())) {
// found @Aspect(...)
@@ -1092,7 +1086,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
// safe
// ?
return determinePerClause(typeDeclaration, clause);
- } else if (annotation instanceof NormalAnnotation) {
+ } else if (annotation instanceof NormalAnnotation) {
// this kind if it was added by the visitor!
// it is an @Aspect(...something...)
NormalAnnotation theAnnotation = (NormalAnnotation) annotation;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
index 4fbdfa849..0a26fafd9 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
@@ -209,18 +209,17 @@ public class EclipseTypeMunger extends ConcreteTypeMunger {
MethodBinding binding = world.makeMethodBinding(munger.getSignature(), munger.getTypeVariableAliases());
findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding);
TypeVariableBinding[] typeVariables = binding.typeVariables;
- for (int i = 0; i < typeVariables.length; i++) {
- TypeVariableBinding tv = typeVariables[i];
+ for (TypeVariableBinding tv : typeVariables) {
String name = new String(tv.sourceName);
TypeVariableBinding[] tv2 = sourceMethod.binding.typeVariables;
- for (int j = 0; j < tv2.length; j++) {
- if (new String(tv2[j].sourceName).equals(name)) {
- typeVariables[i].declaringElement = binding;
+ for (TypeVariableBinding typeVariableBinding : tv2) {
+ if (new String(typeVariableBinding.sourceName).equals(name)) {
+ tv.declaringElement = binding;
}
}
}
- for (int i = 0; i < typeVariables.length; i++) {
- if (typeVariables[i].declaringElement == null) {
+ for (TypeVariableBinding typeVariable : typeVariables) {
+ if (typeVariable.declaringElement == null) {
throw new RuntimeException("Declaring element not set");
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java
index 8b4a917f8..d3e449534 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java
@@ -53,8 +53,7 @@ public class InterTypeMemberFinder implements IMemberFinder {
}
int fieldLength = fieldName.length;
- for (int i = 0, len = interTypeFields.size(); i < len; i++) {
- FieldBinding field = interTypeFields.get(i);
+ for (FieldBinding field : interTypeFields) {
if (field.name.length == fieldLength && CharOperation.prefixEquals(field.name, fieldName)) {
retField = resolveConflicts(sourceTypeBinding, retField, field, site, scope);
}
@@ -256,15 +255,14 @@ public class InterTypeMemberFinder implements IMemberFinder {
// if (interTypeMethods.isEmpty()) return orig;
List<MethodBinding> ret = new ArrayList<MethodBinding>(Arrays.asList(orig));
- for (int i = 0, len = interTypeMethods.size(); i < len; i++) {
- MethodBinding method = interTypeMethods.get(i);
+ for (MethodBinding method : interTypeMethods) {
ret.add(method);
}
ReferenceBinding[] interfaces = sourceTypeBinding.superInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- if (interfaces[i] instanceof SourceTypeBinding) {
- SourceTypeBinding intSTB = (SourceTypeBinding) interfaces[i];
+ for (ReferenceBinding anInterface : interfaces) {
+ if (anInterface instanceof SourceTypeBinding) {
+ SourceTypeBinding intSTB = (SourceTypeBinding) anInterface;
addPublicITDSFrom(intSTB, ret);
}
}
@@ -304,9 +302,7 @@ public class InterTypeMemberFinder implements IMemberFinder {
Set<MethodBinding> ret = new HashSet<MethodBinding>(Arrays.asList(orig));
// System.err.println("declared method: " + ret + " inters = " + interTypeMethods);
- for (int i = 0, len = interTypeMethods.size(); i < len; i++) {
- MethodBinding method = interTypeMethods.get(i);
-
+ for (MethodBinding method : interTypeMethods) {
if (CharOperation.equals(selector, method.selector)) {
ret.add(method);
}
@@ -341,8 +337,7 @@ public class InterTypeMemberFinder implements IMemberFinder {
MethodBinding ret = sourceTypeBinding.getExactMethodBase(selector, argumentTypes, refScope);
// An intertype declaration may override an inherited member (Bug#50776)
- for (int i = 0, len = interTypeMethods.size(); i < len; i++) {
- MethodBinding im = interTypeMethods.get(i);
+ for (MethodBinding im : interTypeMethods) {
if (matches(im, selector, argumentTypes)) {
return im;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
index 10e93ae00..213c41d40 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
@@ -61,11 +61,11 @@ public class InterTypeMethodBinding extends MethodBinding {
// Ok, we need to set the typevariable declaring elements
// 1st set:
// If the typevariable is one declared on the source method, then we know we are the declaring element
- for (int i = 0; i < typeVariables.length; i++) {
- typeVariables[i].declaringElement = this;
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding variable : typeVariables) {
+ variable.declaringElement = this;
}
- for (int i = 0; i < typeVariables.length; i++) {
- if (typeVariables[i].declaringElement == null)
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding typeVariable : typeVariables) {
+ if (typeVariable.declaringElement == null)
throw new RuntimeException("Declaring element not set");
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
index c4c7e1f84..a361cd881 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
@@ -144,8 +144,8 @@ public class PrivilegedHandler implements IPrivilegedHandler {
int len = m.size();
ResolvedMember[] ret = new ResolvedMember[len];
int index = 0;
- for (Iterator i = m.iterator(); i.hasNext();) {
- ret[index++] = (ResolvedMember) i.next();
+ for (Object o : m) {
+ ret[index++] = (ResolvedMember) o;
}
return ret;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
index c80bbb5e9..ec5a2a545 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
@@ -229,8 +229,7 @@ public class AjProblemReporter extends ProblemReporter {
// so we don't have to worry about interfaces, just the superclass.
onTypeX = factory.fromEclipse(type.superclass()); // abstractMethod.declaringClass);
}
- for (Iterator i = onTypeX.getInterTypeMungersIncludingSupers().iterator(); i.hasNext();) {
- ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
+ for (ConcreteTypeMunger m : onTypeX.getInterTypeMungersIncludingSupers()) {
ResolvedMember sig = m.getSignature();
if (!Modifier.isAbstract(sig.getModifiers())) {
if (ResolvedType.matches(
@@ -434,9 +433,8 @@ public class AjProblemReporter extends ProblemReporter {
ResolvedType supertypeToLookAt = onTypeX.getSuperclass();
while (supertypeToLookAt != null) {
List<ConcreteTypeMunger> itMungers = supertypeToLookAt.getInterTypeMungers();
- for (Iterator<ConcreteTypeMunger> i = itMungers.iterator(); i.hasNext();) {
- ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
- if (m.getMunger()!=null && m.getMunger().getKind()== ResolvedTypeMunger.PrivilegedAccess) {
+ for (ConcreteTypeMunger m : itMungers) {
+ if (m.getMunger() != null && m.getMunger().getKind() == ResolvedTypeMunger.PrivilegedAccess) {
continue;
}
ResolvedMember sig = m.getSignature();
@@ -492,13 +490,11 @@ public class AjProblemReporter extends ProblemReporter {
AspectDeclaration ad = (AspectDeclaration) typeDecl.enclosingType;
if (ad.concreteName != null) {
List<Declare> declares = ad.concreteName.declares;
- for (Iterator<Declare> iter = declares.iterator(); iter.hasNext();) {
- Object dec = iter.next();
+ for (Object dec : declares) {
if (dec instanceof DeclareParents) {
DeclareParents decp = (DeclareParents) dec;
TypePattern[] newparents = decp.getParents().getTypePatterns();
- for (int i = 0; i < newparents.length; i++) {
- TypePattern pattern = newparents[i];
+ for (TypePattern pattern : newparents) {
UnresolvedType ut = pattern.getExactType();
if (ut == null)
continue;
@@ -552,8 +548,7 @@ public class AjProblemReporter extends ProblemReporter {
weaverType = factory.fromEclipse(type.superclass());
}
Set checked = new HashSet();
- for (Iterator i = weaverType.getInterTypeMungersIncludingSupers().iterator(); i.hasNext();) {
- ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
+ for (ConcreteTypeMunger m : weaverType.getInterTypeMungersIncludingSupers()) {
ResolvedType theAspect = m.getAspectType();
if (!checked.contains(theAspect)) {
TypeBinding tb = factory.makeTypeBinding(m.getAspectType());
@@ -570,8 +565,8 @@ public class AjProblemReporter extends ProblemReporter {
Collection/* ResolvedMember */privvies = ((ReferenceType) theAspect).getPrivilegedAccesses();
// On an incremental compile the information is in the bcel delegate
if (privvies != null) {
- for (Iterator iterator = privvies.iterator(); iterator.hasNext();) {
- ResolvedMember priv = (ResolvedMember) iterator.next();
+ for (Object privvy : privvies) {
+ ResolvedMember priv = (ResolvedMember) privvy;
if (priv.getName().equals(fname)) {
return;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
index 1b6343fef..219f2fd48 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
@@ -324,12 +324,11 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
return pathname.getPath().endsWith(".class");
}
};
- for (Iterator<File> iter = inPath.iterator(); iter.hasNext();) {
- File inpathElement = iter.next();
+ for (File inpathElement : inPath) {
if (inpathElement.isDirectory()) {
File[] files = FileUtil.listFiles(inpathElement, filter);
- for (int i = 0; i < files.length; i++) {
- binaryFiles.add(new BinarySourceFile(inpathElement, files[i]));
+ for (File file : files) {
+ binaryFiles.add(new BinarySourceFile(inpathElement, file));
}
}
}
@@ -537,8 +536,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
@SuppressWarnings({ "rawtypes", "unchecked" })
void join(Collection local, Collection global) {
- for (Iterator iter = global.iterator(); iter.hasNext();) {
- Object next = iter.next();
+ for (Object next : global) {
if (!local.contains(next)) {
local.add(next);
}
@@ -955,8 +953,8 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
allPaths = FileSystem.ClasspathNormalizer.normalize(allPaths);
this.checkedClasspaths = new FileSystem.Classpath[allPaths.size()];
allPaths.toArray(this.checkedClasspaths);
- for (int i=0;i<checkedClasspaths.length;i++) {
- if (checkedClasspaths[i] == null) {
+ for (Classpath checkedClasspath : checkedClasspaths) {
+ if (checkedClasspath == null) {
throw new IllegalStateException();
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index aacda594c..98c115190 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -453,26 +453,24 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
private void copyResourcesToDestination() throws IOException {
// resources that we need to copy are contained in the injars and inpath only
- for (Iterator i = buildConfig.getInJars().iterator(); i.hasNext();) {
- File inJar = (File) i.next();
- copyResourcesFromJarFile(inJar);
- }
-
- for (Iterator i = buildConfig.getInpath().iterator(); i.hasNext();) {
- File inPathElement = (File) i.next();
- if (inPathElement.isDirectory()) {
- copyResourcesFromDirectory(inPathElement);
- } else {
- copyResourcesFromJarFile(inPathElement);
- }
- }
+ for (File inJar : buildConfig.getInJars()) {
+ copyResourcesFromJarFile(inJar);
+ }
+
+ for (File inPathElement : buildConfig.getInpath()) {
+ if (inPathElement.isDirectory()) {
+ copyResourcesFromDirectory(inPathElement);
+ }
+ else {
+ copyResourcesFromJarFile(inPathElement);
+ }
+ }
if (buildConfig.getSourcePathResources() != null) {
- for (Iterator i = buildConfig.getSourcePathResources().keySet().iterator(); i.hasNext();) {
- String resource = (String) i.next();
- File from = buildConfig.getSourcePathResources().get(resource);
- copyResourcesFromFile(from, resource, from);
- }
+ for (String resource : buildConfig.getSourcePathResources().keySet()) {
+ File from = buildConfig.getSourcePathResources().get(resource);
+ copyResourcesFromFile(from, resource, from);
+ }
}
writeManifest();
@@ -520,12 +518,12 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
});
// For each file, add it either as a real .class file or as a resource
- for (int i = 0; i < files.length; i++) {
- // ASSERT: files[i].getAbsolutePath().startsWith(inFile.getAbsolutePath()
- // or we are in trouble...
- String filename = files[i].getAbsolutePath().substring(dir.getAbsolutePath().length() + 1);
- copyResourcesFromFile(files[i], filename, dir);
- }
+ for (File file : files) {
+ // ASSERT: files[i].getAbsolutePath().startsWith(inFile.getAbsolutePath()
+ // or we are in trouble...
+ String filename = file.getAbsolutePath().substring(dir.getAbsolutePath().length() + 1);
+ copyResourcesFromFile(file, filename, dir);
+ }
}
private void copyResourcesFromFile(File f, String filename, File src) throws IOException {
@@ -663,28 +661,28 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
Map<File, List<String>> outputDirsAndAspects = findOutputDirsForAspects();
Set<Map.Entry<File, List<String>>> outputDirs = outputDirsAndAspects.entrySet();
- for (Iterator<Map.Entry<File, List<String>>> iterator = outputDirs.iterator(); iterator.hasNext();) {
- Map.Entry<File, List<String>> entry = iterator.next();
- File outputDir = entry.getKey();
- List<String> aspects = entry.getValue();
- ByteArrayOutputStream baos = getOutxmlContents(aspects);
- if (zos != null) {
- ZipEntry newEntry = new ZipEntry(filename);
-
- zos.putNextEntry(newEntry);
- zos.write(baos.toByteArray());
- zos.closeEntry();
- } else {
- File outputFile = new File(outputDir, filename);
- OutputStream fos = FileUtil.makeOutputStream(outputFile);
- fos.write(baos.toByteArray());
- fos.close();
- if (buildConfig.getCompilationResultDestinationManager() != null) {
- buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputFile.getPath(),
- CompilationResultDestinationManager.FILETYPE_RESOURCE);
- }
- }
- }
+ for (Map.Entry<File, List<String>> entry : outputDirs) {
+ File outputDir = entry.getKey();
+ List<String> aspects = entry.getValue();
+ ByteArrayOutputStream baos = getOutxmlContents(aspects);
+ if (zos != null) {
+ ZipEntry newEntry = new ZipEntry(filename);
+
+ zos.putNextEntry(newEntry);
+ zos.write(baos.toByteArray());
+ zos.closeEntry();
+ }
+ else {
+ File outputFile = new File(outputDir, filename);
+ OutputStream fos = FileUtil.makeOutputStream(outputFile);
+ fos.write(baos.toByteArray());
+ fos.close();
+ if (buildConfig.getCompilationResultDestinationManager() != null) {
+ buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputFile.getPath(),
+ CompilationResultDestinationManager.FILETYPE_RESOURCE);
+ }
+ }
+ }
}
private ByteArrayOutputStream getOutxmlContents(List aspectNames) {
@@ -693,10 +691,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
ps.println("<aspectj>");
ps.println("<aspects>");
if (aspectNames != null) {
- for (Iterator i = aspectNames.iterator(); i.hasNext();) {
- String name = (String) i.next();
- ps.println("<aspect name=\"" + name + "\"/>");
- }
+ for (Object aspectName : aspectNames) {
+ String name = (String) aspectName;
+ ps.println("<aspect name=\"" + name + "\"/>");
+ }
}
ps.println("</aspects>");
ps.println("</aspectj>");
@@ -729,23 +727,22 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
outputDirsToAspects.put(outputDir, aspectNames);
} else {
List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations();
- for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
- File outputDir = (File) iterator.next();
- outputDirsToAspects.put(outputDir, new ArrayList<String>());
- }
+ for (Object dir : outputDirs) {
+ File outputDir = (File) dir;
+ outputDirsToAspects.put(outputDir, new ArrayList<String>());
+ }
if (aspectNamesToFileNames != null) {
Set<Map.Entry<String, char[]>> entrySet = aspectNamesToFileNames.entrySet();
- for (Iterator<Map.Entry<String, char[]>> iterator = entrySet.iterator(); iterator.hasNext();) {
- Map.Entry<String, char[]> entry = iterator.next();
- String aspectName = entry.getKey();
- char[] fileName = entry.getValue();
- File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
- new File(new String(fileName)));
- if (!outputDirsToAspects.containsKey(outputDir)) {
- outputDirsToAspects.put(outputDir, new ArrayList<String>());
- }
- ((List) outputDirsToAspects.get(outputDir)).add(aspectName);
- }
+ for (Map.Entry<String, char[]> entry : entrySet) {
+ String aspectName = entry.getKey();
+ char[] fileName = entry.getValue();
+ File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
+ new File(new String(fileName)));
+ if (!outputDirsToAspects.containsKey(outputDir)) {
+ outputDirsToAspects.put(outputDir, new ArrayList<String>());
+ }
+ ((List) outputDirsToAspects.get(outputDir)).add(aspectName);
+ }
}
}
return outputDirsToAspects;
@@ -904,12 +901,12 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
// (they are like 'source' files then), and enables a cleaner incremental treatment of
// class file changes in indirs.
File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter);
- for (int j = 0; j < binSrcs.length; j++) {
- UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrcs[j], inPathElement, outputDir);
- List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>();
- ucfl.add(ucf);
- state.recordBinarySource(binSrcs[j].getPath(), ucfl);
- }
+ for (File binSrc : binSrcs) {
+ UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrc, inPathElement, outputDir);
+ List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>();
+ ucfl.add(ucf);
+ state.recordBinarySource(binSrc.getPath(), ucfl);
+ }
}
}
@@ -1034,10 +1031,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
// Translate from strings to File objects
String[] filenames = new String[files.size()];
int idx = 0;
- for (Iterator<File> fIterator = files.iterator(); fIterator.hasNext();) {
- File f = fIterator.next();
- filenames[idx++] = f.getPath();
- }
+ for (File f : files) {
+ filenames[idx++] = f.getPath();
+ }
environment = state.getNameEnvironment();
@@ -1154,48 +1150,48 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
if (!hasErrors || proceedOnError()) {
Collection<ClassFile> classFiles = unitResult.compiledTypes.values();
boolean shouldAddAspectName = (buildConfig.getOutxmlName() != null);
- for (Iterator<ClassFile> iter = classFiles.iterator(); iter.hasNext();) {
- ClassFile classFile = iter.next();
- String filename = new String(classFile.fileName());
- String classname = filename.replace('/', '.');
- filename = filename.replace('/', File.separatorChar) + ".class";
-
- try {
- if (buildConfig.getOutputJar() == null) {
- String outfile = writeDirectoryEntry(unitResult, classFile, filename);
- getWorld().classWriteEvent(classFile.getCompoundName());
- if (environmentSupportsIncrementalCompilation) {
- if (!classname.endsWith("$ajcMightHaveAspect")) {
- ResolvedType type = getBcelWorld().resolve(classname);
- if (type.isAspect()) {
- state.recordAspectClassFile(outfile);
- }
- }
- }
- } else {
- writeZipEntry(classFile, filename);
- }
- if (shouldAddAspectName && !classname.endsWith("$ajcMightHaveAspect")) {
- addAspectName(classname, unitResult.getFileName());
- }
- } catch (IOException ex) {
- IMessage message = EclipseAdapterUtils.makeErrorMessage(new String(unitResult.fileName),
- CANT_WRITE_RESULT, ex);
- handler.handleMessage(message);
- }
-
- }
+ for (ClassFile classFile : classFiles) {
+ String filename = new String(classFile.fileName());
+ String classname = filename.replace('/', '.');
+ filename = filename.replace('/', File.separatorChar) + ".class";
+
+ try {
+ if (buildConfig.getOutputJar() == null) {
+ String outfile = writeDirectoryEntry(unitResult, classFile, filename);
+ getWorld().classWriteEvent(classFile.getCompoundName());
+ if (environmentSupportsIncrementalCompilation) {
+ if (!classname.endsWith("$ajcMightHaveAspect")) {
+ ResolvedType type = getBcelWorld().resolve(classname);
+ if (type.isAspect()) {
+ state.recordAspectClassFile(outfile);
+ }
+ }
+ }
+ }
+ else {
+ writeZipEntry(classFile, filename);
+ }
+ if (shouldAddAspectName && !classname.endsWith("$ajcMightHaveAspect")) {
+ addAspectName(classname, unitResult.getFileName());
+ }
+ } catch (IOException ex) {
+ IMessage message = EclipseAdapterUtils.makeErrorMessage(new String(unitResult.fileName),
+ CANT_WRITE_RESULT, ex);
+ handler.handleMessage(message);
+ }
+
+ }
state.noteNewResult(unitResult);
unitResult.compiledTypes.clear(); // free up references to AjClassFile instances
}
if (unitResult.hasProblems() || unitResult.hasTasks()) {
IProblem[] problems = unitResult.getAllProblems();
- for (int i = 0; i < problems.length; i++) {
- IMessage message = EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i], getBcelWorld(),
- progressListener);
- handler.handleMessage(message);
- }
+ for (IProblem problem : problems) {
+ IMessage message = EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problem, getBcelWorld(),
+ progressListener);
+ handler.handleMessage(message);
+ }
}
}
@@ -1314,14 +1310,15 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
}
StringBuffer buf = new StringBuffer();
boolean first = true;
- for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext();) {
- if (first) {
- first = false;
- } else {
- buf.append(File.pathSeparator);
- }
- buf.append(it.next().toString());
- }
+ for (String s : buildConfig.getFullClasspath()) {
+ if (first) {
+ first = false;
+ }
+ else {
+ buf.append(File.pathSeparator);
+ }
+ buf.append(s.toString());
+ }
return buf.toString();
}
@@ -1349,47 +1346,50 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
}
String ret = null;
- for (Iterator<String> it = buildConfig.getFullClasspath().iterator(); it.hasNext();) {
- File p = new File(it.next());
- // pr112830, allow variations on aspectjrt.jar of the form aspectjrtXXXXXX.jar
- if (p.isFile() && p.getName().startsWith("aspectjrt") && p.getName().endsWith(".jar")) {
-
- try {
- String version = null;
- Manifest manifest = new JarFile(p).getManifest();
- if (manifest == null) {
- ret = "no manifest found in " + p.getAbsolutePath() + ", expected " + Version.getText();
- continue;
- }
- Attributes attr = manifest.getAttributes("org/aspectj/lang/");
- if (null != attr) {
- version = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
- if (null != version) {
- version = version.trim();
- }
- }
- // assume that users of development aspectjrt.jar know what they're doing
- if (version != null && (Version.DEVELOPMENT.equals(version) || version.endsWith("BUILD-SNAPSHOT"))) {
- // MessageUtil.info(holder,
- // "running with development version of aspectjrt.jar in " +
- // p.getAbsolutePath());
- return null;
- } else if (!Version.getText().equals(version)) {
- ret = "bad version number found in " + p.getAbsolutePath() + " expected " + Version.getText() + " found "
- + version;
- continue;
- }
- } catch (IOException ioe) {
- ret = "bad jar file found in " + p.getAbsolutePath() + " error: " + ioe;
- }
- return null; // this is the "OK" return value!
- } else if (p.isFile() && p.getName().indexOf("org.aspectj.runtime") != -1) {
- // likely to be a variant from the springsource bundle repo b272591
- return null;
- } else {
- // might want to catch other classpath errors
- }
- }
+ for (String s : buildConfig.getFullClasspath()) {
+ File p = new File(s);
+ // pr112830, allow variations on aspectjrt.jar of the form aspectjrtXXXXXX.jar
+ if (p.isFile() && p.getName().startsWith("aspectjrt") && p.getName().endsWith(".jar")) {
+
+ try {
+ String version = null;
+ Manifest manifest = new JarFile(p).getManifest();
+ if (manifest == null) {
+ ret = "no manifest found in " + p.getAbsolutePath() + ", expected " + Version.getText();
+ continue;
+ }
+ Attributes attr = manifest.getAttributes("org/aspectj/lang/");
+ if (null != attr) {
+ version = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
+ if (null != version) {
+ version = version.trim();
+ }
+ }
+ // assume that users of development aspectjrt.jar know what they're doing
+ if (version != null && (Version.DEVELOPMENT.equals(version) || version.endsWith("BUILD-SNAPSHOT"))) {
+ // MessageUtil.info(holder,
+ // "running with development version of aspectjrt.jar in " +
+ // p.getAbsolutePath());
+ return null;
+ }
+ else if (!Version.getText().equals(version)) {
+ ret = "bad version number found in " + p.getAbsolutePath() + " expected " + Version.getText() + " found "
+ + version;
+ continue;
+ }
+ } catch (IOException ioe) {
+ ret = "bad jar file found in " + p.getAbsolutePath() + " error: " + ioe;
+ }
+ return null; // this is the "OK" return value!
+ }
+ else if (p.isFile() && p.getName().indexOf("org.aspectj.runtime") != -1) {
+ // likely to be a variant from the springsource bundle repo b272591
+ return null;
+ }
+ else {
+ // might want to catch other classpath errors
+ }
+ }
if (ret != null) {
return ret; // last error found in potentially matching jars...
@@ -1547,10 +1547,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
AjBuildConfig config = (AjBuildConfig) data;
List classpath = config.getClasspath();
sb.append("with classpath: ");
- for (Iterator iter = classpath.iterator(); iter.hasNext();) {
- sb.append(iter.next().toString());
- sb.append(File.pathSeparator);
- }
+ for (Object o : classpath) {
+ sb.append(o.toString());
+ sb.append(File.pathSeparator);
+ }
return sb.toString();
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java
index 30bc1165b..833ce2382 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java
@@ -384,8 +384,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
if (modifiedFiles == null) {
// do not know, so need to go looking
// not our job to account for new and deleted files
- for (Iterator<File> i = buildConfig.getFiles().iterator(); i.hasNext();) {
- File file = i.next();
+ for (File file : buildConfig.getFiles()) {
if (!file.exists()) {
continue;
}
@@ -411,8 +410,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
Collection<BinarySourceFile> getModifiedBinaryFiles(long lastBuildTime) {
List<BinarySourceFile> ret = new ArrayList<BinarySourceFile>();
// not our job to account for new and deleted files
- for (Iterator<BinarySourceFile> i = buildConfig.getBinaryFiles().iterator(); i.hasNext();) {
- AjBuildConfig.BinarySourceFile bsfile = i.next();
+ for (BinarySourceFile bsfile : buildConfig.getBinaryFiles()) {
File file = bsfile.binSrc;
if (!file.exists()) {
continue;
@@ -490,8 +488,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
List<File> classFiles = FileUtil.listClassFiles(dir);
- for (Iterator<File> iterator = classFiles.iterator(); iterator.hasNext();) {
- File classFile = iterator.next();
+ for (File classFile : classFiles) {
if (CHECK_STATE_FIRST && state != null) {
// Next section reworked based on bug 270033:
// if it is an aspect we may or may not be in trouble depending on whether (a) we depend on it (b) it is on the
@@ -763,8 +760,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
simpleNames = ReferenceCollection.internSimpleNames(simpleNames, true);
}
int newlyAffectedFiles = 0;
- for (Iterator<Map.Entry<File, ReferenceCollection>> i = references.entrySet().iterator(); i.hasNext();) {
- Map.Entry<File, ReferenceCollection> entry = i.next();
+ for (Map.Entry<File, ReferenceCollection> entry : references.entrySet()) {
ReferenceCollection refs = entry.getValue();
if (refs != null && refs.includes(qualifiedNames, simpleNames)) {
if (listenerDefined()) {
@@ -838,8 +834,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
*/
private boolean hasAnyStructuralChangesSince(long lastSuccessfulBuildTime) {
Set<Map.Entry<String, Long>> entries = structuralChangesSinceLastFullBuild.entrySet();
- for (Iterator<Map.Entry<String, Long>> iterator = entries.iterator(); iterator.hasNext();) {
- Map.Entry<String, Long> entry = iterator.next();
+ for (Map.Entry<String, Long> entry : entries) {
Long l = entry.getValue();
if (l != null) {
long lvalue = l.longValue();
@@ -905,8 +900,8 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
// are also capturing project dependencies - when a project we depend on is rebuilt, we can just check
// it as a standalone element on our classpath rather than going through them all
List<String> modifiedCpElements = newConfig.getClasspathElementsWithModifiedContents();
- for (Iterator<String> iterator = modifiedCpElements.iterator(); iterator.hasNext();) {
- File cpElement = new File(iterator.next());
+ for (String modifiedCpElement : modifiedCpElements) {
+ File cpElement = new File(modifiedCpElement);
if (cpElement.exists() && !cpElement.isDirectory()) {
if (cpElement.lastModified() > lastSuccessfulBuildTime) {
return true;
@@ -941,8 +936,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
}
if (config.getCompilationResultDestinationManager() != null) {
List<File> dirs = config.getCompilationResultDestinationManager().getAllOutputLocations();
- for (Iterator<File> iterator = dirs.iterator(); iterator.hasNext();) {
- File f = iterator.next();
+ for (File f : dirs) {
try {
File cf = f.getCanonicalFile();
if (!outputLocs.contains(cf)) {
@@ -1093,8 +1087,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
// }
if (addedFiles != null) {
- for (Iterator<File> fIter = addedFiles.iterator(); fIter.hasNext();) {
- File o = fIter.next();
+ for (File o : addedFiles) {
// TODO isn't it a set?? why do this
if (!thisTime.contains(o)) {
thisTime.add(o);
@@ -1132,8 +1125,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
List<BinarySourceFile> addedOrModified = new ArrayList<BinarySourceFile>();
addedOrModified.addAll(addedBinaryFiles);
addedOrModified.addAll(getModifiedBinaryFiles());
- for (Iterator<BinarySourceFile> iter = addedOrModified.iterator(); iter.hasNext();) {
- AjBuildConfig.BinarySourceFile bsf = iter.next();
+ for (BinarySourceFile bsf : addedOrModified) {
UnwovenClassFile ucf = createUnwovenClassFile(bsf);
if (ucf == null) {
continue;
@@ -1159,19 +1151,16 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
*/
private void removeAllResultsOfLastBuild() {
// remove all binarySourceFiles, and all classesFromName...
- for (Iterator<List<ClassFile>> iter = this.inputClassFilesBySource.values().iterator(); iter.hasNext();) {
- List<ClassFile> cfs = iter.next();
+ for (List<ClassFile> cfs : this.inputClassFilesBySource.values()) {
for (ClassFile cf : cfs) {
cf.deleteFromFileSystem(buildConfig);
}
}
- for (Iterator<File> iterator = classesFromName.values().iterator(); iterator.hasNext();) {
- File f = iterator.next();
+ for (File f : classesFromName.values()) {
new ClassFile("", f).deleteFromFileSystem(buildConfig);
}
Set<Map.Entry<String, File>> resourceEntries = resources.entrySet();
- for (Iterator<Map.Entry<String, File>> iter = resourceEntries.iterator(); iter.hasNext();) {
- Map.Entry<String, File> resourcePair = iter.next();
+ for (Map.Entry<String, File> resourcePair : resourceEntries) {
File sourcePath = resourcePair.getValue();
File outputLoc = getOutputLocationFor(buildConfig, sourcePath);
if (outputLoc != null) {
@@ -1210,8 +1199,8 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
// range of bsf is ucfs, domain is files (.class and jars) in inpath/jars
for (BinarySourceFile deletedFile : deletedBinaryFiles) {
List<ClassFile> cfs = this.inputClassFilesBySource.get(deletedFile.binSrc.getPath());
- for (Iterator<ClassFile> iterator = cfs.iterator(); iterator.hasNext();) {
- deleteClassFile(iterator.next());
+ for (ClassFile cf : cfs) {
+ deleteClassFile(cf);
}
this.inputClassFilesBySource.remove(deletedFile.binSrc.getPath());
}
@@ -1328,14 +1317,14 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
references.put(sourceFile, new ReferenceCollection(cr.qualifiedReferences, cr.simpleNameReferences,cr.rootReferences));
UnwovenClassFile[] unwovenClassFiles = result.unwovenClassFiles();
- for (int i = 0; i < unwovenClassFiles.length; i++) {
- File lastTimeRound = classesFromName.get(unwovenClassFiles[i].getClassName());
- recordClassFile(unwovenClassFiles[i], lastTimeRound);
- String name = unwovenClassFiles[i].getClassName();
+ for (UnwovenClassFile unwovenClassFile : unwovenClassFiles) {
+ File lastTimeRound = classesFromName.get(unwovenClassFile.getClassName());
+ recordClassFile(unwovenClassFile, lastTimeRound);
+ String name = unwovenClassFile.getClassName();
if (lastTimeRound == null) {
deltaAddedClasses.add(name);
}
- classesFromName.put(name, new File(unwovenClassFiles[i].getFilename()));
+ classesFromName.put(name, new File(unwovenClassFile.getFilename()));
}
// need to do this before types are deleted from the World...
@@ -1383,10 +1372,10 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
List<ClassFile> classFiles = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
if (classFiles != null) {
- for (int i = 0; i < unwovenClassFiles.length; i++) {
+ for (UnwovenClassFile unwovenClassFile : unwovenClassFiles) {
// deleting also deletes types from the weaver... don't do this if they are
// still present this time around...
- removeFromClassFilesIfPresent(unwovenClassFiles[i].getClassName(), classFiles);
+ removeFromClassFilesIfPresent(unwovenClassFile.getClassName(), classFiles);
}
for (ClassFile cf : classFiles) {
recordTypeChanged(cf.fullyQualifiedTypeName);
@@ -1420,8 +1409,8 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
private void recordFQNsResultingFromCompilationUnit(File sourceFile, InterimCompilationResult icr) {
List<ClassFile> classFiles = new ArrayList<ClassFile>();
UnwovenClassFile[] types = icr.unwovenClassFiles();
- for (int i = 0; i < types.length; i++) {
- classFiles.add(new ClassFile(types[i].getClassName(), new File(types[i].getFilename())));
+ for (UnwovenClassFile type : types) {
+ classFiles.add(new ClassFile(type.getClassName(), new File(type.getFilename())));
}
this.fullyQualifiedTypeNamesResultingFromCompilationUnit.put(sourceFile, classFiles);
}
@@ -1438,8 +1427,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
if (cr != null) {
Map compiledTypes = cr.compiledTypes;
if (compiledTypes != null) {
- for (Iterator<char[]> iterator = compiledTypes.keySet().iterator(); iterator.hasNext();) {
- char[] className = iterator.next();
+ for (char[] className : (Iterable<char[]>) compiledTypes.keySet()) {
String typeName = new String(className).replace('/', '.');
if (typeName.indexOf(BcelWeaver.SYNTHETIC_CLASS_POSTFIX) == -1) {
ResolvedType rt = world.resolve(typeName);
@@ -1623,9 +1611,10 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
if (existingIfs.length != newIfsAsChars.length) {
return true;
}
- new_interface_loop: for (int i = 0; i < newIfsAsChars.length; i++) {
- for (int j = 0; j < existingIfs.length; j++) {
- if (CharOperation.equals(existingIfs[j], newIfsAsChars[i])) {
+ new_interface_loop:
+ for (char[] newIfsAsChar : newIfsAsChars) {
+ for (char[] existingIf : existingIfs) {
+ if (CharOperation.equals(existingIf, newIfsAsChar)) {
continue new_interface_loop;
}
}
@@ -1654,12 +1643,12 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
if (newFields.length != existingFs.length) {
return true;
}
- new_field_loop: for (int i = 0; i < newFields.length; i++) {
- IBinaryField field = newFields[i];
+ new_field_loop:
+ for (IBinaryField field : newFields) {
char[] fieldName = field.getName();
- for (int j = 0; j < existingFs.length; j++) {
- if (CharOperation.equals(existingFs[j].getName(), fieldName)) {
- IBinaryField existing = existingFs[j];
+ for (IBinaryField existingF : existingFs) {
+ if (CharOperation.equals(existingF.getName(), fieldName)) {
+ IBinaryField existing = existingF;
if (!modifiersEqual(field.getModifiers(), existing.getModifiers())) {
return true;
}
@@ -1732,13 +1721,13 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
if (newMethods.length != existingMs.length) {
return true;
}
- new_method_loop: for (int i = 0; i < newMethods.length; i++) {
- IBinaryMethod method = newMethods[i];
+ new_method_loop:
+ for (IBinaryMethod method : newMethods) {
char[] methodName = method.getSelector();
- for (int j = 0; j < existingMs.length; j++) {
- if (CharOperation.equals(existingMs[j].getSelector(), methodName)) {
+ for (IBinaryMethod existingM : existingMs) {
+ if (CharOperation.equals(existingM.getSelector(), methodName)) {
// candidate match
- if (!CharOperation.equals(method.getMethodDescriptor(), existingMs[j].getMethodDescriptor())) {
+ if (!CharOperation.equals(method.getMethodDescriptor(), existingM.getMethodDescriptor())) {
// ok, the descriptors don't match, but is this a funky ctor on a non-static inner
// type?
// boolean mightBeOK =
@@ -1762,7 +1751,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
continue; // might be overloading
} else {
// matching sigs
- IBinaryMethod existing = existingMs[j];
+ IBinaryMethod existing = existingM;
if (!modifiersEqual(method.getModifiers(), existing.getModifiers())) {
return true;
}
@@ -1880,13 +1869,14 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
if (existingIfs.length != newIfsAsChars.length) {
return true;
}
- new_interface_loop: for (int i = 0; i < newIfsAsChars.length; i++) {
- for (int j = 0; j < existingIfs.length; j++) {
- if (CharOperation.equals(existingIfs[j], newIfsAsChars[i])) {
+ new_interface_loop:
+ for (char[] newIfsAsChar : newIfsAsChars) {
+ for (char[] existingIf : existingIfs) {
+ if (CharOperation.equals(existingIf, newIfsAsChar)) {
continue new_interface_loop;
}
}
- logAnalysis(filename,"set of interfaces changed. old="+stringify(existingIfs)+" new="+stringify(newIfsAsChars));
+ logAnalysis(filename, "set of interfaces changed. old=" + stringify(existingIfs) + " new=" + stringify(newIfsAsChars));
return true;
}
@@ -1913,32 +1903,32 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
logAnalysis(filename,"number of fields changed. old="+stringify(existingFs)+" new="+stringify(newFields));
return true;
}
- new_field_loop: for (int i = 0; i < newFields.length; i++) {
- IBinaryField field = newFields[i];
+ new_field_loop:
+ for (IBinaryField field : newFields) {
char[] fieldName = field.getName();
- for (int j = 0; j < existingFs.length; j++) {
- if (CharOperation.equals(existingFs[j].getName(), fieldName)) {
- IBinaryField existing = existingFs[j];
+ for (IBinaryField existingF : existingFs) {
+ if (CharOperation.equals(existingF.getName(), fieldName)) {
+ IBinaryField existing = existingF;
if (!modifiersEqual(field.getModifiers(), existing.getModifiers())) {
- logAnalysis(filename,"field modifiers changed '"+existing+"' old=0x"+Integer.toHexString(existing.getModifiers())+" new=0x"+Integer.toHexString(field.getModifiers()));
+ logAnalysis(filename, "field modifiers changed '" + existing + "' old=0x" + Integer.toHexString(existing.getModifiers()) + " new=0x" + Integer.toHexString(field.getModifiers()));
return true;
}
if (!CharOperation.equals(existing.getTypeName(), field.getTypeName())) {
- logAnalysis(filename,"field type changed '"+existing+"' old="+new String(existing.getTypeName())+" new="+new String(field.getTypeName()));
+ logAnalysis(filename, "field type changed '" + existing + "' old=" + new String(existing.getTypeName()) + " new=" + new String(field.getTypeName()));
return true;
}
char[] existingGSig = existing.getGenericSignature();
char[] fieldGSig = field.getGenericSignature();
if ((existingGSig == null && fieldGSig != null) || (existingGSig != null && fieldGSig == null)) {
- logAnalysis(filename,"field generic sig changed '"+existing+"' old="+
- (existingGSig==null?"null":new String(existingGSig))+" new="+(fieldGSig==null?"null":new String(fieldGSig)));
+ logAnalysis(filename, "field generic sig changed '" + existing + "' old=" +
+ (existingGSig == null ? "null" : new String(existingGSig)) + " new=" + (fieldGSig == null ? "null" : new String(fieldGSig)));
return true;
}
if (existingGSig != null) {
if (!CharOperation.equals(existingGSig, fieldGSig)) {
- logAnalysis(filename,"field generic sig changed '"+existing+"' old="+
- (existingGSig==null?"null":new String(existingGSig))+" new="+(fieldGSig==null?"null":new String(fieldGSig)));
+ logAnalysis(filename, "field generic sig changed '" + existing + "' old=" +
+ (existingGSig == null ? "null" : new String(existingGSig)) + " new=" + (fieldGSig == null ? "null" : new String(fieldGSig)));
return true;
}
}
@@ -1946,7 +1936,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
continue new_field_loop;
}
}
- logAnalysis(filename,"field changed. New field detected '"+field+"'");
+ logAnalysis(filename, "field changed. New field detected '" + field + "'");
return true;
}
@@ -1999,13 +1989,13 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
logAnalysis(filename,"number of methods changed. old="+stringify(existingMs)+" new="+stringify(newMethods));
return true;
}
- new_method_loop: for (int i = 0; i < newMethods.length; i++) {
- IBinaryMethod method = newMethods[i];
+ new_method_loop:
+ for (IBinaryMethod method : newMethods) {
char[] methodName = method.getSelector();
- for (int j = 0; j < existingMs.length; j++) {
- if (CharOperation.equals(existingMs[j].getSelector(), methodName)) {
+ for (IBinaryMethod existingM : existingMs) {
+ if (CharOperation.equals(existingM.getSelector(), methodName)) {
// candidate match
- if (!CharOperation.equals(method.getMethodDescriptor(), existingMs[j].getMethodDescriptor())) {
+ if (!CharOperation.equals(method.getMethodDescriptor(), existingM.getMethodDescriptor())) {
// ok, the descriptors don't match, but is this a funky ctor on a non-static inner
// type?
// boolean mightBeOK =
@@ -2029,28 +2019,28 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
continue; // might be overloading
} else {
// matching sigs
- IBinaryMethod existing = existingMs[j];
+ IBinaryMethod existing = existingM;
if (!modifiersEqual(method.getModifiers(), existing.getModifiers())) {
- logAnalysis(filename,"method modifiers changed '"+existing+"' old=0x"+Integer.toHexString(existing.getModifiers())+" new=0x"+Integer.toHexString(method.getModifiers()));
+ logAnalysis(filename, "method modifiers changed '" + existing + "' old=0x" + Integer.toHexString(existing.getModifiers()) + " new=0x" + Integer.toHexString(method.getModifiers()));
return true;
}
if (exceptionClausesDiffer(existing, method)) {
- logAnalysis(filename,"method exception clauses changed '"+existing+"' old="+existing+" new="+method);
+ logAnalysis(filename, "method exception clauses changed '" + existing + "' old=" + existing + " new=" + method);
return true;
}
char[] existingGSig = existing.getGenericSignature();
char[] methodGSig = method.getGenericSignature();
if ((existingGSig == null && methodGSig != null) || (existingGSig != null && methodGSig == null)) {
- logAnalysis(filename,"method generic sig changed '"+existing+"' old="+
- (existingGSig==null?"null":new String(existingGSig))+" new="+(methodGSig==null?"null":new String(methodGSig)));
+ logAnalysis(filename, "method generic sig changed '" + existing + "' old=" +
+ (existingGSig == null ? "null" : new String(existingGSig)) + " new=" + (methodGSig == null ? "null" : new String(methodGSig)));
return true;
}
if (existingGSig != null) {
if (!CharOperation.equals(existingGSig, methodGSig)) {
- logAnalysis(filename,"method generic sig changed '"+existing+"' old="+
- (existingGSig==null?"null":new String(existingGSig))+" new="+(methodGSig==null?"null":new String(methodGSig)));
+ logAnalysis(filename, "method generic sig changed '" + existing + "' old=" +
+ (existingGSig == null ? "null" : new String(existingGSig)) + " new=" + (methodGSig == null ? "null" : new String(methodGSig)));
return true;
}
}
@@ -2061,7 +2051,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
// TODO missing a return true here? Meaning we have a field in the new that we can't find in the old!
}
- logAnalysis(filename,"method changed. New method detected '"+stringify(method)+"' (might be a rename)");
+ logAnalysis(filename, "method changed. New method detected '" + stringify(method) + "' (might be a rename)");
return true; // (no match found)
}
@@ -2236,8 +2226,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
// System.err.println("simple: " + simpleStrings);
// System.err.println("qualif: " + qualifiedStrings);
- for (Iterator<Map.Entry<File, ReferenceCollection>> i = references.entrySet().iterator(); i.hasNext();) {
- Map.Entry<File, ReferenceCollection> entry = i.next();
+ for (Map.Entry<File, ReferenceCollection> entry : references.entrySet()) {
ReferenceCollection refs = entry.getValue();
if (refs != null && refs.includes(qualifiedNames, simpleNames)) {
File file = entry.getKey();
@@ -2473,10 +2462,10 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
}
});
if (weaverGenerated != null) {
- for (int i = 0; i < weaverGenerated.length; i++) {
- weaverGenerated[i].delete();
+ for (File file : weaverGenerated) {
+ file.delete();
if (buildConfig != null && buildConfig.getCompilationResultDestinationManager() != null) {
- buildConfig.getCompilationResultDestinationManager().reportFileRemove(weaverGenerated[i].getPath(),
+ buildConfig.getCompilationResultDestinationManager().reportFileRemove(file.getPath(),
CompilationResultDestinationManager.FILETYPE_CLASS);
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
index 450ffc40b..77862dddf 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
@@ -321,8 +321,7 @@ public class AsmElementFormatter {
TypeReference[] typeRefs = pstr.typeArguments;
if (typeRefs != null && typeRefs.length > 0) {
handleSig.append("\\<");
- for (int i = 0; i < typeRefs.length; i++) {
- TypeReference typeR = typeRefs[i];
+ for (TypeReference typeR : typeRefs) {
TypeBinding typeB = typeR.resolvedType;
if (typeB == null) {
typeB = typeR.resolveType(scope);
@@ -368,8 +367,7 @@ public class AsmElementFormatter {
TypeReference[] typeRefs = pstr.typeArguments[i];
if (typeRefs != null && typeRefs.length > 0) {
handleSig.append("\\<");
- for (int j = 0; j < typeRefs.length; j++) {
- TypeReference typeR = typeRefs[j];
+ for (TypeReference typeR : typeRefs) {
TypeBinding typeB = typeR.resolvedType;
if (typeB == null) {
typeB = typeR.resolveType(scope);
@@ -428,11 +426,11 @@ public class AsmElementFormatter {
List<char[]> paramSigs = new ArrayList<char[]>();
List<String> paramSourceRefs = new ArrayList<String>();
boolean problemWithSourceRefs = false;
- for (int i = 0; i < argArray.length; i++) {
- String argName = new String(argArray[i].name);
+ for (Argument argument : argArray) {
+ String argName = new String(argument.name);
// String argType = "<UnknownType>"; // pr135052
- if (acceptArgument(argName, argArray[i].type.toString())) {
- TypeReference typeR = argArray[i].type;
+ if (acceptArgument(argName, argument.type.toString())) {
+ TypeReference typeR = argument.type;
if (typeR != null && md.scope != null) {
TypeBinding typeB = typeR.resolvedType;
if (typeB == null) {
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index 7da62b87c..7ee6cf9e4 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -208,8 +208,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
// Check if already there
IProgramElement sourceFolderNode = null;
List<IProgramElement> kids = root.getChildren();
- for (Iterator<IProgramElement> iterator = kids.iterator(); iterator.hasNext();) {
- IProgramElement child = (IProgramElement) iterator.next();
+ for (IProgramElement child : kids) {
if (child.getKind() == IProgramElement.Kind.SOURCE_FOLDER && child.getName().equals(sourceFolder)) {
sourceFolderNode = child;
break;
@@ -265,8 +264,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
IProgramElement pkgNode = null;
if (structureModel != null && structureModel.getHierarchy().getRoot() != null && rootForSource.getChildren() != null) {
- for (Iterator<IProgramElement> it = rootForSource.getChildren().iterator(); it.hasNext();) {
- IProgramElement currNode = (IProgramElement) it.next();
+ for (IProgramElement currNode : rootForSource.getChildren()) {
if (pkgName.equals(currNode.getName())) {
pkgNode = currNode;
break;
@@ -641,9 +639,9 @@ public class AsmHierarchyBuilder extends ASTVisitor {
}
ResolvedMember[] members = onType.resolve(world).getDeclaredPointcuts();
if (members != null) {
- for (int i = 0; i < members.length; i++) {
- if (members[i].getName().equals(rp.name)) {
- return members[i];
+ for (ResolvedMember member : members) {
+ if (member.getName().equals(rp.name)) {
+ return member;
}
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
index 7c92b223e..8a3acaec8 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
@@ -137,15 +137,15 @@ public class EclipseAdapterUtils {
// If the user has turned off classfile line number gen, then we may not be able to tell them
// about all secondary locations (pr209372)
int validPlaces = 0;
- for (int ii = 0; ii < seeAlso.length; ii++) {
- if (seeAlso[ii].getSourceLineNumber() >= 0)
+ for (IProblem value : seeAlso) {
+ if (value.getSourceLineNumber() >= 0)
validPlaces++;
}
ISourceLocation[] seeAlsoLocations = new ISourceLocation[validPlaces];
int pos = 0;
- for (int i = 0; i < seeAlso.length; i++) {
- if (seeAlso[i].getSourceLineNumber() >= 0) {
- seeAlsoLocations[pos++] = new SourceLocation(new File(new String(seeAlso[i].getOriginatingFileName())), seeAlso[i]
+ for (IProblem iProblem : seeAlso) {
+ if (iProblem.getSourceLineNumber() >= 0) {
+ seeAlsoLocations[pos++] = new SourceLocation(new File(new String(iProblem.getOriginatingFileName())), iProblem
.getSourceLineNumber());
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseSourceContext.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseSourceContext.java
index f92d37877..31471ad6d 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseSourceContext.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EclipseSourceContext.java
@@ -80,15 +80,14 @@ public class EclipseSourceContext implements IEclipseSourceContext {
if (result == null) return;
IProblem[] probs = result.getProblems();
if (probs!=null) {
- for (int i = 0; i < probs.length; i++) {
- IProblem problem = probs[i];
+ for (IProblem problem : probs) {
if (problem == null) continue;
- if (problem.getID() == IProblem.UnusedMethodDeclaredThrownException
+ if (problem.getID() == IProblem.UnusedMethodDeclaredThrownException
|| problem.getID() == IProblem.UnusedConstructorDeclaredThrownException) {
if (problem.getSourceLineNumber() == problemLineNumber) {
- UnusedDeclaredThrownExceptionFilter filter =
- new UnusedDeclaredThrownExceptionFilter(problem);
- result.removeProblems(filter);
+ UnusedDeclaredThrownExceptionFilter filter =
+ new UnusedDeclaredThrownExceptionFilter(problem);
+ result.removeProblems(filter);
}
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
index 3322ac308..abd1bf5a6 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
@@ -42,8 +42,8 @@ public class EmacsStructureModelManager {
try {
// Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet();
Set fileSet = model.getHierarchy().getFileMapEntrySet();
- for (Iterator it = fileSet.iterator(); it.hasNext();) {
- IProgramElement peNode = (IProgramElement) ((Map.Entry) it.next()).getValue();
+ for (Object o : fileSet) {
+ IProgramElement peNode = (IProgramElement) ((Map.Entry) o).getValue();
dumpStructureToFile(peNode);
}
} catch (IOException ioe) {
@@ -95,9 +95,8 @@ public class EmacsStructureModelManager {
private void printDecls(IProgramElement node) {
print("(");
- for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
+ for (Object nodeObject : node.getChildren()) {
// this ignores relations on the compile unit
- Object nodeObject = it.next();
// throw new RuntimeException("unimplemented");
// if (nodeObject instanceof IProgramElement) {
IProgramElement child = (IProgramElement) nodeObject;
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java
index e255761b6..aeac71571 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java
@@ -55,8 +55,7 @@ public class IncrementalStateManager {
public static void persist() {
// check serialization works
Set<Map.Entry<String, AjState>> entries = incrementalStates.entrySet();
- for (Iterator<Map.Entry<String, AjState>> iterator = entries.iterator(); iterator.hasNext();) {
- Map.Entry<String, AjState> entry = iterator.next();
+ for (Map.Entry<String, AjState> entry : entries) {
System.out.println("Name " + entry.getKey());
File f = new File("n:/temp/foo.ajstate");
try {
@@ -77,8 +76,7 @@ public class IncrementalStateManager {
}
public static void clearIncrementalStates() {
- for (Iterator iter = incrementalStates.values().iterator(); iter.hasNext();) {
- AjState element = (AjState) iter.next();
+ for (AjState element : incrementalStates.values()) {
element.wipeAllKnowledge();
}
incrementalStates.clear();
@@ -101,8 +99,7 @@ public class IncrementalStateManager {
System.err.println("> findStateManagingOutputLocation(" + location + ") has " + allStates.size()
+ " states to look through");
}
- for (Iterator<AjState> iter = allStates.iterator(); iter.hasNext();) {
- AjState element = iter.next();
+ for (AjState element : allStates) {
AjBuildConfig ajbc = element.getBuildConfig();
if (ajbc == null) {
// FIXME asc why can it ever be null?
@@ -121,8 +118,8 @@ public class IncrementalStateManager {
CompilationResultDestinationManager outputManager = ajbc.getCompilationResultDestinationManager();
if (outputManager != null) {
List outputDirs = outputManager.getAllOutputLocations();
- for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
- File dir = (File) iterator.next();
+ for (Object o : outputDirs) {
+ File dir = (File) o;
if (dir.equals(location)) {
if (debugIncrementalStates) {
System.err.println("< findStateManagingOutputLocation(" + location + ") returning " + element);
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
index 6580a388c..57602a440 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
@@ -107,8 +107,8 @@ public class AjASTConverter extends ASTConverter {
adviceDecl.setFlags(adviceDecl.getFlags() | ASTNode.MALFORMED);
break;
case AST.JLS3:
- for (int i = 0, max = typeParameters.length; i < max; i++) {
- ((AroundAdviceDeclaration) adviceDecl).typeParameters().add(convert(typeParameters[i]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter : typeParameters) {
+ ((AroundAdviceDeclaration) adviceDecl).typeParameters().add(convert(typeParameter));
}
}
}
@@ -119,15 +119,15 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = adviceDeclaration.thrownExceptions;
if (thrownExceptions != null) {
int thrownExceptionsLength = thrownExceptions.length;
- for (int i = 0; i < thrownExceptionsLength; i++) {
- adviceDecl.thrownExceptions().add(convert(thrownExceptions[i]));
+ for (TypeReference thrownException : thrownExceptions) {
+ adviceDecl.thrownExceptions().add(convert(thrownException));
}
}
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = adviceDeclaration.arguments;
if (parameters != null) {
int parametersLength = parameters.length;
- for (int i = 0; i < parametersLength; i++) {
- adviceDecl.parameters().add(convert(parameters[i]));
+ for (Argument parameter : parameters) {
+ adviceDecl.parameters().add(convert(parameter));
}
}
int start = adviceDeclaration.sourceStart;
@@ -404,8 +404,8 @@ public class AjASTConverter extends ASTConverter {
methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
break;
default :
- for (int i = 0, max = typeParameters.length; i < max; i++) {
- methodDecl.typeParameters().add(convert(typeParameters[i]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter : typeParameters) {
+ methodDecl.typeParameters().add(convert(typeParameter));
}
}
}
@@ -666,16 +666,16 @@ public class AjASTConverter extends ASTConverter {
}
TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns();
List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns();
- for (int i = 0; i < weaverTypePatterns.length; i++) {
- typePatterns.add(convert(weaverTypePatterns[i]));
+ for (TypePattern weaverTypePattern : weaverTypePatterns) {
+ typePatterns.add(convert(weaverTypePattern));
}
} else if (declare instanceof DeclarePrecedence) {
declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclarePrecedenceDeclaration(this.ast);
DeclarePrecedence dp = (DeclarePrecedence) declare;
TypePattern[] weaverTypePatterns = dp.getPatterns().getTypePatterns();
List typePatterns = ((DeclarePrecedenceDeclaration) declareDeclaration).typePatterns();
- for (int i = 0; i < weaverTypePatterns.length; i++) {
- typePatterns.add(convert(weaverTypePatterns[i]));
+ for (TypePattern weaverTypePattern : weaverTypePatterns) {
+ typePatterns.add(convert(weaverTypePattern));
}
} else if (declare instanceof DeclareSoft) {
declareDeclaration = new DeclareSoftDeclaration(this.ast);
@@ -763,8 +763,8 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = pointcutDeclaration.arguments;
if (parameters != null) {
int parametersLength = parameters.length;
- for (int i = 0; i < parametersLength; i++) {
- pointcutDecl.parameters().add(convert(parameters[i]));
+ for (Argument parameter : parameters) {
+ pointcutDecl.parameters().add(convert(parameter));
}
}
@@ -1141,10 +1141,10 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] expressions = expression.expressions;
if (expressions != null) {
int length = expressions.length;
- for (int i = 0; i < length; i++) {
- Expression expr = super.convert(expressions[i]);
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression value : expressions) {
+ Expression expr = super.convert(value);
if (this.resolveBindings) {
- recordNodes(expr, expressions[i]);
+ recordNodes(expr, value);
}
arrayInitializer.expressions().add(expr);
}
@@ -1505,16 +1505,15 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.ImportReference[] imports = unit.imports;
if (imports != null) {
int importLength = imports.length;
- for (int i = 0; i < importLength; i++) {
- compilationUnit.imports().add(convertImport(imports[i]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ImportReference anImport : imports) {
+ compilationUnit.imports().add(convertImport(anImport));
}
}
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = unit.types;
if (types != null) {
int typesLength = types.length;
- for (int i = 0; i < typesLength; i++) {
- org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration = types[i];
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration : types) {
if (CharOperation.equals(declaration.name, TypeConstants.PACKAGE_INFO_NAME)) {
continue;
}
@@ -1908,8 +1907,8 @@ public class AjASTConverter extends ASTConverter {
forStatement.initializers().add(variableDeclarationExpression);
} else {
int initializationsLength = initializations.length;
- for (int i = 0; i < initializationsLength; i++) {
- Expression initializer = convertToExpression(initializations[i]);
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement initialization : initializations) {
+ Expression initializer = convertToExpression(initialization);
if (initializer != null) {
forStatement.initializers().add(initializer);
} else {
@@ -1924,8 +1923,8 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] increments = statement.increments;
if (increments != null) {
int incrementsLength = increments.length;
- for (int i = 0; i < incrementsLength; i++) {
- forStatement.updaters().add(convertToExpression(increments[i]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement increment : increments) {
+ forStatement.updaters().add(convertToExpression(increment));
}
}
forStatement.setBody(convert(statement.action));
@@ -2062,8 +2061,8 @@ public class AjASTConverter extends ASTConverter {
setTypeNameForAnnotation(annotation, normalAnnotation);
org.aspectj.org.eclipse.jdt.internal.compiler.ast.MemberValuePair[] memberValuePairs = annotation.memberValuePairs;
if (memberValuePairs != null) {
- for (int i = 0, max = memberValuePairs.length; i < max; i++) {
- normalAnnotation.values().add(convert(memberValuePairs[i]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.MemberValuePair memberValuePair : memberValuePairs) {
+ normalAnnotation.values().add(convert(memberValuePair));
}
}
int start = annotation.sourceStart;
@@ -2149,10 +2148,10 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = allocation.arguments;
if (arguments != null) {
int length = arguments.length;
- for (int i = 0; i < length; i++) {
- Expression argument = super.convert(arguments[i]);
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression : arguments) {
+ Expression argument = super.convert(expression);
if (this.resolveBindings) {
- recordNodes(argument, arguments[i]);
+ recordNodes(argument, expression);
}
classInstanceCreation.arguments().add(argument);
}
@@ -2404,8 +2403,8 @@ public class AjASTConverter extends ASTConverter {
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = statement.statements;
if (statements != null) {
int statementsLength = statements.length;
- for (int i = 0; i < statementsLength; i++) {
- switchStatement.statements().add(convert(statements[i]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement value : statements) {
+ switchStatement.statements().add(convert(value));
}
}
return switchStatement;
@@ -2541,13 +2540,13 @@ public class AjASTConverter extends ASTConverter {
if (superInterfaces != null) {
switch(this.ast.apiLevel) {
case AST.JLS2_INTERNAL :
- for (int index = 0, length = superInterfaces.length; index < length; index++) {
- typeDecl.internalSuperInterfaces().add(convert(superInterfaces[index]));
+ for (TypeReference anInterface : superInterfaces) {
+ typeDecl.internalSuperInterfaces().add(convert(anInterface));
}
break;
default :
- for (int index = 0, length = superInterfaces.length; index < length; index++) {
- typeDecl.superInterfaceTypes().add(convertType(superInterfaces[index]));
+ for (TypeReference superInterface : superInterfaces) {
+ typeDecl.superInterfaceTypes().add(convertType(superInterface));
}
}
}
@@ -2558,8 +2557,8 @@ public class AjASTConverter extends ASTConverter {
typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
break;
default :
- for (int index = 0, length = typeParameters.length; index < length; index++) {
- typeDecl.typeParameters().add(convert(typeParameters[index]));
+ for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter : typeParameters) {
+ typeDecl.typeParameters().add(convert(typeParameter));
}
}
}
@@ -2590,8 +2589,8 @@ public class AjASTConverter extends ASTConverter {
TypeReference[] bounds = typeParameter.bounds;
if (bounds != null) {
Type type = null;
- for (int index = 0, length = bounds.length; index < length; index++) {
- type = convertType(bounds[index]);
+ for (TypeReference bound : bounds) {
+ type = convertType(bound);
typeParameter2.typeBounds().add(type);
end = type.getStartPosition() + type.getLength() - 1;
}
@@ -2906,8 +2905,8 @@ public class AjASTConverter extends ASTConverter {
TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments;
if (typeArguments != null) {
Type type2 = null;
- for (int i = 0, max = typeArguments.length; i < max; i++) {
- type2 = convertType(typeArguments[i]);
+ for (TypeReference typeArgument : typeArguments) {
+ type2 = convertType(typeArgument);
((ParameterizedType) type).typeArguments().add(type2);
end = type2.getStartPosition() + type2.getLength() - 1;
}
@@ -2982,8 +2981,8 @@ public class AjASTConverter extends ASTConverter {
int numberOfEnclosingType = 0;
int startingIndex = 0;
int endingIndex = 0;
- for (int i = 0, max = typeArguments.length; i < max; i++) {
- if (typeArguments[i] != null) {
+ for (TypeReference[] typeArgument : typeArguments) {
+ if (typeArgument != null) {
numberOfEnclosingType++;
} else if (numberOfEnclosingType == 0) {
endingIndex++;
@@ -3308,14 +3307,14 @@ public class AjASTConverter extends ASTConverter {
private void lookupForScopes() {
if (this.pendingNameScopeResolution != null) {
- for (Iterator iterator = this.pendingNameScopeResolution.iterator(); iterator.hasNext();) {
- Name name = (Name) iterator.next();
+ for (Object o : this.pendingNameScopeResolution) {
+ Name name = (Name) o;
this.ast.getBindingResolver().recordScope(name, lookupScope(name));
}
}
if (this.pendingThisExpressionScopeResolution != null) {
- for (Iterator iterator = this.pendingThisExpressionScopeResolution.iterator(); iterator.hasNext();) {
- ThisExpression thisExpression = (ThisExpression) iterator.next();
+ for (Object o : this.pendingThisExpressionScopeResolution) {
+ ThisExpression thisExpression = (ThisExpression) o;
this.ast.getBindingResolver().recordScope(thisExpression, lookupScope(thisExpression));
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java
index 8e950cd42..8244a3a8d 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java
@@ -82,8 +82,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
* (element type: <code>IExtendedModifiers</code>)
*/
void printModifiers(List ext) {
- for (Iterator it = ext.iterator(); it.hasNext(); ) {
- ASTNode p = (ASTNode) it.next();
+ for (Object o : ext) {
+ ASTNode p = (ASTNode) o;
p.accept(this);
this.buffer.append(" ");//$NON-NLS-1$
}
@@ -144,8 +144,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
this.buffer.append("@interface ");//$NON-NLS-1$
node.getName().accept(this);
this.buffer.append(" {");//$NON-NLS-1$
- for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
- BodyDeclaration d = (BodyDeclaration) it.next();
+ for (Object o : node.bodyDeclarations()) {
+ BodyDeclaration d = (BodyDeclaration) o;
d.accept(this);
}
this.buffer.append("}\n");//$NON-NLS-1$
@@ -180,8 +180,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
public boolean visit(AnonymousClassDeclaration node) {
this.buffer.append("{\n");//$NON-NLS-1$
this.indent++;
- for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
- BodyDeclaration b = (BodyDeclaration) it.next();
+ for (Object o : node.bodyDeclarations()) {
+ BodyDeclaration b = (BodyDeclaration) o;
b.accept(this);
}
this.indent--;
@@ -210,9 +210,9 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
int dims = at.getDimensions();
Type elementType = at.getElementType();
elementType.accept(this);
- for (Iterator it = node.dimensions().iterator(); it.hasNext(); ) {
+ for (Object o : node.dimensions()) {
this.buffer.append("[");//$NON-NLS-1$
- Expression e = (Expression) it.next();
+ Expression e = (Expression) o;
e.accept(this);
this.buffer.append("]");//$NON-NLS-1$
dims--;
@@ -283,8 +283,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
public boolean visit(Block node) {
this.buffer.append("{\n");//$NON-NLS-1$
this.indent++;
- for (Iterator it = node.statements().iterator(); it.hasNext(); ) {
- Statement s = (Statement) it.next();
+ for (Object o : node.statements()) {
+ Statement s = (Statement) o;
s.accept(this);
}
this.indent--;
@@ -407,12 +407,12 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
if (node.getPackage() != null) {
node.getPackage().accept(this);
}
- for (Iterator it = node.imports().iterator(); it.hasNext(); ) {
- ImportDeclaration d = (ImportDeclaration) it.next();
+ for (Object value : node.imports()) {
+ ImportDeclaration d = (ImportDeclaration) value;
d.accept(this);
}
- for (Iterator it = node.types().iterator(); it.hasNext(); ) {
- AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
+ for (Object o : node.types()) {
+ AbstractTypeDeclaration d = (AbstractTypeDeclaration) o;
d.accept(this);
}
return false;
@@ -593,8 +593,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
}
if (!node.bodyDeclarations().isEmpty()) {
this.buffer.append("; ");//$NON-NLS-1$
- for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
- BodyDeclaration d = (BodyDeclaration) it.next();
+ for (Object o : node.bodyDeclarations()) {
+ BodyDeclaration d = (BodyDeclaration) o;
d.accept(this);
// other body declarations include trailing punctuation
}
@@ -723,9 +723,9 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
final List extendedOperands = node.extendedOperands();
if (extendedOperands.size() != 0) {
this.buffer.append(' ');
- for (Iterator it = extendedOperands.iterator(); it.hasNext(); ) {
+ for (Object extendedOperand : extendedOperands) {
this.buffer.append(node.getOperator().toString()).append(' ');
- Expression e = (Expression) it.next();
+ Expression e = (Expression) extendedOperand;
e.accept(this);
}
}
@@ -765,8 +765,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
public boolean visit(Javadoc node) {
printIndent();
this.buffer.append("/** ");//$NON-NLS-1$
- for (Iterator it = node.tags().iterator(); it.hasNext(); ) {
- ASTNode e = (ASTNode) it.next();
+ for (Object o : node.tags()) {
+ ASTNode e = (ASTNode) o;
e.accept(this);
}
this.buffer.append("\n */\n");//$NON-NLS-1$
@@ -1023,8 +1023,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
if (node.getJavadoc() != null) {
node.getJavadoc().accept(this);
}
- for (Iterator it = node.annotations().iterator(); it.hasNext(); ) {
- Annotation p = (Annotation) it.next();
+ for (Object o : node.annotations()) {
+ Annotation p = (Annotation) o;
p.accept(this);
this.buffer.append(" ");//$NON-NLS-1$
}
@@ -1296,8 +1296,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
this.buffer.append(") ");//$NON-NLS-1$
this.buffer.append("{\n");//$NON-NLS-1$
this.indent++;
- for (Iterator it = node.statements().iterator(); it.hasNext(); ) {
- Statement s = (Statement) it.next();
+ for (Object o : node.statements()) {
+ Statement s = (Statement) o;
s.accept(this);
this.indent--; // incremented in visit(SwitchCase)
}
@@ -1336,8 +1336,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
previousRequiresWhiteSpace = true;
}
boolean previousRequiresNewLine = false;
- for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
- ASTNode e = (ASTNode) it.next();
+ for (Object o : node.fragments()) {
+ ASTNode e = (ASTNode) o;
// assume text elements include necessary leading and trailing whitespace
// but Name, MemberRef, MethodRef, and nested TagElement do not include white space
boolean currentIncludesWhiteSpace = (e instanceof TextElement);
@@ -1398,8 +1398,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
this.buffer.append("try ");//$NON-NLS-1$
node.getBody().accept(this);
this.buffer.append(" ");//$NON-NLS-1$
- for (Iterator it = node.catchClauses().iterator(); it.hasNext(); ) {
- CatchClause cc = (CatchClause) it.next();
+ for (Object o : node.catchClauses()) {
+ CatchClause cc = (CatchClause) o;
cc.accept(this);
}
if (node.getFinally() != null) {
@@ -1494,8 +1494,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor {
this.buffer.append("{\n");//$NON-NLS-1$
this.indent++;
BodyDeclaration prev = null;
- for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
- BodyDeclaration d = (BodyDeclaration) it.next();
+ for (Object o : node.bodyDeclarations()) {
+ BodyDeclaration d = (BodyDeclaration) o;
if (prev instanceof EnumConstantDeclaration) {
// enum constant declarations do not include punctuation
if (d instanceof EnumConstantDeclaration) {
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java
index dd3f296a6..5333ec18f 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java
@@ -173,15 +173,14 @@ public class AjTypeDeclaration extends TypeDeclaration {
List bd = bodyDeclarations();
// ajh02: 0 bodyDeclarations :-/
int pointcutCount = 0;
- for (Iterator it = bd.listIterator(); it.hasNext(); ) {
- if (it.next() instanceof PointcutDeclaration) {
+ for (Object o : bd) {
+ if (o instanceof PointcutDeclaration) {
pointcutCount++;
}
}
PointcutDeclaration[] pointcuts = new PointcutDeclaration[pointcutCount];
int next = 0;
- for (Iterator it = bd.listIterator(); it.hasNext(); ) {
- Object decl = it.next();
+ for (Object decl : bd) {
if (decl instanceof PointcutDeclaration) {
pointcuts[next++] = (PointcutDeclaration) decl;
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java
index ff1a2d1ac..de6afab25 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java
@@ -211,8 +211,7 @@ public class AspectDeclaration extends AjTypeDeclaration {
// ajh02: method added
List bd = bodyDeclarations();
List advice = new ArrayList();
- for (Iterator it = bd.listIterator(); it.hasNext();) {
- Object decl = it.next();
+ for (Object decl : bd) {
if (decl instanceof AdviceDeclaration) {
advice.add(decl);
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
index 4e8235cf2..6f7a1dd7c 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
@@ -119,8 +119,8 @@ public class Main {
}
IMessage[] messages = holder.getMessages(kind, orGreater);
if (!LangUtil.isEmpty(messages)) {
- for (int i = 0; i < messages.length; i++) {
- sink.add(MessagePrinter.render(messages[i]));
+ for (IMessage message : messages) {
+ sink.add(MessagePrinter.render(message));
}
}
}
@@ -264,8 +264,8 @@ public class Main {
boolean skipExit = false;
if (useSystemExit && !LangUtil.isEmpty(args)) { // sigh - pluck -noExit
- for (int i = 0; i < args.length; i++) {
- if ("-noExit".equals(args[i])) {
+ for (String arg : args) {
+ if ("-noExit".equals(arg)) {
skipExit = true;
break;
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
index 5bb86a18c..1f936661e 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
@@ -97,11 +97,11 @@ public class BuildArgParserTestCase extends TestCase {
List cp = config.getClasspath();
boolean jar1Found = false;
boolean jar2Found = false;
- for (Iterator iter = cp.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- if (element.indexOf("1.jar") != -1) jar1Found = true;
- if (element.indexOf("2.jar") != -1) jar2Found = true;
- }
+ for (Object o : cp) {
+ String element = (String) o;
+ if (element.indexOf("1.jar") != -1) jar1Found = true;
+ if (element.indexOf("2.jar") != -1) jar2Found = true;
+ }
assertTrue(
config.getClasspath().toString(),
jar1Found);
@@ -373,11 +373,11 @@ public class BuildArgParserTestCase extends TestCase {
List cp = config.getClasspath();
boolean jar1Found = false;
boolean jar2Found = false;
- for (Iterator iter = cp.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- if (element.indexOf("1.jar") != -1) jar1Found = true;
- if (element.indexOf("2.jar") != -1) jar2Found = true;
- }
+ for (Object o : cp) {
+ String element = (String) o;
+ if (element.indexOf("1.jar") != -1) jar1Found = true;
+ if (element.indexOf("2.jar") != -1) jar2Found = true;
+ }
assertTrue(
config.getClasspath().toString(),
jar1Found);
@@ -405,8 +405,8 @@ public class BuildArgParserTestCase extends TestCase {
String b = new File(TEST_DIR + "../bug-40257/d1/d2/B.java").getCanonicalPath();
String c = new File(TEST_DIR + "../bug-40257/d3/C.java").getCanonicalPath();
List pathList = new ArrayList();
- for (Iterator it = config.getFiles().iterator(); it.hasNext(); ) {
- pathList.add(((File)it.next()).getCanonicalPath());
+ for (File file : config.getFiles()) {
+ pathList.add(file.getCanonicalPath());
}
assertTrue(pathList.contains(a));
assertTrue(pathList.contains(b));
@@ -544,9 +544,9 @@ public class BuildArgParserTestCase extends TestCase {
private void checkPathSubset(List path) throws IOException {
String files[] = { "aspectjJar.file", "jarChild", "parent.zip" };
- for (int i = 0; i < files.length; i++) {
- File file = new File(NONSTANDARD_JAR_DIR+files[i]);
- assertTrue("bad path: " + path, path.contains(file.getCanonicalPath()));
+ for (String s : files) {
+ File file = new File(NONSTANDARD_JAR_DIR + s);
+ assertTrue("bad path: " + path, path.contains(file.getCanonicalPath()));
}
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java
index bcc4ad172..53053d8b3 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java
@@ -74,8 +74,8 @@ public abstract class CommandTestCase extends TestCase {
args.add("-g"); // XXX need this to get sourcefile and line numbers, shouldn't
- for (int i = 0; i < extraArgs.length; i++) {
- args.add(extraArgs[i]);
+ for (String extraArg : extraArgs) {
+ args.add(extraArg);
}
args.add(Constants.TESTDATA_PATH + "/" + source);
@@ -132,10 +132,9 @@ public abstract class CommandTestCase extends TestCase {
assertTrue("expected error", nErrors > 0);
} else {
List errors = new ArrayList(Arrays.asList(myHandler.getErrors()));
- for (int i = 0, len = expectedErrors.length; i < len; i++) {
- int line = expectedErrors[i];
+ for (int line : expectedErrors) {
boolean found = false;
- for (Iterator iter = errors.iterator(); iter.hasNext();) {
+ for (Iterator iter = errors.iterator(); iter.hasNext(); ) {
IMessage m = (IMessage) iter.next();
if (m.getSourceLocation() != null && m.getSourceLocation().getLine() == line) {
found = true;
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java
index 7ca59d741..33f8a48e9 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java
@@ -281,10 +281,9 @@ public class DeclareParentsTest extends AjcTestCase {
// ///////////////////////////////////////////////////////////////////////////
// Check the error messages are comparable (allow for differing orderings)
if (compareErrors) {
- for (Iterator<IMessage> iter = binaryErrorMessages.iterator(); iter.hasNext();) {
- IMessage binaryMessage = iter.next();
+ for (IMessage binaryMessage : binaryErrorMessages) {
IMessage correctSourceMessage = null;
- for (Iterator<IMessage> iterator = sourceErrorMessages.iterator(); iterator.hasNext() && correctSourceMessage == null;) {
+ for (Iterator<IMessage> iterator = sourceErrorMessages.iterator(); iterator.hasNext() && correctSourceMessage == null; ) {
IMessage sourceMessage = iterator.next();
if (sourceMessage.getMessage().equals(binaryMessage.getMessage())) {
@@ -298,8 +297,7 @@ public class DeclareParentsTest extends AjcTestCase {
sourceErrorMessages.remove(correctSourceMessage);
}
if (sourceErrorMessages.size() > 0) {
- for (Iterator<IMessage> iter = sourceErrorMessages.iterator(); iter.hasNext();) {
- IMessage srcMsg = iter.next();
+ for (IMessage srcMsg : sourceErrorMessages) {
System.err.println("This error message from source compilation '" + srcMsg
+ "' didn't occur during binary weaving.");
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java
index 36fe2e92c..6b96c9469 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java
@@ -49,9 +49,9 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests?
MessageHandler h = new MessageHandler();
// boolean result;
StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; i++) {
- sb.append("\n###### results for " + args[i]);
- sb.append("\n" + me.run(new File(args[i]), h) + ": " + h);
+ for (String arg : args) {
+ sb.append("\n###### results for " + arg);
+ sb.append("\n" + me.run(new File(arg), h) + ": " + h);
}
System.err.flush();
System.out.flush();
@@ -260,9 +260,9 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests?
List<String> normalizeFilenames(String[] ra) { // XXX util
ArrayList<String> result = new ArrayList<>();
if (null != ra) {
- for (int i = 0; i < ra.length; i++) {
- result.add(normalizeFilename(ra[i]));
- }
+ for (String s : ra) {
+ result.add(normalizeFilename(s));
+ }
if (1 < ra.length) {
Collections.sort(result);
}
@@ -332,29 +332,28 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests?
info(handler, context);
BitSet foundSet = new BitSet(10);
- for (int i = 0; i < exp.length; i++) {
- final int expLine = exp[i];
+ for (final int expLine : exp) {
boolean found = false;
for (int j = 0; !found && (j < messages.length); j++) {
ISourceLocation sl = messages[j].getSourceLocation();
found = ((null != sl) && (expLine == sl.getLine()));
if (found) {
- info(handler, "found " + label + " for: " + exp[i]);
+ info(handler, "found " + label + " for: " + expLine);
if (foundSet.get(j)) {
info(
- handler,
- "duplicate " + label + " expected: " + exp[i]);
+ handler,
+ "duplicate " + label + " expected: " + expLine);
}
foundSet.set(j);
}
}
if (!found) {
String s =
- "expected "
- + label
- + " not found: "
- + exp[i]
- + context;
+ "expected "
+ + label
+ + " not found: "
+ + expLine
+ + context;
fail(handler, s); // bad short-circuit
if (!result) {
result = false;
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java
index 307232643..b1ebd10ca 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java
@@ -79,14 +79,14 @@ public class WorkingTestMain {
args.add("-classpath");
args.add(Constants.aspectjrtClasspath());
-
- for (int i=0; i < argfiles.length; i++) {
- args.add("@" + examplesDir + argfiles[i]);
+
+ for (String argfile : argfiles) {
+ args.add("@" + examplesDir + argfile);
}
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
- for (int i=0; i < classes.length; i++) {
- TestUtil.runMain("out", classes[i]);
+ for (String aClass : classes) {
+ TestUtil.runMain("out", aClass);
}
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java
index 213cf0e2c..c41e07fe1 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java
@@ -33,42 +33,40 @@ public class AjAST5Test extends AjASTTestCase {
AjAST ajast = createAjAST();
AspectDeclaration d = ajast.newAspectDeclaration();
List props = AspectDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor)o;
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("perClause")) {
assertNull("AspectDeclaration's " + element.getId() + " property" +
- "should be null since we haven't set it yet",
- d.getStructuralProperty(element));
+ "should be null since we haven't set it yet",
+ d.getStructuralProperty(element));
}
} else if (o instanceof SimplePropertyDescriptor) {
- SimplePropertyDescriptor element = (SimplePropertyDescriptor)o;
+ SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
assertNotNull("AspectDeclaration's " + element.getId() + " property" +
- "should not be null since it is a boolean",
+ "should not be null since it is a boolean",
d.getStructuralProperty(element));
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("perClause")) {
PerTypeWithin ptw = ajast.newPerTypeWithin();
- d.setStructuralProperty(element,ptw);
+ d.setStructuralProperty(element, ptw);
assertEquals("AspectDeclaration's perClause property should" +
- " now be a perTypeWithin",ptw,d.getStructuralProperty(element));
+ " now be a perTypeWithin", ptw, d.getStructuralProperty(element));
} else if (element.getId().equals("javadoc")) {
// do nothing since makes no sense to have javadoc
- }
+ }
} else if (o instanceof SimplePropertyDescriptor) {
- SimplePropertyDescriptor element = (SimplePropertyDescriptor)o;
- if (element.getId().equals("privileged")) {
+ SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
+ if (element.getId().equals("privileged")) {
Boolean b = new Boolean(true);
- d.setStructuralProperty(element,b);
+ d.setStructuralProperty(element, b);
assertEquals("AspectDeclaration's isPrivileged property should" +
- " now be a boolean",b,d.getStructuralProperty(element));
- }
+ " now be a boolean", b, d.getStructuralProperty(element));
+ }
}
}
}
@@ -77,26 +75,24 @@ public class AjAST5Test extends AjASTTestCase {
AjAST ajast = createAjAST();
AjTypeDeclaration d = ajast.newAjTypeDeclaration();
List props = AjTypeDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof SimplePropertyDescriptor) {
SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
if (element.getId().equals("aspect")) {
assertNotNull("AjTypeDeclaration's " + element.getId() + " property" +
- " should not be null since it is a boolean",
- d.getStructuralProperty(element));
- }
+ " should not be null since it is a boolean",
+ d.getStructuralProperty(element));
+ }
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof SimplePropertyDescriptor) {
SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
if (element.getId().equals("aspect")) {
Boolean b = new Boolean(true);
- d.setStructuralProperty(element,b);
+ d.setStructuralProperty(element, b);
assertEquals("AjTypeDeclaration's aspect property should" +
- " now be a SignaturePattern",b,d.getStructuralProperty(element));
+ " now be a SignaturePattern", b, d.getStructuralProperty(element));
}
}
}
@@ -106,51 +102,49 @@ public class AjAST5Test extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareParentsDeclaration d = ajast.newDeclareParentsDeclaration();
List props = DeclareParentsDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor)o;
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
assertNull("DeclareParentsDeclaration's " + element.getId() + " property" +
- "should be null since we haven't set it yet",
- d.getStructuralProperty(element));
+ "should be null since we haven't set it yet",
+ d.getStructuralProperty(element));
} else if (o instanceof ChildListPropertyDescriptor) {
- ChildListPropertyDescriptor element = (ChildListPropertyDescriptor)o;
+ ChildListPropertyDescriptor element = (ChildListPropertyDescriptor) o;
assertNotNull("DeclareParentsDeclaration's " + element.getId() + " property" +
- "should not be null since it is a list",
+ "should not be null since it is a list",
d.getStructuralProperty(element));
assertEquals("should only be able to put TypePattern's into the list",
- TypePattern.class,element.getElementType());
+ TypePattern.class, element.getElementType());
} else if (o instanceof SimplePropertyDescriptor) {
- SimplePropertyDescriptor element = (SimplePropertyDescriptor)o;
+ SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
assertNotNull("DeclareParentsDeclaration's " + element.getId() + " property" +
- "should not be null since it is a boolean",
- d.getStructuralProperty(element));
+ "should not be null since it is a boolean",
+ d.getStructuralProperty(element));
} else {
fail("unknown PropertyDescriptor associated with DeclareParentsDeclaration: " + o);
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("childTypePattern")) {
DefaultTypePattern dtp = ajast.newDefaultTypePattern();
- d.setStructuralProperty(element,dtp);
+ d.setStructuralProperty(element, dtp);
assertEquals("DeclareParentsDeclaration's typePattern property should" +
- " now be a DefaultTypePattern",dtp,d.getStructuralProperty(element));
+ " now be a DefaultTypePattern", dtp, d.getStructuralProperty(element));
} else if (element.getId().equals("javadoc")) {
// do nothing since makes no sense to have javadoc
} else {
fail("unknown property for DeclareParentsDeclaration");
- }
+ }
} else if (o instanceof SimplePropertyDescriptor) {
- SimplePropertyDescriptor element = (SimplePropertyDescriptor)o;
- if (element.getId().equals("isExtends")) {
+ SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
+ if (element.getId().equals("isExtends")) {
Boolean b = new Boolean(true);
- d.setStructuralProperty(element,b);
+ d.setStructuralProperty(element, b);
assertEquals("DeclareParentsDeclaration's isExtends property should" +
- " now be a boolean",b,d.getStructuralProperty(element));
- }
+ " now be a boolean", b, d.getStructuralProperty(element));
+ }
}
}
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java
index 96e71cb7e..e4c49b48c 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java
@@ -393,8 +393,7 @@ public class AjASTTest extends AjASTTestCase {
boolean foundName = false;
boolean foundParamList = false;
boolean foundDesignator = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if ((o instanceof ChildPropertyDescriptor)) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
String id = element.getId();
@@ -439,8 +438,7 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
PointcutDeclaration d = ajast.newPointcutDeclaration();
List props = PointcutDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("name")) {
@@ -467,8 +465,7 @@ public class AjASTTest extends AjASTTestCase {
fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + o);
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("designator")) {
@@ -505,8 +502,7 @@ public class AjASTTest extends AjASTTestCase {
boolean foundPerClause = false;
boolean foundIsPrivileged = false;
boolean foundIsAspect = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if ((o instanceof ChildPropertyDescriptor)) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
String id = element.getId();
@@ -735,8 +731,7 @@ public class AjASTTest extends AjASTTestCase {
ajast.newAjTypeDeclaration();
List props = AjTypeDeclaration.propertyDescriptors(AST.JLS3);
boolean foundAspect = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof SimplePropertyDescriptor) {
SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
String id = element.getId();
@@ -770,8 +765,7 @@ public class AjASTTest extends AjASTTestCase {
boolean foundPrivileged = false;
boolean foundPerClause = false;
// boolean foundAspect = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof SimplePropertyDescriptor) {
SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
String id = element.getId();
@@ -802,8 +796,7 @@ public class AjASTTest extends AjASTTestCase {
ajast.newTypeDeclaration();
List props = TypeDeclaration.propertyDescriptors(AST.JLS3);
boolean foundAspect = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof SimplePropertyDescriptor) {
SimplePropertyDescriptor element = (SimplePropertyDescriptor) o;
String id = element.getId();
@@ -831,8 +824,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPattern = false;
boolean foundAnnotationName = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -883,8 +876,8 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareAtFieldDeclaration d = ajast.newDeclareAtFieldDeclaration();
List props = DeclareAtFieldDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("annotationName")) {
assertNotNull("DeclareAtFieldDeclaration's " + element.getId() + " property"
+ " should not be null since it is lazily created", d.getStructuralProperty(element));
@@ -893,8 +886,8 @@ public class AjASTTest extends AjASTTestCase {
+ " should be null since we haven't set it yet", d.getStructuralProperty(element));
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pattern")) {
SignaturePattern p = ajast.newSignaturePattern();
d.setStructuralProperty(element, p);
@@ -929,8 +922,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPattern = false;
boolean foundAnnotationName = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -981,8 +974,8 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareAtMethodDeclaration d = ajast.newDeclareAtMethodDeclaration();
List props = DeclareAtMethodDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("annotationName")) {
assertNotNull("DeclareAtMethodDeclaration's " + element.getId() + " property"
+ " should not be null since it is lazily created", d.getStructuralProperty(element));
@@ -991,8 +984,8 @@ public class AjASTTest extends AjASTTestCase {
+ " should be null since we haven't set it yet", d.getStructuralProperty(element));
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pattern")) {
SignaturePattern p = ajast.newSignaturePattern();
d.setStructuralProperty(element, p);
@@ -1027,8 +1020,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPattern = false;
boolean foundAnnotationName = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -1079,8 +1072,8 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareAtConstructorDeclaration d = ajast.newDeclareAtConstructorDeclaration();
List props = DeclareAtConstructorDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("annotationName")) {
assertNotNull("DeclareAtConstructorDeclaration's " + element.getId() + " property"
+ " should not be null since it is lazily created", d.getStructuralProperty(element));
@@ -1089,8 +1082,8 @@ public class AjASTTest extends AjASTTestCase {
+ " should be null since we haven't set it yet", d.getStructuralProperty(element));
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pattern")) {
SignaturePattern p = ajast.newSignaturePattern();
d.setStructuralProperty(element, p);
@@ -1125,8 +1118,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPattern = false;
boolean foundAnnotationName = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -1177,8 +1170,8 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareAtTypeDeclaration d = ajast.newDeclareAtTypeDeclaration();
List props = DeclareAtTypeDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
if (element.getId().equals("annotationName")) {
assertNotNull("DeclareAtTypeDeclaration's " + element.getId() + " property"
+ " should not be null since it is lazily created", d.getStructuralProperty(element));
@@ -1187,8 +1180,8 @@ public class AjASTTest extends AjASTTestCase {
+ " should be null since we haven't set it yet", d.getStructuralProperty(element));
}
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pattern")) {
DefaultTypePattern p = ajast.newDefaultTypePattern();
d.setStructuralProperty(element, p);
@@ -1223,8 +1216,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPointcut = false;
boolean foundMessage = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -1273,13 +1266,13 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareErrorDeclaration d = ajast.newDeclareErrorDeclaration();
List props = DeclareErrorDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
assertNull("DeclareErrorDeclaration's " + element.getId() + " property" + "should be null since we haven't set it yet",
d.getStructuralProperty(element));
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pointcut")) {
AndPointcut p = ajast.newAndPointcut();
d.setStructuralProperty(element, p);
@@ -1315,8 +1308,7 @@ public class AjASTTest extends AjASTTestCase {
boolean foundTypePattern = false;
boolean foundIsExtends = false;
boolean foundTypePatternList = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if ((o instanceof ChildPropertyDescriptor)) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
String id = element.getId();
@@ -1400,8 +1392,7 @@ public class AjASTTest extends AjASTTestCase {
List props = DeclarePrecedenceDeclaration.propertyDescriptors(AST.JLS3);
boolean foundJavadoc = false;
boolean foundTypePatterns = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if ((o instanceof ChildPropertyDescriptor) && ((ChildPropertyDescriptor) o).getId().equals("javadoc")) {
foundJavadoc = true;
} else if ((o instanceof ChildListPropertyDescriptor)
@@ -1440,8 +1431,7 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclarePrecedenceDeclaration d = ajast.newDeclarePrecedenceDeclaration();
List props = DeclarePrecedenceDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : props) {
if (o instanceof ChildPropertyDescriptor) {
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
assertNull("DeclareErrorDeclaration's " + element.getId() + " property"
@@ -1473,8 +1463,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPointcut = false;
boolean foundTypePattern = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -1523,13 +1513,13 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareSoftDeclaration d = ajast.newDeclareSoftDeclaration();
List props = DeclareSoftDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
assertNull("DeclareSoftDeclaration's " + element.getId() + " property" + "should be null since we haven't set it yet",
d.getStructuralProperty(element));
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pointcut")) {
AndPointcut p = ajast.newAndPointcut();
d.setStructuralProperty(element, p);
@@ -1564,8 +1554,8 @@ public class AjASTTest extends AjASTTestCase {
boolean foundJavadoc = false;
boolean foundPointcut = false;
boolean foundMessage = false;
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
String id = element.getId();
if (id.equals("javadoc")) {
foundJavadoc = true;
@@ -1614,13 +1604,13 @@ public class AjASTTest extends AjASTTestCase {
AjAST ajast = createAjAST();
DeclareWarningDeclaration d = ajast.newDeclareWarningDeclaration();
List props = DeclareWarningDeclaration.propertyDescriptors(AST.JLS3);
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object o : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o;
assertNull("DeclareWarningDeclaration's " + element.getId() + " property"
+ "should be null since we haven't set it yet", d.getStructuralProperty(element));
}
- for (Iterator iter = props.iterator(); iter.hasNext();) {
- ChildPropertyDescriptor element = (ChildPropertyDescriptor) iter.next();
+ for (Object prop : props) {
+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) prop;
if (element.getId().equals("pointcut")) {
AndPointcut p = ajast.newAndPointcut();
d.setStructuralProperty(element, p);
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java
index 94d57c862..b3870c6e8 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java
@@ -88,9 +88,9 @@ public abstract class AjASTTestCase extends TestCase {
protected List<SourceRange> getSourceRanges(int[][] sourceRanges) {
List<SourceRange> convertedRanges = new ArrayList<SourceRange>();
- for (int i = 0; i < sourceRanges.length; i++) {
- convertedRanges.add(new SourceRange(sourceRanges[i][0],
- sourceRanges[i][1]));
+ for (int[] sourceRange : sourceRanges) {
+ convertedRanges.add(new SourceRange(sourceRange[0],
+ sourceRange[1]));
}
return convertedRanges;
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
index facab0e7e..671b310cc 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
@@ -258,8 +258,8 @@ public class Ajc {
private boolean hasSpecifiedIncremental(String[] args) {
if (args == null)
return false;
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-incremental"))
+ for (String arg : args) {
+ if (arg.equals("-incremental"))
return true;
}
return false;
@@ -313,14 +313,14 @@ public class Ajc {
}
private void addMessagesTo(List<IMessage> aList, IMessage[] messages) {
- for (int i = 0; i < messages.length; i++) {
- aList.add(messages[i]);
+ for (IMessage message : messages) {
+ aList.add(message);
}
}
private boolean isIncremental(String[] args) {
- for (int i = 0; i < args.length; i++) {
- if (args[i].trim().equals("-incremental"))
+ for (String arg : args) {
+ if (arg.trim().equals("-incremental"))
return true;
}
return false;
@@ -428,10 +428,10 @@ public class Ajc {
return (toMatch.equals(prefix));
}
});
- for (int i = 0; i < toCopy.length; i++) {
- String toPath = relativeToPath + toCopy[i];
+ for (String s : toCopy) {
+ String toPath = relativeToPath + s;
to = new File(sandbox, toPath);
- FileUtil.copyFile(new File(from.getParentFile(), toCopy[i]), to);
+ FileUtil.copyFile(new File(from.getParentFile(), s), to);
}
} else {
FileUtil.copyFile(from, ret);
@@ -450,8 +450,7 @@ public class Ajc {
System.out.println("start of AJDE structure model:" + prefix); //$NON-NLS-1$
IRelationshipMap asmRelMap = model.getRelationshipMap();
- for (Iterator<String> iter = asmRelMap.getEntries().iterator(); iter.hasNext();) {
- String sourceOfRelationship = iter.next();
+ for (String sourceOfRelationship : asmRelMap.getEntries()) {
System.err.println("Examining source relationship handle: " + sourceOfRelationship);
List<IRelationship> relationships = null;
if (useHandles) {
@@ -461,11 +460,10 @@ public class Ajc {
relationships = asmRelMap.get(ipe);
}
if (relationships != null) {
- for (Iterator<IRelationship> iterator = relationships.iterator(); iterator.hasNext();) {
- Relationship rel = (Relationship) iterator.next();
+ for (IRelationship relationship : relationships) {
+ Relationship rel = (Relationship) relationship;
List<String> targets = rel.getTargets();
- for (Iterator<String> iterator2 = targets.iterator(); iterator2.hasNext();) {
- String t = (String) iterator2.next();
+ for (String t : targets) {
IProgramElement link = model.getHierarchy().findElementForHandle(t);
System.out.println(""); //$NON-NLS-1$
System.out.println(" sourceOfRelationship " + sourceOfRelationship); //$NON-NLS-1$
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
index 3d4572057..a9442de73 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
@@ -1010,9 +1010,9 @@ public abstract class AjcTestCase extends TestCase {
buff.append("Unexpected ");
buff.append(type);
buff.append(" messages:\n");
- for (Iterator iter = messages.iterator(); iter.hasNext();) {
+ for (Object message : messages) {
buff.append("\t");
- buff.append(iter.next().toString());
+ buff.append(message.toString());
buff.append("\n");
}
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java
index 1265e4502..a7d661038 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java
@@ -174,49 +174,49 @@ public class CompilationResult {
}
buff.append("\n");
int msgNo = 1;
- for (Iterator iter = failMessages.iterator(); iter.hasNext();) {
+ for (IMessage failMessage : failMessages) {
buff.append("[fail ");
buff.append(msgNo++);
buff.append("] ");
- buff.append(iter.next().toString());
+ buff.append(failMessage.toString());
buff.append("\n");
}
msgNo = 1;
- for (Iterator iter = errorMessages.iterator(); iter.hasNext();) {
+ for (IMessage errorMessage : errorMessages) {
buff.append("[error ");
buff.append(msgNo++);
buff.append("] ");
- buff.append(iter.next().toString());
+ buff.append(errorMessage.toString());
buff.append("\n");
}
msgNo = 1;
- for (Iterator iter = warningMessages.iterator(); iter.hasNext();) {
+ for (IMessage warningMessage : warningMessages) {
buff.append("[warning ");
buff.append(msgNo++);
buff.append("] ");
- buff.append(iter.next().toString());
+ buff.append(warningMessage.toString());
buff.append("\n");
}
msgNo = 1;
- for (Iterator iter = infoMessages.iterator(); iter.hasNext();) {
+ for (IMessage infoMessage : infoMessages) {
buff.append("[info ");
buff.append(msgNo++);
buff.append("] ");
- buff.append(iter.next().toString());
+ buff.append(infoMessage.toString());
buff.append("\n");
}
msgNo = 1;
- for (Iterator iter = weaveMessages.iterator(); iter.hasNext();) {
+ for (IMessage weaveMessage : weaveMessages) {
buff.append("[weaveInfo ");
buff.append(msgNo++);
buff.append("] ");
- buff.append(iter.next().toString());
+ buff.append(weaveMessage.toString());
buff.append("\n");
}
buff.append("\ncommand was: 'ajc");
- for (int i = 0; i < args.length; i++) {
+ for (String arg : args) {
buff.append(' ');
- buff.append(args[i]);
+ buff.append(arg);
}
buff.append("'\n");
return buff.toString();
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java
index 019a51849..9dff188ed 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java
@@ -29,45 +29,45 @@ public class DelegatingOutputStream extends OutputStream {
public void close() throws IOException {
target.close();
-
- for (Iterator i = delegates.iterator(); i.hasNext();) {
- OutputStream delegate = (OutputStream)i.next();
+
+ for (Object o : delegates) {
+ OutputStream delegate = (OutputStream) o;
delegate.close();
}
}
public void flush() throws IOException {
target.flush();
-
- for (Iterator i = delegates.iterator(); i.hasNext();) {
- OutputStream delegate = (OutputStream)i.next();
+
+ for (Object o : delegates) {
+ OutputStream delegate = (OutputStream) o;
delegate.flush();
}
}
public void write(byte[] b, int off, int len) throws IOException {
if (verbose) target.write(b, off, len);
-
- for (Iterator i = delegates.iterator(); i.hasNext();) {
- OutputStream delegate = (OutputStream)i.next();
- delegate.write(b,off,len);
+
+ for (Object o : delegates) {
+ OutputStream delegate = (OutputStream) o;
+ delegate.write(b, off, len);
}
}
public void write(byte[] b) throws IOException {
if (verbose) target.write(b);
-
- for (Iterator i = delegates.iterator(); i.hasNext();) {
- OutputStream delegate = (OutputStream)i.next();
+
+ for (Object o : delegates) {
+ OutputStream delegate = (OutputStream) o;
delegate.write(b);
}
}
public void write(int b) throws IOException {
if (verbose) target.write(b);
-
- for (Iterator i = delegates.iterator(); i.hasNext();) {
- OutputStream delegate = (OutputStream)i.next();
+
+ for (Object o : delegates) {
+ OutputStream delegate = (OutputStream) o;
delegate.write(b);
}
}