diff options
author | Alexander Kurtakov | 2017-09-26 07:41:04 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-09-26 08:34:57 +0000 |
commit | 3f6fa366346517ddca5065507880255ee8d18641 (patch) | |
tree | 1e6b5cab997947b05bde59574729c5b3a7a553be /bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse | |
parent | 98cc2037bf4a49c605fa52ba45969c0dcd51ddbc (diff) | |
download | eclipse.platform.swt-3f6fa366346517ddca5065507880255ee8d18641.tar.gz eclipse.platform.swt-3f6fa366346517ddca5065507880255ee8d18641.tar.xz eclipse.platform.swt-3f6fa366346517ddca5065507880255ee8d18641.zip |
Bug 524932 - Stricter warnings for swt tools
Enable more warnings and fix them.
Change-Id: I2f201327e6cd9176f1447f69857d8e8afd753352
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse')
6 files changed, 32 insertions, 33 deletions
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 cf73b9c395..ed06304974 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 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 @@ -93,9 +93,8 @@ public static String getDelimiter(String fileName) { int c1 = is.read(); if (c1 == '\n') { return "\r\n"; - } else { - return "\r"; } + return "\r"; } } } catch (IOException e) { 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 125d64ac2c..136805fb66 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, 2015 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 @@ -259,14 +259,14 @@ public void generate(ProgressMonitor progress) { this.progress = null; } -String getPackageName(String className) { +String getPackageName() { int dot = mainClassName.lastIndexOf('.'); if (dot == -1) return ""; return mainClassName.substring(0, dot); } -String[] getClassNames(String mainClassName) { - String pkgName = getPackageName(mainClassName); +String[] getClassNames() { + String pkgName = getPackageName(); String classpath = getClasspath(); if (classpath == null) classpath = System.getProperty("java.class.path"); String pkgPath = pkgName.replace('.', File.separatorChar); @@ -317,9 +317,9 @@ public JNIClass[] getClasses() { if (classes != null) return classes; if (mainClassName == null) return new JNIClass[0]; if (USE_AST) return getASTClasses(); - String[] classNames = getClassNames(mainClassName); + String[] classNames = getClassNames(); Arrays.sort(classNames); - String packageName = getPackageName(mainClassName); + String packageName = getPackageName(); JNIClass[] classes = new JNIClass[classNames.length]; for (int i = 0; i < classNames.length; i++) { String className = classNames[i]; @@ -345,7 +345,7 @@ JNIClass[] getASTClasses() { String root = classesDir != null ? classesDir : new File(outputDir).getParent() + "/"; String mainPath = new File(root + mainClassName.replace('.', '/') + ".java").getAbsolutePath(); List<JNIClass> classes = new ArrayList<>(); - String packageName = getPackageName(mainClassName); + String packageName = getPackageName(); File dir = new File(root + "/" + packageName.replace('.', '/')); File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { 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 5a0f9cd0ff..521c6563a9 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 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 @@ -899,7 +899,7 @@ public void run() { cleanup(); } -String getPackageString(String className) { +String getPackageString() { int dot = app.getMainClassName().lastIndexOf('.'); if (dot == -1) return ""; return app.getMainClassName().substring(0, dot); @@ -924,7 +924,7 @@ String getFlagsString(String[] flags) { } String getMethodString(JNIMethod method) { - String pkgName = getPackageString(method.getDeclaringClass().getName()); + String pkgName = getPackageString(); StringBuffer buffer = new StringBuffer(); buffer.append(method.getName()); buffer.append("("); 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 5827c693b2..2243fd9c89 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, 2013 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.swt.tools.internal; -import java.lang.reflect.Modifier; +import java.lang.reflect.*; public class MetaDataGenerator extends JNIGenerator { @@ -102,7 +102,7 @@ public String getOutputName() { return getMainClass().getName(); } -protected boolean getGenerate(JNIClass clazz) { +protected boolean getGenerate() { return true; } 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 8cd0a747a7..f4ae947c36 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 @@ -92,7 +92,7 @@ boolean isFloatingPoint(String type) { return type.equals("float") || type.equals("double"); } -void generateCallback(JNIMethod method, String function, JNIParameter[] params, JNIType returnType) { +void generateCallback(JNIMethod method, String function) { output("static jintLong "); output(function); outputln(";"); @@ -197,7 +197,7 @@ public void generate(JNIMethod method) { outputln(";"); } if (function.startsWith("CALLBACK_")) { - generateCallback(method, function, params, returnType); + generateCallback(method, function); } generateFunctionPrototype(method, function, params, returnType, returnType64, !sameFunction); if (!function.equals(function64)) { @@ -213,7 +213,7 @@ public void generate(JNIMethod method) { outputln("#endif"); } generateFunctionBody(method, function, function64, params, returnType, returnType64); - generateSourceEnd(function); + generateSourceEnd(); outputln(); } @@ -474,7 +474,7 @@ void generateEnterExitMacro(JNIMethod method, String function, String function64 } } -boolean generateLocalVars(JNIMethod method, JNIParameter[] params, JNIType returnType, JNIType returnType64) { +boolean generateLocalVars(JNIParameter[] params, JNIType returnType, JNIType returnType64) { boolean needsReturn = enterExitMacro; for (int i = 0; i < params.length; i++) { JNIParameter param = params[i]; @@ -542,7 +542,7 @@ boolean generateGetters(JNIMethod method, JNIParameter[] params) { return genFailTag; } -void generateSetters(JNIMethod method, JNIParameter[] params) { +void generateSetters(JNIParameter[] params) { int criticalCount = 0; for (int i = params.length - 1; i >= 0; i--) { JNIParameter param = params[i]; @@ -856,18 +856,18 @@ void generateFunctionCall(JNIMethod method, JNIParameter[] params, JNIType retur } if (objc_struct) { outputln("\t} else if (sizeof(_arg0) > STRUCT_SIZE_LIMIT) {"); - generate_objc_msgSend_stret (method, params, name); + generate_objc_msgSend_stret (params, name); generateFunctionCallRightSide(method, params, 1); outputln(";"); outputln("\t} else {"); - generate_objc_msgSend_stret (method, params, name.substring(0, name.length() - "_stret".length())); + generate_objc_msgSend_stret (params, name.substring(0, name.length() - "_stret".length())); generateFunctionCallRightSide(method, params, 1); outputln(";"); outputln("\t}"); } } -void generate_objc_msgSend_stret (JNIMethod method, JNIParameter[] params, String func) { +void generate_objc_msgSend_stret (JNIParameter[] params, String func) { output("\t\t*lparg0 = (*("); JNIType paramType = params[0].getType(), paramType64 = params[0].getType64(); output(paramType.getTypeSignature4(!paramType.equals(paramType64), true)); @@ -895,7 +895,7 @@ void generate_objc_msgSend_stret (JNIMethod method, JNIParameter[] params, Strin output(")"); } -void generateReturn(JNIMethod method, JNIType returnType, boolean needsReturn) { +void generateReturn(JNIType returnType, boolean needsReturn) { if (needsReturn && !returnType.isType("void")) { outputln("\treturn rc;"); } @@ -925,7 +925,7 @@ void generateFunctionBody(JNIMethod method, String function, String function64, if (isMemove) { generateMemmove(method, function, function64, params); } else { - boolean needsReturn = generateLocalVars(method, params, returnType, returnType64); + boolean needsReturn = generateLocalVars(params, returnType, returnType64); generateEnterExitMacro(method, function, function64, true); boolean genFailTag = generateGetters(method, params); if (method.getFlag(FLAG_DYNAMIC)) { @@ -934,9 +934,9 @@ void generateFunctionBody(JNIMethod method, String function, String function64, generateFunctionCall(method, params, returnType, returnType64, needsReturn); } if (genFailTag) outputln("fail:"); - generateSetters(method, params); + generateSetters(params); generateEnterExitMacro(method, function, function64, false); - generateReturn(method, returnType, needsReturn); + generateReturn(returnType, needsReturn); } outputln("}"); @@ -989,7 +989,7 @@ void generateSourceStart(String function, String function64) { } } -void generateSourceEnd(String function) { +void generateSourceEnd() { outputln("#endif"); } 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 2ec64f7952..462fb9f0be 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, 2015 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 @@ -107,7 +107,7 @@ void generateHeaderFile(JNIClass clazz) { generateSourceStart(clazz); generatePrototypes(clazz); generateBlankMacros(clazz); - generateSourceEnd(clazz); + generateSourceEnd(); outputln(); } @@ -118,7 +118,7 @@ void generateSourceFile(JNIClass clazz) { generateGlobalVar(clazz); outputln(); generateFunctions(clazz); - generateSourceEnd(clazz); + generateSourceEnd(); outputln(); } @@ -128,7 +128,7 @@ void generateSourceStart(JNIClass clazz) { outputln(clazzName); } -void generateSourceEnd(JNIClass clazz) { +void generateSourceEnd() { outputln("#endif"); } |