diff options
author | Alexander Kurtakov | 2018-04-27 10:18:26 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-04-27 10:20:34 +0000 |
commit | 9a92da14a27e579409c00ff3eefd197eac4209da (patch) | |
tree | 04e77e62326f7d3f4e651b00efbb88f98114dca3 /bundles/org.eclipse.swt.tools/JNI Generation/org | |
parent | d31a640dc02a4f04fd0b8c1b1d3ee6ea59377acf (diff) | |
download | eclipse.platform.swt-9a92da14a27e579409c00ff3eefd197eac4209da.tar.gz eclipse.platform.swt-9a92da14a27e579409c00ff3eefd197eac4209da.tar.xz eclipse.platform.swt-9a92da14a27e579409c00ff3eefd197eac4209da.zip |
For each conversion in swt.tools.
Change-Id: I9b24de33ba07df5717bb32326392f24555d5c88d
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt.tools/JNI Generation/org')
19 files changed, 77 insertions, 129 deletions
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 a642b92ed9..e54221e232 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 @@ public class ASTClass extends ASTItem implements JNIClass { if (file.exists()) { return file.getAbsolutePath(); } - for (int i = 0; i < imports.length; i++) { - file = new File(basePath + imports[i].replace('.', '/') + "/" + simpleName + ".java"); + for (String import1 : imports) { + file = new File(basePath + import1.replace('.', '/') + "/" + simpleName + ".java"); if (file.exists()) { return file.getAbsolutePath(); } @@ -53,10 +53,10 @@ public class ASTClass extends ASTItem implements JNIClass { if (file.exists()) { return packageName + "." + simpleName; } - for (int i = 0; i < imports.length; i++) { - file = new File(basePath + imports[i].replace('.', '/') + "/" + simpleName + ".java"); + for (String import1 : imports) { + file = new File(basePath + import1.replace('.', '/') + "/" + simpleName + ".java"); if (file.exists()) { - return imports[i] + "." + simpleName; + return import1 + "." + simpleName; } } return simpleName; @@ -99,8 +99,7 @@ public ASTClass(String sourcePath, MetaData metaData) { FieldDeclaration[] fields = type.getFields(); List<ASTField> fid = new ArrayList<>(); - for (int i = 0; i < fields.length; i++) { - FieldDeclaration field = fields[i]; + for (FieldDeclaration field : fields) { List<VariableDeclarationFragment> fragments = field.fragments(); for (VariableDeclarationFragment fragment : fragments) { fid.add(new ASTField(this, source, field, fragment)); @@ -109,9 +108,9 @@ public ASTClass(String sourcePath, MetaData metaData) { this.fields = fid.toArray(new ASTField[fid.size()]); MethodDeclaration[] methods = type.getMethods(); List<ASTMethod> mid = new ArrayList<>(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getReturnType2() == null) continue; - mid.add(new ASTMethod(this, source, methods[i])); + for (MethodDeclaration method : methods) { + if (method.getReturnType2() == null) continue; + mid.add(new ASTMethod(this, source, method)); } 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 1f490d200c..4427e75731 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 @@ public String getAccessor() { @Override public String getCast() { String cast = ((String)getParam("cast")).trim(); - if (cast.length() > 0) { + if (!cast.isEmpty()) { 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 a8cd8ce367..c251dc5745 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,8 +64,7 @@ public ASTMethod(ASTClass declaringClass, String source, MethodDeclaration metho paramTypes64 = new ASTType[parameters.size()]; this.parameters = new ASTParameter[paramTypes.length]; int i = 0; - for (Iterator<SingleVariableDeclaration> iterator = parameters.iterator(); iterator.hasNext(); i++) { - SingleVariableDeclaration param = iterator.next(); + for (SingleVariableDeclaration param : parameters) { paramTypes[i] = new ASTType(declaringClass.resolver, param.getType(), param.getExtraDimensions()); paramTypes64[i] = paramTypes[i]; this.parameters[i] = new ASTParameter(this, i, param.getName().getIdentifier()); @@ -116,8 +115,7 @@ public boolean isNativeUnique() { boolean result = true; String name = getName(); JNIMethod[] methods = declaringClass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - JNIMethod mth = methods[i]; + for (JNIMethod mth : methods) { 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 181d347b4d..bf40e0064d 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,8 +31,7 @@ public String flatten() { Set<String> set = params.keySet(); String[] keys = set.toArray(new String[set.size()]); Arrays.sort(keys); - for (int j = 0; j < keys.length; j++) { - String key = keys[j]; + for (String key : keys) { Object value = params.get(key); String valueStr = ""; if (value instanceof String) { @@ -77,8 +76,8 @@ public String[] getFlags() { @Override public boolean getFlag(String flag) { String[] flags = getFlags(); - for (int i = 0; i < flags.length; i++) { - if (flags[i].equals(flag)) return true; + for (String flag2 : flags) { + if (flag2.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 8f4cc1c977..fa768cdcf1 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,8 +99,7 @@ void loadDirectory(File file) { if (entries == null) { entries = new String[0]; } - for (int i = 0; i < entries.length; i++) { - String entry = entries[i]; + for (String entry : entries) { 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 69b58d0608..d0192c7b14 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, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,8 +40,7 @@ public void generate(JNIClass clazz) { public void generate(JNIField[] fields) { sort(fields); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { 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 db66465645..293f759c9f 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, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,8 +29,7 @@ public void generate(JNIClass clazz) { public void generate(JNIMethod[] methods) { sort(methods); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { 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 8bce4db357..385371f676 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, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2018 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.Modifier; +import java.lang.reflect.*; public class ConstantsGenerator extends JNIGenerator { @@ -23,8 +23,7 @@ public void generate(JNIClass clazz) { public void generate(JNIField[] fields) { sort(fields); outputln("int main() {"); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { if ((field.getModifiers() & Modifier.FINAL) == 0) continue; generate(field); } @@ -52,8 +51,7 @@ public static void main(String[] args) { } try { ConstantsGenerator gen = new ConstantsGenerator(); - for (int i = 0; i < args.length; i++) { - String clazzName = args[i]; + for (String clazzName : args) { 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 1c457c13ef..23694e775c 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,8 +49,7 @@ public void generate(JNIClass clazz) { } public void generate(JNIField[] fields) { - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { int mods = field.getModifiers(); if ((mods & Modifier.PUBLIC) == 0) continue; if ((mods & Modifier.FINAL) != 0) continue; @@ -70,8 +69,7 @@ public void generate(JNIField field) { } public void generate(JNIMethod[] methods) { - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { 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 110167a12d..83557aabbe 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,8 +131,7 @@ static String getFunctionName(JNIMethod method, JNIType[] paramTypes) { StringBuilder buffer = new StringBuilder(); buffer.append(function); buffer.append("__"); - for (int i = 0; i < paramTypes.length; i++) { - JNIType paramType = paramTypes[i]; + for (JNIType paramType : paramTypes) { buffer.append(toC(paramType.getTypeSignature(false))); } return buffer.toString(); @@ -217,8 +216,7 @@ public void generate() { generateAutoGenNote(); generateIncludes(); sort(classes); - for (int i = 0; i < classes.length; i++) { - JNIClass clazz = classes[i]; + for (JNIClass clazz : classes) { if (getGenerate(clazz)) generate(clazz); if (progress != null) progress.step(); } @@ -238,8 +236,7 @@ public JNIClass[] getClasses() { } public boolean getCPP() { - for (int i = 0; i < classes.length; i++) { - JNIClass clazz = classes[i]; + for (JNIClass clazz : classes) { if (clazz.getFlag(FLAG_CPP)) { return true; } @@ -272,8 +269,7 @@ public String getOutputName() { } public boolean getM() { - for (int i = 0; i < classes.length; i++) { - JNIClass clazz = classes[i]; + for (JNIClass clazz : classes) { 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 8a9ed8723d..6125715888 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, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,11 +226,9 @@ public void generate(ProgressMonitor progress) { this.progress = progress; if (progress != null) { int nativeCount = 0; - for (int i = 0; i < natives.length; i++) { - JNIClass clazz = natives[i]; + for (JNIClass clazz : natives) { JNIMethod[] methods = clazz.getDeclaredMethods(); - for (int j = 0; j < methods.length; j++) { - JNIMethod method = methods[j]; + for (JNIMethod method : methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; nativeCount++; } @@ -299,8 +297,7 @@ String[] getClassNames() { if(entries == null) { entries = new String[0]; } - for (int i = 0; i < entries.length; i++) { - String entry = entries[i]; + for (String entry : entries) { File f = new File(file, entry); if (!f.isDirectory()) { if (f.getAbsolutePath().endsWith(".class")) { @@ -354,8 +351,7 @@ JNIClass[] getASTClasses() { if (files == null) { files = new File[0]; } - for (int i = 0; i < files.length; i++) { - File file = files[i]; + for (File file : files) { try { String path = file.getAbsolutePath().replace('\\', '/'); if (path.endsWith(".java")) { @@ -381,11 +377,9 @@ JNIClass[] getASTClasses() { public JNIClass[] getNativesClasses(JNIClass[] classes) { if (mainClass == null) return new JNIClass[0]; List<JNIClass> result = new ArrayList<>(); - for (int i = 0; i < classes.length; i++) { - JNIClass clazz = classes[i]; + for (JNIClass clazz : classes) { JNIMethod[] methods = clazz.getDeclaredMethods(); - for (int j = 0; j < methods.length; j++) { - JNIMethod method = methods[j]; + for (JNIMethod method : methods) { int mods = method.getModifiers(); if ((mods & Modifier.NATIVE) != 0) { result.add(clazz); @@ -410,8 +404,7 @@ public JNIClass[] getStructureClasses(JNIClass[] classes) { } JNIField[] fields = clazz.getDeclaredFields(); boolean hasPublicFields = false; - for (int j = 0; j < fields.length; j++) { - JNIField field = fields[j]; + for (JNIField field : fields) { 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 7a0834b38b..21274bd229 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,8 +152,7 @@ void generateAll() { shell.setCursor(cursor); shell.setEnabled(false); Control[] children = actionsPanel.getChildren(); - for (int i = 0; i < children.length; i++) { - Control child = children[i]; + for (Control child : children) { if (child instanceof Button) child.setEnabled(false); } boolean showProgress = true; @@ -201,8 +200,7 @@ void generateAll() { while (!done[0]) { if (!display.readAndDispatch()) display.sleep(); } - for (int i = 0; i < children.length; i++) { - Control child = children[i]; + for (Control child : children) { if (child instanceof Button) child.setEnabled(true); } if (showProgress) { @@ -240,8 +238,7 @@ JNIMethod[] getSelectedMethods() { TableItem[] selection = membersLt.getSelection(); JNIMethod[] methods = new JNIMethod[selection.length]; int count = 0; - for (int i = 0; i < selection.length; i++) { - TableItem item = selection [i]; + for (TableItem item : selection) { Object data = item.getData(); if (data instanceof JNIMethod) { methods[count++] = (JNIMethod)data; @@ -259,8 +256,7 @@ JNIField[] getSelectedFields() { TableItem[] selection = membersLt.getSelection(); JNIField[] fields = new JNIField[selection.length]; int count = 0; - for (int i = 0; i < selection.length; i++) { - TableItem item = selection [i]; + for (TableItem item : selection) { Object data = item.getData(); if (data instanceof JNIField) { fields[count++] = (JNIField)data; @@ -915,8 +911,7 @@ String getClassString(JNIType type) { String getFlagsString(String[] flags) { if (flags.length == 0) return ""; StringBuilder buffer = new StringBuilder(); - for (int j = 0; j < flags.length; j++) { - String flag = flags[j]; + for (String flag : flags) { if (buffer.length() != 0) buffer.append(", "); buffer.append(flag); } @@ -958,8 +953,7 @@ void updateClasses() { item.setChecked(clazz.getGenerate()); } TableColumn[] columns = classesLt.getColumns(); - for (int i = 0; i < columns.length; i++) { - TableColumn column = columns[i]; + for (TableColumn column : columns) { column.pack(); } classesLt.setSelection(mainIndex); @@ -969,8 +963,7 @@ void updateMembers() { membersLt.removeAll(); membersLt.setHeaderVisible(false); TableColumn[] columns = membersLt.getColumns(); - for (int i = 0; i < columns.length; i++) { - TableColumn column = columns[i]; + for (TableColumn column : columns) { column.dispose(); } int[] indices = classesLt.getSelectionIndices(); @@ -979,8 +972,7 @@ void updateMembers() { JNIClass clazz = (JNIClass)classItem.getData(); boolean hasNatives = false; JNIMethod[] methods = clazz.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { int mods = method.getModifiers(); if (hasNatives =((mods & Modifier.NATIVE) != 0)) break; } @@ -998,8 +990,7 @@ void updateMembers() { column.setText("Exclude"); */ JNIGenerator.sort(methods); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; TableItem item = new TableItem(membersLt, SWT.NONE); item.setData(method); @@ -1026,8 +1017,7 @@ void updateMembers() { column.setText("Exclude"); */ JNIField[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { int mods = field.getModifiers(); if (((mods & Modifier.PUBLIC) == 0) || ((mods & Modifier.FINAL) != 0) || @@ -1045,8 +1035,7 @@ void updateMembers() { } } columns = membersLt.getColumns(); - for (int i = 0; i < columns.length; i++) { - TableColumn column = columns[i]; + for (TableColumn column : columns) { column.pack(); } membersLt.setHeaderVisible(true); @@ -1076,8 +1065,7 @@ void updateParameters() { item.setText(PARAM_FLAGS_COLUMN, getFlagsString(param.getFlags())); } TableColumn[] columns = paramsLt.getColumns(); - for (int i = 0; i < columns.length; i++) { - TableColumn column = columns[i]; + for (TableColumn column : columns) { 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 44f58a34d1..284516f41c 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, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,8 +33,7 @@ public void generate(JNIClass clazz) { } public void generate(JNIField[] fields) { - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { int mods = field.getModifiers(); if ((mods & Modifier.PUBLIC) == 0) continue; if ((mods & Modifier.FINAL) != 0) continue; @@ -54,8 +53,7 @@ public void generate(JNIField field) { public void generate(JNIMethod[] methods) { sort(methods); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { 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 f4ae947c36..c8583e58b5 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, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,8 +72,7 @@ public void generate(JNIClass clazz) { public void generate(JNIMethod[] methods) { sort(methods); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); if (progress != null) progress.step(); @@ -223,8 +222,7 @@ public void setEnterExitMacro(boolean enterExitMacro) { void generateExcludes(JNIMethod[] methods) { HashSet<String> excludes = new HashSet<>(); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String exclude = method.getExclude(); if (exclude.length() != 0) { @@ -233,8 +231,7 @@ void generateExcludes(JNIMethod[] methods) { } for (String exclude: excludes) { outputln(exclude); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String methodExclude = method.getExclude(); if (exclude.equals(methodExclude)) { @@ -523,8 +520,7 @@ boolean generateLocalVars(JNIParameter[] params, JNIType returnType, JNIType ret boolean generateGetters(JNIMethod method, JNIParameter[] params) { boolean genFailTag = false; int criticalCount = 0; - for (int i = 0; i < params.length; i++) { - JNIParameter param = params[i]; + for (JNIParameter param : params) { if (!isCritical(param)) { genFailTag |= generateGetParameter(method, param, false, 1); } else { @@ -532,8 +528,7 @@ boolean generateGetters(JNIMethod method, JNIParameter[] params) { } } if (criticalCount != 0) { - for (int i = 0; i < params.length; i++) { - JNIParameter param = params[i]; + for (JNIParameter param : params) { 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 6cc20a87f1..da668963e0 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 @@ public String getAccessor() { @Override public String getCast() { String cast = ((String)getParam("cast")).trim(); - if (cast.length() > 0) { + if (!cast.isEmpty()) { 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 aef0caf4c9..e8a68ed299 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, 2015 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,8 +128,7 @@ public boolean isNativeUnique() { boolean result = true; String name = getName(); JNIMethod[] methods = declaringClass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - JNIMethod mth = methods[i]; + for (JNIMethod mth : methods) { 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 872a31c0c9..a56ea3f517 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, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2018 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.Modifier; +import java.lang.reflect.*; public class SizeofGenerator extends JNIGenerator { @@ -36,8 +36,7 @@ public void generate() { public void generate(JNIField[] fields) { sort(fields); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { if ((field.getModifiers() & Modifier.FINAL) == 0) continue; generate(field); } @@ -58,8 +57,7 @@ public static void main(String[] args) { } try { SizeofGenerator gen = new SizeofGenerator(); - for (int i = 0; i < args.length; i++) { - String clazzName = args[i]; + for (String clazzName : args) { 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 f6d766bb49..8ccab69987 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, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2018 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.Modifier; +import java.lang.reflect.*; public class StatsGenerator extends JNIGenerator { @@ -110,8 +110,7 @@ void generateSourceFile(JNIClass clazz) { output(className); outputln("_nativeFunctionNames[] = {"); sort(methods); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String function = getFunctionName(method), function64 = getFunctionName(method, method.getParameterTypes64()); if (!function.equals(function64)) { @@ -193,8 +192,7 @@ void generateStatsNatives(String className) { void generateFunctionEnum(JNIMethod[] methods) { if (methods.length == 0) return; outputln("typedef enum {"); - for (int i = 0; i < methods.length; i++) { - JNIMethod method = methods[i]; + for (JNIMethod method : methods) { 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 bc8d30c6cd..f58d9c9e77 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, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 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,8 +80,7 @@ public String getSuffix() { void generateExcludes(JNIClass[] classes) { HashSet<String> excludes = new HashSet<>(); - for (int i = 0; i < classes.length; i++) { - JNIClass clazz = classes[i]; + for (JNIClass clazz : classes) { String exclude = clazz.getExclude(); if (exclude.length() != 0) { excludes.add(exclude); @@ -89,8 +88,7 @@ void generateExcludes(JNIClass[] classes) { } for (String exclude : excludes) { outputln(exclude); - for (int i = 0; i < classes.length; i++) { - JNIClass clazz = classes[i]; + for (JNIClass clazz : classes) { String classExclude = clazz.getExclude(); if (exclude.equals(classExclude)) { output("#define NO_"); @@ -201,8 +199,7 @@ void generateFIDsStructure(JNIClass clazz) { output("\tjfieldID "); JNIField[] fields = clazz.getDeclaredFields(); boolean first = true; - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { if (ignoreField(field)) continue; if (!first) output(", "); output(field.getName()); @@ -248,8 +245,7 @@ void generateCacheFunction(JNIClass clazz) { } outputln(); JNIField[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { if (ignoreField(field)) continue; output("\t"); output(clazzName); @@ -293,8 +289,7 @@ void generateGetFields(JNIClass clazz) { } } JNIField[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { if (ignoreField(field)) continue; String exclude = field.getExclude(); if (exclude.length() != 0) { @@ -447,8 +442,7 @@ void generateSetFields(JNIClass clazz) { } } JNIField[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - JNIField field = fields[i]; + for (JNIField field : fields) { if (ignoreField(field)) continue; String exclude = field.getExclude(); if (exclude.length() != 0) { |