Bug 534783 – SWT tools isn't rebuilding natives after foreach patch
Revert "For each conversion in swt.tools."
This reverts commit 9a92da14a27e579409c00ff3eefd197eac4209da.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=534783
Change-Id: I464b41bdc9bdd125b1f56b501e226fb89ceca310
Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java
index e54221e..a642b92 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java
@@ -37,8 +37,8 @@
if (file.exists()) {
return file.getAbsolutePath();
}
- for (String import1 : imports) {
- file = new File(basePath + import1.replace('.', '/') + "/" + simpleName + ".java");
+ for (int i = 0; i < imports.length; i++) {
+ file = new File(basePath + imports[i].replace('.', '/') + "/" + simpleName + ".java");
if (file.exists()) {
return file.getAbsolutePath();
}
@@ -53,10 +53,10 @@
if (file.exists()) {
return packageName + "." + simpleName;
}
- for (String import1 : imports) {
- file = new File(basePath + import1.replace('.', '/') + "/" + simpleName + ".java");
+ for (int i = 0; i < imports.length; i++) {
+ file = new File(basePath + imports[i].replace('.', '/') + "/" + simpleName + ".java");
if (file.exists()) {
- return import1 + "." + simpleName;
+ return imports[i] + "." + simpleName;
}
}
return simpleName;
@@ -99,7 +99,8 @@
FieldDeclaration[] fields = type.getFields();
List<ASTField> fid = new ArrayList<>();
- for (FieldDeclaration field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ FieldDeclaration field = fields[i];
List<VariableDeclarationFragment> fragments = field.fragments();
for (VariableDeclarationFragment fragment : fragments) {
fid.add(new ASTField(this, source, field, fragment));
@@ -108,9 +109,9 @@
this.fields = fid.toArray(new ASTField[fid.size()]);
MethodDeclaration[] methods = type.getMethods();
List<ASTMethod> mid = new ArrayList<>();
- for (MethodDeclaration method : methods) {
- if (method.getReturnType2() == null) continue;
- mid.add(new ASTMethod(this, source, method));
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getReturnType2() == null) continue;
+ mid.add(new ASTMethod(this, source, methods[i]));
}
this.methods = mid.toArray(new ASTMethod[mid.size()]);
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java
index 4427e75..1f490d2 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java
@@ -100,7 +100,7 @@
@Override
public String getCast() {
String cast = ((String)getParam("cast")).trim();
- if (!cast.isEmpty()) {
+ if (cast.length() > 0) {
if (!cast.startsWith("(")) cast = "(" + cast;
if (!cast.endsWith(")")) cast = cast + ")";
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java
index c251dc5..a8cd8ce 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java
@@ -64,7 +64,8 @@
paramTypes64 = new ASTType[parameters.size()];
this.parameters = new ASTParameter[paramTypes.length];
int i = 0;
- for (SingleVariableDeclaration param : parameters) {
+ for (Iterator<SingleVariableDeclaration> iterator = parameters.iterator(); iterator.hasNext(); i++) {
+ SingleVariableDeclaration param = iterator.next();
paramTypes[i] = new ASTType(declaringClass.resolver, param.getType(), param.getExtraDimensions());
paramTypes64[i] = paramTypes[i];
this.parameters[i] = new ASTParameter(this, i, param.getName().getIdentifier());
@@ -115,7 +116,8 @@
boolean result = true;
String name = getName();
JNIMethod[] methods = declaringClass.getDeclaredMethods();
- for (JNIMethod mth : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod mth = methods[i];
if ((mth.getModifiers() & Modifier.NATIVE) != 0 &&
this != mth && !this.equals(mth) &&
name.equals(mth.getName()))
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java
index bf40e00..181d347 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java
@@ -31,7 +31,8 @@
Set<String> set = params.keySet();
String[] keys = set.toArray(new String[set.size()]);
Arrays.sort(keys);
- for (String key : keys) {
+ for (int j = 0; j < keys.length; j++) {
+ String key = keys[j];
Object value = params.get(key);
String valueStr = "";
if (value instanceof String) {
@@ -76,8 +77,8 @@
@Override
public boolean getFlag(String flag) {
String[] flags = getFlags();
- for (String flag2 : flags) {
- if (flag2.equals(flag)) return true;
+ for (int i = 0; i < flags.length; i++) {
+ if (flags[i].equals(flag)) return true;
}
return false;
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java
index fa768cd..8f4cc1c 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java
@@ -99,7 +99,8 @@
if (entries == null) {
entries = new String[0];
}
- for (String entry : entries) {
+ for (int i = 0; i < entries.length; i++) {
+ String entry = entries[i];
File f = new File(file, entry);
if (!f.isDirectory()) {
if (f.getAbsolutePath().endsWith(".java")) {
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java
index d0192c7..69b58d0 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,7 +40,8 @@
public void generate(JNIField[] fields) {
sort(fields);
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if ((field.getModifiers() & Modifier.FINAL) == 0) continue;
generate(field);
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java
index 293f759..db66465 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,8 @@
public void generate(JNIMethod[] methods) {
sort(methods);
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
generate(method);
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java
index 385371f..8bce4db 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.tools.internal;
-import java.lang.reflect.*;
+import java.lang.reflect.Modifier;
public class ConstantsGenerator extends JNIGenerator {
@@ -23,7 +23,8 @@
public void generate(JNIField[] fields) {
sort(fields);
outputln("int main() {");
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if ((field.getModifiers() & Modifier.FINAL) == 0) continue;
generate(field);
}
@@ -51,7 +52,8 @@
}
try {
ConstantsGenerator gen = new ConstantsGenerator();
- for (String clazzName : args) {
+ for (int i = 0; i < args.length; i++) {
+ String clazzName = args[i];
Class<?> clazz = Class.forName(clazzName);
gen.generate(new ReflectClass(clazz));
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java
index 23694e7..1c457c1 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java
@@ -49,7 +49,8 @@
}
public void generate(JNIField[] fields) {
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
int mods = field.getModifiers();
if ((mods & Modifier.PUBLIC) == 0) continue;
if ((mods & Modifier.FINAL) != 0) continue;
@@ -69,7 +70,8 @@
}
public void generate(JNIMethod[] methods) {
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
generate(method);
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java
index 83557aa..110167a 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java
@@ -131,7 +131,8 @@
StringBuilder buffer = new StringBuilder();
buffer.append(function);
buffer.append("__");
- for (JNIType paramType : paramTypes) {
+ for (int i = 0; i < paramTypes.length; i++) {
+ JNIType paramType = paramTypes[i];
buffer.append(toC(paramType.getTypeSignature(false)));
}
return buffer.toString();
@@ -216,7 +217,8 @@
generateAutoGenNote();
generateIncludes();
sort(classes);
- for (JNIClass clazz : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ JNIClass clazz = classes[i];
if (getGenerate(clazz)) generate(clazz);
if (progress != null) progress.step();
}
@@ -236,7 +238,8 @@
}
public boolean getCPP() {
- for (JNIClass clazz : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ JNIClass clazz = classes[i];
if (clazz.getFlag(FLAG_CPP)) {
return true;
}
@@ -269,7 +272,8 @@
}
public boolean getM() {
- for (JNIClass clazz : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ JNIClass clazz = classes[i];
if (clazz.getFlag(FLAG_M)) {
return true;
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
index 6125715..8a9ed87 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -226,9 +226,11 @@
this.progress = progress;
if (progress != null) {
int nativeCount = 0;
- for (JNIClass clazz : natives) {
+ for (int i = 0; i < natives.length; i++) {
+ JNIClass clazz = natives[i];
JNIMethod[] methods = clazz.getDeclaredMethods();
- for (JNIMethod method : methods) {
+ for (int j = 0; j < methods.length; j++) {
+ JNIMethod method = methods[j];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
nativeCount++;
}
@@ -297,7 +299,8 @@
if(entries == null) {
entries = new String[0];
}
- for (String entry : entries) {
+ for (int i = 0; i < entries.length; i++) {
+ String entry = entries[i];
File f = new File(file, entry);
if (!f.isDirectory()) {
if (f.getAbsolutePath().endsWith(".class")) {
@@ -351,7 +354,8 @@
if (files == null) {
files = new File[0];
}
- for (File file : files) {
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
try {
String path = file.getAbsolutePath().replace('\\', '/');
if (path.endsWith(".java")) {
@@ -377,9 +381,11 @@
public JNIClass[] getNativesClasses(JNIClass[] classes) {
if (mainClass == null) return new JNIClass[0];
List<JNIClass> result = new ArrayList<>();
- for (JNIClass clazz : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ JNIClass clazz = classes[i];
JNIMethod[] methods = clazz.getDeclaredMethods();
- for (JNIMethod method : methods) {
+ for (int j = 0; j < methods.length; j++) {
+ JNIMethod method = methods[j];
int mods = method.getModifiers();
if ((mods & Modifier.NATIVE) != 0) {
result.add(clazz);
@@ -404,7 +410,8 @@
}
JNIField[] fields = clazz.getDeclaredFields();
boolean hasPublicFields = false;
- for (JNIField field : fields) {
+ for (int j = 0; j < fields.length; j++) {
+ JNIField field = fields[j];
int mods = field.getModifiers();
if ((mods & Modifier.PUBLIC) != 0 && (mods & Modifier.STATIC) == 0) {
hasPublicFields = true;
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java
index 21274bd..7a0834b 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java
@@ -152,7 +152,8 @@
shell.setCursor(cursor);
shell.setEnabled(false);
Control[] children = actionsPanel.getChildren();
- for (Control child : children) {
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
if (child instanceof Button) child.setEnabled(false);
}
boolean showProgress = true;
@@ -200,7 +201,8 @@
while (!done[0]) {
if (!display.readAndDispatch()) display.sleep();
}
- for (Control child : children) {
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
if (child instanceof Button) child.setEnabled(true);
}
if (showProgress) {
@@ -238,7 +240,8 @@
TableItem[] selection = membersLt.getSelection();
JNIMethod[] methods = new JNIMethod[selection.length];
int count = 0;
- for (TableItem item : selection) {
+ for (int i = 0; i < selection.length; i++) {
+ TableItem item = selection [i];
Object data = item.getData();
if (data instanceof JNIMethod) {
methods[count++] = (JNIMethod)data;
@@ -256,7 +259,8 @@
TableItem[] selection = membersLt.getSelection();
JNIField[] fields = new JNIField[selection.length];
int count = 0;
- for (TableItem item : selection) {
+ for (int i = 0; i < selection.length; i++) {
+ TableItem item = selection [i];
Object data = item.getData();
if (data instanceof JNIField) {
fields[count++] = (JNIField)data;
@@ -911,7 +915,8 @@
String getFlagsString(String[] flags) {
if (flags.length == 0) return "";
StringBuilder buffer = new StringBuilder();
- for (String flag : flags) {
+ for (int j = 0; j < flags.length; j++) {
+ String flag = flags[j];
if (buffer.length() != 0) buffer.append(", ");
buffer.append(flag);
}
@@ -953,7 +958,8 @@
item.setChecked(clazz.getGenerate());
}
TableColumn[] columns = classesLt.getColumns();
- for (TableColumn column : columns) {
+ for (int i = 0; i < columns.length; i++) {
+ TableColumn column = columns[i];
column.pack();
}
classesLt.setSelection(mainIndex);
@@ -963,7 +969,8 @@
membersLt.removeAll();
membersLt.setHeaderVisible(false);
TableColumn[] columns = membersLt.getColumns();
- for (TableColumn column : columns) {
+ for (int i = 0; i < columns.length; i++) {
+ TableColumn column = columns[i];
column.dispose();
}
int[] indices = classesLt.getSelectionIndices();
@@ -972,7 +979,8 @@
JNIClass clazz = (JNIClass)classItem.getData();
boolean hasNatives = false;
JNIMethod[] methods = clazz.getDeclaredMethods();
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
int mods = method.getModifiers();
if (hasNatives =((mods & Modifier.NATIVE) != 0)) break;
}
@@ -990,7 +998,8 @@
column.setText("Exclude");
*/
JNIGenerator.sort(methods);
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
TableItem item = new TableItem(membersLt, SWT.NONE);
item.setData(method);
@@ -1017,7 +1026,8 @@
column.setText("Exclude");
*/
JNIField[] fields = clazz.getDeclaredFields();
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
int mods = field.getModifiers();
if (((mods & Modifier.PUBLIC) == 0) ||
((mods & Modifier.FINAL) != 0) ||
@@ -1035,7 +1045,8 @@
}
}
columns = membersLt.getColumns();
- for (TableColumn column : columns) {
+ for (int i = 0; i < columns.length; i++) {
+ TableColumn column = columns[i];
column.pack();
}
membersLt.setHeaderVisible(true);
@@ -1065,7 +1076,8 @@
item.setText(PARAM_FLAGS_COLUMN, getFlagsString(param.getFlags()));
}
TableColumn[] columns = paramsLt.getColumns();
- for (TableColumn column : columns) {
+ for (int i = 0; i < columns.length; i++) {
+ TableColumn column = columns[i];
column.pack();
}
paramsLt.setRedraw(true);
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java
index 284516f..44f58a3 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,7 +33,8 @@
}
public void generate(JNIField[] fields) {
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
int mods = field.getModifiers();
if ((mods & Modifier.PUBLIC) == 0) continue;
if ((mods & Modifier.FINAL) != 0) continue;
@@ -53,7 +54,8 @@
public void generate(JNIMethod[] methods) {
sort(methods);
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
generate(method);
outputln();
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java
index c8583e5..f4ae947 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -72,7 +72,8 @@
public void generate(JNIMethod[] methods) {
sort(methods);
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
generate(method);
if (progress != null) progress.step();
@@ -222,7 +223,8 @@
void generateExcludes(JNIMethod[] methods) {
HashSet<String> excludes = new HashSet<>();
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
String exclude = method.getExclude();
if (exclude.length() != 0) {
@@ -231,7 +233,8 @@
}
for (String exclude: excludes) {
outputln(exclude);
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
String methodExclude = method.getExclude();
if (exclude.equals(methodExclude)) {
@@ -520,7 +523,8 @@
boolean generateGetters(JNIMethod method, JNIParameter[] params) {
boolean genFailTag = false;
int criticalCount = 0;
- for (JNIParameter param : params) {
+ for (int i = 0; i < params.length; i++) {
+ JNIParameter param = params[i];
if (!isCritical(param)) {
genFailTag |= generateGetParameter(method, param, false, 1);
} else {
@@ -528,7 +532,8 @@
}
}
if (criticalCount != 0) {
- for (JNIParameter param : params) {
+ for (int i = 0; i < params.length; i++) {
+ JNIParameter param = params[i];
if (isCritical(param)) {
genFailTag |= generateGetParameter(method, param, true, 2);
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java
index da66896..6cc20a8 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java
@@ -97,7 +97,7 @@
@Override
public String getCast() {
String cast = ((String)getParam("cast")).trim();
- if (!cast.isEmpty()) {
+ if (cast.length() > 0) {
if (!cast.startsWith("(")) cast = "(" + cast;
if (!cast.endsWith(")")) cast = cast + ")";
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java
index e8a68ed..aef0caf 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -128,7 +128,8 @@
boolean result = true;
String name = getName();
JNIMethod[] methods = declaringClass.getDeclaredMethods();
- for (JNIMethod mth : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod mth = methods[i];
if ((mth.getModifiers() & Modifier.NATIVE) != 0 &&
this != mth && !this.equals(mth) &&
name.equals(mth.getName()))
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java
index a56ea3f..872a31c 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.tools.internal;
-import java.lang.reflect.*;
+import java.lang.reflect.Modifier;
public class SizeofGenerator extends JNIGenerator {
@@ -36,7 +36,8 @@
public void generate(JNIField[] fields) {
sort(fields);
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if ((field.getModifiers() & Modifier.FINAL) == 0) continue;
generate(field);
}
@@ -57,7 +58,8 @@
}
try {
SizeofGenerator gen = new SizeofGenerator();
- for (String clazzName : args) {
+ for (int i = 0; i < args.length; i++) {
+ String clazzName = args[i];
Class<?> clazz = Class.forName(clazzName);
gen.generate(new ReflectClass(clazz));
}
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java
index 8ccab69..f6d766b 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.tools.internal;
-import java.lang.reflect.*;
+import java.lang.reflect.Modifier;
public class StatsGenerator extends JNIGenerator {
@@ -110,7 +110,8 @@
output(className);
outputln("_nativeFunctionNames[] = {");
sort(methods);
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
String function = getFunctionName(method), function64 = getFunctionName(method, method.getParameterTypes64());
if (!function.equals(function64)) {
@@ -192,7 +193,8 @@
void generateFunctionEnum(JNIMethod[] methods) {
if (methods.length == 0) return;
outputln("typedef enum {");
- for (JNIMethod method : methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JNIMethod method = methods[i];
if ((method.getModifiers() & Modifier.NATIVE) == 0) continue;
String function = getFunctionName(method), function64 = getFunctionName(method, method.getParameterTypes64());
if (!function.equals(function64)) {
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java
index f58d9c9..bc8d30c 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -80,7 +80,8 @@
void generateExcludes(JNIClass[] classes) {
HashSet<String> excludes = new HashSet<>();
- for (JNIClass clazz : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ JNIClass clazz = classes[i];
String exclude = clazz.getExclude();
if (exclude.length() != 0) {
excludes.add(exclude);
@@ -88,7 +89,8 @@
}
for (String exclude : excludes) {
outputln(exclude);
- for (JNIClass clazz : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ JNIClass clazz = classes[i];
String classExclude = clazz.getExclude();
if (exclude.equals(classExclude)) {
output("#define NO_");
@@ -199,7 +201,8 @@
output("\tjfieldID ");
JNIField[] fields = clazz.getDeclaredFields();
boolean first = true;
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if (ignoreField(field)) continue;
if (!first) output(", ");
output(field.getName());
@@ -245,7 +248,8 @@
}
outputln();
JNIField[] fields = clazz.getDeclaredFields();
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if (ignoreField(field)) continue;
output("\t");
output(clazzName);
@@ -289,7 +293,8 @@
}
}
JNIField[] fields = clazz.getDeclaredFields();
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if (ignoreField(field)) continue;
String exclude = field.getExclude();
if (exclude.length() != 0) {
@@ -442,7 +447,8 @@
}
}
JNIField[] fields = clazz.getDeclaredFields();
- for (JNIField field : fields) {
+ for (int i = 0; i < fields.length; i++) {
+ JNIField field = fields[i];
if (ignoreField(field)) continue;
String exclude = field.getExclude();
if (exclude.length() != 0) {
diff --git a/bundles/org.eclipse.swt.tools/JavadocBasher/org/eclipse/swt/tools/internal/JavadocBasher.java b/bundles/org.eclipse.swt.tools/JavadocBasher/org/eclipse/swt/tools/internal/JavadocBasher.java
index 6d6a3e5..f8dc4c1 100644
--- a/bundles/org.eclipse.swt.tools/JavadocBasher/org/eclipse/swt/tools/internal/JavadocBasher.java
+++ b/bundles/org.eclipse.swt.tools/JavadocBasher/org/eclipse/swt/tools/internal/JavadocBasher.java
@@ -450,7 +450,7 @@
};
for (Entry<String, String> entry: comments.entrySet()) {
String name = entry.getKey();
- if (!entry.getValue().isEmpty()){
+ if (entry.getValue().length() > 0){
int i = 0;
for (i = 0; i < filter.length; i++) {
if (name.equals(filter[i])) break;
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
index 58adc94..2c9e7c2 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2018 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -50,7 +50,8 @@
if (path == null) return;
File[] frameworks = path.listFiles();
if (frameworks == null) return;
- for (File file : frameworks) {
+ for (int i = 0; i < frameworks.length; i++) {
+ File file = frameworks[i];
String name = file.getName();
int index = name.lastIndexOf(".");
if (index != -1) {
@@ -673,7 +674,8 @@
ArrayList<Node> methods = (ArrayList<Node>)clazz[1];
Object[] superclass = classes.get(getSuperclassName(node));
if (superclass != null) {
- for (Node method : ((ArrayList<Node>) superclass[1])) {
+ for (Iterator<Node> iterator2 = ((ArrayList<Node>)superclass[1]).iterator(); iterator2.hasNext();) {
+ Node method = iterator2.next();
if (isStatic(method)) {
methods.add(method);
}
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGeneratorUI.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGeneratorUI.java
index 8621562..d5a3106 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGeneratorUI.java
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGeneratorUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2018 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,9 +41,9 @@
parentItem = lastParent;
} else {
TreeItem[] items = superItem.getItems();
- for (TreeItem item : items) {
- if (name.equals(item.getData())) {
- parentItem = item;
+ for (int i = 0; i < items.length; i++) {
+ if (name.equals(items[i].getData())) {
+ parentItem = items[i];
break;
}
}
@@ -122,15 +122,15 @@
}
/* Figure out categories state */
TreeItem[] items = item.getItems();
- for (TreeItem item2 : items) {
- TreeItem[] children = item2.getItems();
+ for (int i = 0; i < items.length; i++) {
+ TreeItem[] children = items[i].getItems();
int checkedCount = 0;
for (int j = 0; j < children.length; j++) {
if (children[j].getChecked()) checkedCount++;
if (children[j].getGrayed()) break;
}
- item2.setChecked(checkedCount != 0);
- item2.setGrayed(checkedCount != children.length);
+ items[i].setChecked(checkedCount != 0);
+ items[i].setGrayed(checkedCount != children.length);
}
}
}
@@ -275,27 +275,30 @@
// editorTx.addListener(SWT.FocusOut, textListener);
editorTx.addListener(SWT.KeyDown, textListener);
editorTx.addListener(SWT.Traverse, textListener);
- attribTable.addListener(SWT.MouseDown, e -> e.display.asyncExec (() -> {
- if (attribTable.isDisposed ()) return;
- if (e.button != 1) return;
- Point pt = new Point(e.x, e.y);
- TableItem item = attribTable.getItem(pt);
- if (item == null) return;
- int column = -1;
- for (int i = 0; i < attribTable.getColumnCount(); i++) {
- if (item.getBounds(i).contains(pt)) {
- column = i;
- break;
- }
+ attribTable.addListener(SWT.MouseDown, e -> e.display.asyncExec (new Runnable () {
+ @Override
+ public void run () {
+ if (attribTable.isDisposed ()) return;
+ if (e.button != 1) return;
+ Point pt = new Point(e.x, e.y);
+ TableItem item = attribTable.getItem(pt);
+ if (item == null) return;
+ int column = -1;
+ for (int i = 0; i < attribTable.getColumnCount(); i++) {
+ if (item.getBounds(i).contains(pt)) {
+ column = i;
+ break;
+ }
+ }
+ if (column == -1) return;
+ if (!getEditable(item, column)) return;
+ editor.setColumn(column);
+ editor.setItem(item);
+ editorTx.setText(item.getText(column));
+ editorTx.selectAll();
+ editorTx.setVisible(true);
+ editorTx.setFocus();
}
- if (column == -1) return;
- if (!getEditable(item, column)) return;
- editor.setColumn(column);
- editor.setItem(item);
- editorTx.setText(item.getText(column));
- editorTx.selectAll();
- editorTx.setVisible(true);
- editorTx.setFocus();
}));
return comp;
@@ -453,12 +456,13 @@
}
TreeItem findItem(TreeItem[] items, Node node) {
- for (TreeItem item : items) {
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[i];
checkChildren(item);
if (item.getData() == node) return item;
}
- for (TreeItem item : items) {
- TreeItem child = findItem(item.getItems(), node);
+ for (int i = 0; i < items.length; i++) {
+ TreeItem child = findItem(items[i].getItems(), node);
if (child != null) return child;
}
return null;
diff --git a/bundles/org.eclipse.swt.tools/NativeStats/org/eclipse/swt/tools/internal/NativeStats.java b/bundles/org.eclipse.swt.tools/NativeStats/org/eclipse/swt/tools/internal/NativeStats.java
index 553f0ef..dd45df8 100644
--- a/bundles/org.eclipse.swt.tools/NativeStats/org/eclipse/swt/tools/internal/NativeStats.java
+++ b/bundles/org.eclipse.swt.tools/NativeStats/org/eclipse/swt/tools/internal/NativeStats.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -109,14 +109,16 @@
if (funcs == null) return;
Arrays.sort(funcs);
int total = 0;
- for (NativeFunction func : funcs) {
+ for (int i = 0; i < funcs.length; i++) {
+ NativeFunction func = funcs[i];
total += func.getCallCount();
}
ps.print(className);
ps.print("=");
ps.print(total);
ps.println();
- for (NativeFunction func : funcs) {
+ for (int i = 0; i < funcs.length; i++) {
+ NativeFunction func = funcs[i];
if (func.getCallCount() > 0) {
ps.print("\t");
ps.print(func.getName());
@@ -133,7 +135,8 @@
public Map<String, NativeFunction[]> snapshot() {
Map<String, NativeFunction[]> snapshot = new HashMap<>();
- for (String className : classes) {
+ for (int i = 0; i < classes.length; i++) {
+ String className = classes[i];
snapshot(className, snapshot);
}
return snapshot;