tcl.validators: Move to Java 8.
Adapt codebase to new constructs.
Change-Id: I637c600494ed0914f10bc9db8f336617b136ba97
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/.classpath b/tcl/plugins/org.eclipse.dltk.tcl.validators/.classpath
index 64c5e31..eca7bdb 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/.classpath
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/.settings/org.eclipse.jdt.core.prefs b/tcl/plugins/org.eclipse.dltk.tcl.validators/.settings/org.eclipse.jdt.core.prefs
index ea19265..d00ac10 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/.settings/org.eclipse.jdt.core.prefs
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/.settings/org.eclipse.jdt.core.prefs
@@ -10,9 +10,9 @@
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -106,7 +106,7 @@
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
@@ -185,9 +185,12 @@
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/META-INF/MANIFEST.MF b/tcl/plugins/org.eclipse.dltk.tcl.validators/META-INF/MANIFEST.MF
index eb56422..a90a3c0 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/META-INF/MANIFEST.MF
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/META-INF/MANIFEST.MF
@@ -13,7 +13,7 @@
org.eclipse.dltk.launching;bundle-version="0.0.0",
org.eclipse.core.resources,
org.eclipse.emf.ecore
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-LazyStart: true
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.dltk.tcl.internal.validators,
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/ChecksExtensionManager.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/ChecksExtensionManager.java
index 4138849..af93f32 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/ChecksExtensionManager.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/ChecksExtensionManager.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2017 xored software, Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Andrei Sobolev)
@@ -33,7 +33,7 @@
private static final String EXTENSION_ID = TclValidatorsCore.PLUGIN_ID
+ ".tclCheck";
private static ChecksExtensionManager sInstance;
- private List<TclCheckInfo> checks = new ArrayList<TclCheckInfo>();
+ private List<TclCheckInfo> checks = new ArrayList<>();
private boolean initialized = false;
public static class TclCheckInfo {
@@ -82,8 +82,8 @@
}
initialized = true;
IConfigurationElement[] configurationElements = Platform
- .getExtensionRegistry().getConfigurationElementsFor(
- EXTENSION_ID);
+ .getExtensionRegistry()
+ .getConfigurationElementsFor(EXTENSION_ID);
for (IConfigurationElement config : configurationElements) {
try {
String id = config.getAttribute(ID_ATTR);
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/TclCheckBuildParticipant.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/TclCheckBuildParticipant.java
index caf3579..0fa0c15 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/TclCheckBuildParticipant.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/TclCheckBuildParticipant.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2017 xored software, Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Andrei Sobolev)
@@ -40,6 +40,7 @@
public TclCheckBuildParticipant(IScriptProject project) {
}
+ @Override
public void build(IBuildContext context) throws CoreException {
try {
if (!TESTING_DO_OPERATIONS) {
@@ -61,8 +62,8 @@
IScriptProject scriptProject = module
.getScriptProject();
check.checkCommands(commands, errorCollector,
- preferences.getOptions(info),
- scriptProject, lineTracker);
+ preferences.getOptions(info), scriptProject,
+ lineTracker);
}
}
}
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/ArgumentsDefinitionCheck.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/ArgumentsDefinitionCheck.java
index 359f91e..85edd2f 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/ArgumentsDefinitionCheck.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/ArgumentsDefinitionCheck.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2017 xored software, Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Andrei Sobolev)
@@ -34,6 +34,7 @@
// TODO Auto-generated constructor stub
}
+ @Override
public void checkCommands(List<TclCommand> commands,
final ITclErrorReporter reporter, Map<String, String> options,
IScriptProject project, ISourceLineTracker sourceLineTracker) {
@@ -70,18 +71,18 @@
ArgumentDefinition definition = list.get(i);
if (definition.getName() == null) {
reporter.report(ICheckKinds.CHECK_BAD_ARG_DEFINITION,
- "Bad argument definition", null, definition
- .getArgument().getStart(), definition
- .getArgument().getEnd(),
+ "Bad argument definition", null,
+ definition.getArgument().getStart(),
+ definition.getArgument().getEnd(),
ITclErrorReporter.WARNING);
} else {
for (int j = 0; j < i; j++) {
ArgumentDefinition other = list.get(j);
if (definition.getName().equals(other.getName()))
- reporter.report(
- ICheckKinds.CHECK_SAME_ARG_NAME,
+ reporter.report(ICheckKinds.CHECK_SAME_ARG_NAME,
"Argument with the same name "
- + "has been declared", null,
+ + "has been declared",
+ null,
definition.getArgument().getStart(),
definition.getArgument().getEnd(),
ITclErrorReporter.WARNING);
@@ -91,14 +92,11 @@
wasArgs = true;
if (definition.isDefaulted()
&& !definition.isDefaultEmtpy()) {
- reporter
- .report(
- ICheckKinds.CHECK_ARGS_DEFAULT,
- "\"args\" cannot be defaulted. Default value is ignored.",
- null, definition.getArgument()
- .getStart(), definition
- .getArgument().getEnd(),
- ITclErrorReporter.WARNING);
+ reporter.report(ICheckKinds.CHECK_ARGS_DEFAULT,
+ "\"args\" cannot be defaulted. Default value is ignored.",
+ null, definition.getArgument().getStart(),
+ definition.getArgument().getEnd(),
+ ITclErrorReporter.WARNING);
}
} else {
if (wasArgs) {
@@ -111,8 +109,7 @@
if (definition.isDefaulted()) {
wasDef = true;
} else if (wasDef) {
- reporter.report(
- ICheckKinds.CHECK_NON_DEF_AFTER_DEF,
+ reporter.report(ICheckKinds.CHECK_NON_DEF_AFTER_DEF,
"Non-default arg specified after default",
null, definition.getArgument().getStart(),
definition.getArgument().getEnd(),
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/CommandRedefinitionCheck.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/CommandRedefinitionCheck.java
index b6e8863..865bb56 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/CommandRedefinitionCheck.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/CommandRedefinitionCheck.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2017 xored software, Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Andrei Sobolev)
@@ -37,13 +37,15 @@
public CommandRedefinitionCheck() {
}
+ @Override
public void checkCommands(final List<TclCommand> tclCommands,
final ITclErrorReporter reporter, Map<String, String> options,
- IScriptProject project, final ISourceLineTracker sourceLineTracker) {
+ IScriptProject project,
+ final ISourceLineTracker sourceLineTracker) {
final IScopeProcessor processor = DefinitionManager.getInstance()
.createProcessor();
TclParserUtils.traverse(tclCommands, new TclVisitor() {
- Map<String, Integer> userCommands = new HashMap<String, Integer>();
+ Map<String, Integer> userCommands = new HashMap<>();
@Override
public boolean visit(TclCommand tclCommand) {
@@ -69,16 +71,15 @@
reporter.report(
ICheckKinds.BUILTIN_COMMAND_REDEFINITION,
"Built-in command redefinition", null,
- nameArgument.getStart(), nameArgument
- .getEnd(),
+ nameArgument.getStart(),
+ nameArgument.getEnd(),
ITclErrorReporter.WARNING);
Set<String> names = userCommands.keySet();
for (String name : names) {
if (name.equals(current)) {
- final String msg = NLS
- .bind(
- "Procedure {0} is already defined on line {1}",
- name, userCommands.get(name));
+ final String msg = NLS.bind(
+ "Procedure {0} is already defined on line {1}",
+ name, userCommands.get(name));
reporter.report(
ICheckKinds.USER_COMMAND_REDEFINITION,
msg, null, nameArgument.getStart(),
@@ -87,8 +88,8 @@
}
}
int start = tclCommand.getStart();
- userCommands.put(current, sourceLineTracker
- .getLineNumberOfOffset(start));
+ userCommands.put(current,
+ sourceLineTracker.getLineNumberOfOffset(start));
}
}
return true;
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedProcCheck.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedProcCheck.java
index fd2aa39..d3db740 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedProcCheck.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedProcCheck.java
@@ -36,6 +36,7 @@
public UndefinedProcCheck() {
}
+ @Override
public void checkCommands(List<TclCommand> commands,
final ITclErrorReporter reporter, Map<String, String> options,
final IScriptProject project,
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedVariableCheck.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedVariableCheck.java
index 2f983a6..46a1420 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedVariableCheck.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UndefinedVariableCheck.java
@@ -35,6 +35,7 @@
public UndefinedVariableCheck() {
}
+ @Override
public void checkCommands(List<TclCommand> commands,
final ITclErrorReporter reporter, Map<String, String> options,
final IScriptProject project,
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UnreachableCodeCheck.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UnreachableCodeCheck.java
index f930df7..90765c9 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UnreachableCodeCheck.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/checks/UnreachableCodeCheck.java
@@ -32,6 +32,7 @@
public UnreachableCodeCheck() {
}
+ @Override
public void checkCommands(final List<TclCommand> tclCommands,
final ITclErrorReporter reporter, Map<String, String> options,
IScriptProject project, ISourceLineTracker sourceLineTracker) {
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/packages/PackageRequireSourceAnalyser.java b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/packages/PackageRequireSourceAnalyser.java
index f80162e..f9b8823 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/packages/PackageRequireSourceAnalyser.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.validators/src/org/eclipse/dltk/tcl/internal/validators/packages/PackageRequireSourceAnalyser.java
@@ -81,7 +81,7 @@
private final PackageSourceCollector packageCollector = new PackageSourceCollector();
- private final List<ModuleInfo> modules = new ArrayList<ModuleInfo>();
+ private final List<ModuleInfo> modules = new ArrayList<>();
private static class ModuleInfo {
final String name;
@@ -134,12 +134,13 @@
private int buildType;
private boolean autoAddPackages;
- private Set<TclModuleInfo> providedByRequiredProjects = new HashSet<TclModuleInfo>();
+ private Set<TclModuleInfo> providedByRequiredProjects = new HashSet<>();
+ @Override
public boolean beginBuild(int buildType) {
this.buildType = buildType;
this.autoAddPackages = ScriptProjectUtil.isBuilderEnabled(project);
- List<TclModuleInfo> moduleInfos = new ArrayList<TclModuleInfo>();
+ List<TclModuleInfo> moduleInfos = new ArrayList<>();
moduleInfos.addAll(
TclPackagesManager.getProjectModules(project.getElementName()));
if (buildType == IBuildParticipantExtension.FULL_BUILD) {
@@ -183,6 +184,7 @@
private List<TclPackageInfo> knownInfos;
+ @Override
public void buildExternalModule(IBuildContext context)
throws CoreException {
ISourceModule module = context.getSourceModule();
@@ -196,6 +198,7 @@
addInfoForModule(context, module, null);
}
+ @Override
public void build(IBuildContext context) throws CoreException {
ISourceModule module = context.getSourceModule();
TclModule tclModule = TclBuildContext.getStatements(context);
@@ -251,15 +254,16 @@
return modulePath;
}
+ @Override
public void endBuild(IProgressMonitor monitor) {
monitor.subTask(Messages.TclCheckBuilder_retrievePackages);
// initialize manager caches after they are collected
- final Set<String> names = new HashSet<String>();
- final Set<String> autoNames = new HashSet<String>();
+ final Set<String> names = new HashSet<>();
+ final Set<String> autoNames = new HashSet<>();
InterpreterContainerHelper.getInterpreterContainerDependencies(project,
names, autoNames);
// process all modules
- final Set<String> newDependencies = new HashSet<String>();
+ final Set<String> newDependencies = new HashSet<>();
int remainingWork = modules.size();
IEnvironment environment = EnvironmentManager
.getEnvironment(this.project);
@@ -271,7 +275,7 @@
// Check for user override for selected source value
EList<UserCorrection> corrections = moduleInfo.moduleInfo
.getPackageCorrections();
- List<TclSourceEntry> toCheck = new ArrayList<TclSourceEntry>();
+ List<TclSourceEntry> toCheck = new ArrayList<>();
for (UserCorrection userCorrection : corrections) {
if (userCorrection.getOriginalValue()
@@ -321,7 +325,7 @@
// Check for user override for selected source value
EList<UserCorrection> corrections = moduleInfo
.getPackageCorrections();
- List<TclSourceEntry> toCheck = new ArrayList<TclSourceEntry>();
+ List<TclSourceEntry> toCheck = new ArrayList<>();
for (UserCorrection userCorrection : corrections) {
if (userCorrection.getOriginalValue()
@@ -372,7 +376,7 @@
if (buildType != IBuildParticipantExtension.RECONCILE_BUILD) {
List<TclModuleInfo> mods = packageCollector.getModules()
.get(project);
- List<TclModuleInfo> result = new ArrayList<TclModuleInfo>();
+ List<TclModuleInfo> result = new ArrayList<>();
// Clean modules without required items
for (TclModuleInfo tclModuleInfo : mods) {
// Clean old corrections.
@@ -414,7 +418,7 @@
private void cleanCorrections(EList<UserCorrection> corrections,
EList<TclSourceEntry> entries) {
- final Set<String> values = new HashSet<String>();
+ final Set<String> values = new HashSet<>();
for (TclSourceEntry tclSourceEntry : entries) {
values.add(tclSourceEntry.getValue());
}
@@ -438,7 +442,7 @@
// Convert path to real path.
for (TclSourceEntry source : moduleInfo.moduleInfo.getSourced()) {
final String value = source.getValue();
- final Set<IPath> sourcedPaths = new HashSet<IPath>();
+ final Set<IPath> sourcedPaths = new HashSet<>();
for (Iterator<UserCorrection> i = corrections.iterator(); i
.hasNext();) {
final UserCorrection userCorrection = i.next();
@@ -704,12 +708,14 @@
return autoAddPackages;
}
+ @Override
public void prepare(IBuildChange buildChange, IBuildState buildState) {
}
/**
* @since 2.0
*/
+ @Override
public void clean() {
TclPackagesManager.setProjectModules(project.getElementName(),
Collections.<TclModuleInfo> emptyList());