tcl.launching: Move to Java 8. Enable more warnings, fix them and enable save actions. Change-Id: Ia527657c584e1b303f228553f3fa74328de5a0df Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/.classpath b/tcl/plugins/org.eclipse.dltk.tcl.launching/.classpath index 64c5e31..eca7bdb 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/.classpath +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/.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.launching/.settings/org.eclipse.jdt.core.prefs b/tcl/plugins/org.eclipse.dltk.tcl.launching/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..2053e50 --- /dev/null +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,104 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +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.8
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/.settings/org.eclipse.jdt.ui.prefs b/tcl/plugins/org.eclipse.dltk.tcl.launching/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..fbac55c --- /dev/null +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,59 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=true +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/META-INF/MANIFEST.MF b/tcl/plugins/org.eclipse.dltk.tcl.launching/META-INF/MANIFEST.MF index 0d0492d..3e57ecb 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/META-INF/MANIFEST.MF +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/META-INF/MANIFEST.MF
@@ -14,8 +14,8 @@ org.eclipse.dltk.console;bundle-version="0.0.0", org.eclipse.dltk.tcl.debug;bundle-version="0.0.0", org.eclipse.dltk.debug;bundle-version="0.0.0" -Eclipse-LazyStart: true +Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.dltk.tcl.console, org.eclipse.dltk.tcl.internal.launching, org.eclipse.dltk.tcl.launching -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclConsoleUtil.java b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclConsoleUtil.java index acee81c..5cc28f2 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclConsoleUtil.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclConsoleUtil.java
@@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 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 * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.tcl.console; @@ -31,15 +30,12 @@ import org.eclipse.dltk.tcl.launching.TclLaunchingPlugin; public class TclConsoleUtil { - public static ILaunch runDefaultTclInterpreter(TclInterpreter interpreter) - throws CoreException, IOException { - final ConsoleDeployment deployment = deployConsoleScript(EnvironmentManager - .getLocalEnvironment()); + public static ILaunch runDefaultTclInterpreter(TclInterpreter interpreter) throws CoreException, IOException { + final ConsoleDeployment deployment = deployConsoleScript(EnvironmentManager.getLocalEnvironment()); if (deployment == null) { return null; } - final ILaunch launch = ScriptLaunchUtil.runScript(TclNature.NATURE_ID, - deployment.scriptFile, null, null, + final ILaunch launch = ScriptLaunchUtil.runScript(TclNature.NATURE_ID, deployment.scriptFile, null, null, constructConsoleArgs(interpreter), null); registerForCleanup(launch, deployment, interpreter); return launch; @@ -48,15 +44,13 @@ /** * @since 1.1 */ - public static ILaunch runTclInterpreter(IInterpreterInstall install, - TclInterpreter interpreter) throws CoreException, IOException { - final ConsoleDeployment deployment = deployConsoleScript(install - .getEnvironment()); + public static ILaunch runTclInterpreter(IInterpreterInstall install, TclInterpreter interpreter) + throws CoreException, IOException { + final ConsoleDeployment deployment = deployConsoleScript(install.getEnvironment()); if (deployment == null) { return null; } - final ILaunch launch = ScriptLaunchUtil.runScript(install, - deployment.scriptFile, null, null, + final ILaunch launch = ScriptLaunchUtil.runScript(install, deployment.scriptFile, null, null, constructConsoleArgs(interpreter), null); registerForCleanup(launch, deployment, interpreter); return launch; @@ -73,45 +67,38 @@ } - private static ConsoleDeployment deployConsoleScript( - IEnvironment environment) throws IOException { - final IExecutionEnvironment exeEnv = (IExecutionEnvironment) environment - .getAdapter(IExecutionEnvironment.class); + private static ConsoleDeployment deployConsoleScript(IEnvironment environment) throws IOException { + final IExecutionEnvironment exeEnv = environment.getAdapter(IExecutionEnvironment.class); final IDeployment deployment = exeEnv.createDeployment(); if (deployment == null) { return null; } - final IPath path = deployment - .add(TclLaunchingPlugin.getDefault().getBundle(), - TclLaunchingPlugin.getDefault().getConsoleProxy()); + final IPath path = deployment.add(TclLaunchingPlugin.getDefault().getBundle(), + TclLaunchingPlugin.getDefault().getConsoleProxy()); return new ConsoleDeployment(deployment, deployment.getFile(path)); } private static String[] constructConsoleArgs(TclInterpreter interpreter) { ScriptConsoleServer server = ScriptConsoleServer.getInstance(); - return new String[] { DLTKDebugPlugin.getDefault().getBindAddress(), - Integer.toString(server.getPort()), + return new String[] { DLTKDebugPlugin.getDefault().getBindAddress(), Integer.toString(server.getPort()), server.register(interpreter) }; } - private static void registerForCleanup(final ILaunch launch, - final ConsoleDeployment deployment, TclInterpreter interpreter) { + private static void registerForCleanup(final ILaunch launch, final ConsoleDeployment deployment, + TclInterpreter interpreter) { if (launch == null) { return; } - DeploymentManager.getInstance().addDeployment(launch, - deployment.deployment); - interpreter.addCloseOperation(new Runnable() { - public void run() { - IProcess[] processes = launch.getProcesses(); - if (processes != null) { - for (int i = 0; i < processes.length; i++) { - try { - processes[i].terminate(); - } catch (DebugException e) { - if (DLTKCore.DEBUG) { - e.printStackTrace(); - } + DeploymentManager.getInstance().addDeployment(launch, deployment.deployment); + interpreter.addCloseOperation(() -> { + IProcess[] processes = launch.getProcesses(); + if (processes != null) { + for (int i = 0; i < processes.length; i++) { + try { + processes[i].terminate(); + } catch (DebugException e) { + if (DLTKCore.DEBUG) { + e.printStackTrace(); } } }
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclInterpreter.java b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclInterpreter.java index 29f8a28..d718b5d 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclInterpreter.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/console/TclInterpreter.java
@@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 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 * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.tcl.console; @@ -18,15 +17,14 @@ import org.eclipse.dltk.compiler.CharOperation; import org.eclipse.dltk.compiler.util.Util; -import org.eclipse.dltk.console.ConsoleRequest; -import org.eclipse.dltk.console.IScriptExecResult; import org.eclipse.dltk.console.IScriptConsoleIO; +import org.eclipse.dltk.console.IScriptExecResult; import org.eclipse.dltk.console.IScriptInterpreter; import org.eclipse.dltk.console.InterpreterResponse; import org.eclipse.dltk.console.ScriptExecResult; import org.eclipse.dltk.console.ShellResponse; -public class TclInterpreter implements IScriptInterpreter, ConsoleRequest { +public class TclInterpreter implements IScriptInterpreter { private static final String COMPLETE_COMMAND = "complete"; //$NON-NLS-1$ @@ -38,33 +36,35 @@ private int state; - private List closeRunnables = new ArrayList(); + private List<Runnable> closeRunnables = new ArrayList<>(); - private List initialListeners = new ArrayList(); + private List<Runnable> initialListeners = new ArrayList<>(); // IScriptInterpreter + @Override public IScriptExecResult exec(String command) throws IOException { InterpreterResponse response = protocol.execInterpreter(command); if (response != null) { state = response.getState(); - return new ScriptExecResult(response.getContent(), response - .isError()); + return new ScriptExecResult(response.getContent(), response.isError()); } else { return null; } } + @Override public boolean isValid() { return protocol != null; } + @Override public int getState() { return state; } // IScriptInterpreterShell - public List getCompletions(String commandLine, int position) - throws IOException { + @Override + public List getCompletions(String commandLine, int position) throws IOException { String[] args = new String[] { commandLine, Integer.toString(position) }; @@ -73,8 +73,8 @@ return response.getCompletions(); } - public String getDescription(String commandLine, int position) - throws IOException { + @Override + public String getDescription(String commandLine, int position) throws IOException { String[] args = new String[] { commandLine, Integer.toString(position) }; ShellResponse response = protocol.execShell(DESCRIBE_COMMAND, args); @@ -82,11 +82,13 @@ return response != null ? response.getDescription() : Util.EMPTY_STRING; } + @Override public String[] getNames(String type) throws IOException { return null; } + @Override public void close() throws IOException { try { if (protocol != null) { @@ -94,9 +96,8 @@ protocol.close(); } // run all close runnables. - for (Iterator iterator = this.closeRunnables.iterator(); iterator - .hasNext();) { - Runnable op = (Runnable) iterator.next(); + for (Iterator<Runnable> iterator = this.closeRunnables.iterator(); iterator.hasNext();) { + Runnable op = iterator.next(); op.run(); } } catch (SocketException e) { @@ -104,11 +105,11 @@ } // IScriptConsoleProtocol + @Override public void consoleConnected(IScriptConsoleIO protocol) { this.protocol = protocol; - for (Iterator iterator = this.initialListeners.iterator(); iterator - .hasNext();) { - Runnable op = (Runnable) iterator.next(); + for (Iterator<Runnable> iterator = this.initialListeners.iterator(); iterator.hasNext();) { + Runnable op = iterator.next(); Thread t = new Thread(op); t.run(); } @@ -119,6 +120,7 @@ this.closeRunnables.add(runnable); } + @Override public void addInitialListenerOperation(Runnable runnable) { if (this.protocol != null) { new Thread(runnable).start(); @@ -127,6 +129,7 @@ } } + @Override public InputStream getInitialOutputStream() { return protocol.getInitialResponseStream(); }
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstall.java b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstall.java index 85d35e7..f47d187 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstall.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstall.java
@@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 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 * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.tcl.internal.launching; @@ -46,10 +45,9 @@ boolean initialized = false; void load() { - final IContentCache cache = ModelManager.getModelManager() - .getCoreCache(); - String builtins = cache.getCacheEntryAttributeString(install - .getInstallLocation(), BUILTINST_INFORMATION, true); + final IContentCache cache = ModelManager.getModelManager().getCoreCache(); + String builtins = cache.getCacheEntryAttributeString(install.getInstallLocation(), BUILTINST_INFORMATION, + true); if (builtins != null) { source.append(builtins); lastModified = System.currentTimeMillis(); @@ -57,24 +55,18 @@ return; } Job loadTclBuiltin = new Job("Generate Tcl builtin file...") { + @Override protected IStatus run(final IProgressMonitor monitor) { - monitor.beginTask("Generate Tcl builtin file", - IProgressMonitor.UNKNOWN); + monitor.beginTask("Generate Tcl builtin file", IProgressMonitor.UNKNOWN); IExecutionEnvironment exeEnv = install.getExecEnvironment(); if (exeEnv == null) return Status.CANCEL_STATUS; String bundlePath = "scripts/builtins.tcl"; - String content = ScriptLaunchUtil - .runEmbeddedScriptReadContent( - exeEnv, - bundlePath, - TclLaunchingPlugin.getDefault().getBundle(), - install.getInstallLocation(), monitor); + String content = ScriptLaunchUtil.runEmbeddedScriptReadContent(exeEnv, bundlePath, + TclLaunchingPlugin.getDefault().getBundle(), install.getInstallLocation(), monitor); if (content != null) { - cache.setCacheEntryAttribute(install - .getInstallLocation(), BUILTINST_INFORMATION, - content); + cache.setCacheEntryAttribute(install.getInstallLocation(), BUILTINST_INFORMATION, content); } if (content != null) { source.append(content); @@ -100,6 +92,7 @@ super(type, id); } + @Override public IInterpreterRunner getInterpreterRunner(String mode) { IInterpreterRunner runner = super.getInterpreterRunner(mode); @@ -114,18 +107,21 @@ return null; } + @Override public String getNatureId() { return TclNature.NATURE_ID; } - private static final Map<IInterpreterInstall, BuiltinsHelper> helpers = new HashMap<IInterpreterInstall, BuiltinsHelper>(); + private static final Map<IInterpreterInstall, BuiltinsHelper> helpers = new HashMap<>(); // Builtins + @Override public String getBuiltinModuleContent(String name) { BuiltinsHelper helper = initialize(); return helper.source.toString(); } + @Override public long lastModified() { BuiltinsHelper helper = initialize(); return helper.lastModified; @@ -148,6 +144,7 @@ return helper; } + @Override public String[] getBuiltinModules() { return new String[] { "builtins.tcl" }; //$NON-NLS-1$ }
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstallType.java b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstallType.java index 5c5893e..314535e 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstallType.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/GenericTclInstallType.java
@@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 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 * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.tcl.internal.launching; @@ -39,7 +38,6 @@ import org.eclipse.dltk.tcl.core.TclPackagesManager; import org.eclipse.dltk.tcl.core.TclPlugin; import org.eclipse.dltk.tcl.core.packages.TclInterpreterInfo; -import org.eclipse.dltk.tcl.core.packages.TclPackageInfo; import org.eclipse.dltk.tcl.core.packages.TclPackagesFactory; import org.eclipse.dltk.tcl.internal.core.packages.ProcessOutputCollector; import org.eclipse.dltk.tcl.launching.TclLaunchingPlugin; @@ -52,11 +50,10 @@ * @since 1.1 */ public static final String TYPE_ID = "org.eclipse.dltk.internal.debug.ui.launcher.GenericTclInstallType"; - private static final String[] INTERPRETER_NAMES = { "tclsh", "tclsh84", - "tclsh8.4", "tclsh85", "tclsh8.5", "tclsh8.6", + private static final String[] INTERPRETER_NAMES = { "tclsh", "tclsh84", "tclsh8.4", "tclsh85", "tclsh8.5", + "tclsh8.6", - "wish", "wish84", "wish85", "wish86", "wish8.4", "wish85", - "wish8.5", "wish8.6", + "wish", "wish84", "wish85", "wish86", "wish8.4", "wish85", "wish8.5", "wish8.6", "vtk", @@ -64,76 +61,72 @@ "base-tcl-linux", "base-tk-linux", - "base-tcl-thread", "base-tk-thread", "base-tcl8.5-thread", - "base-tcl8.6-thread", "base-tk8.5-thread", "base-tk8.6-thread" }; + "base-tcl-thread", "base-tk-thread", "base-tcl8.5-thread", "base-tcl8.6-thread", "base-tk8.5-thread", + "base-tk8.6-thread" }; + @Override public String getNatureId() { return TclNature.NATURE_ID; } + @Override public String getName() { return INSTALL_TYPE_NAME; } + @Override protected String getPluginId() { return TclLaunchingPlugin.PLUGIN_ID; } + @Override protected String[] getPossibleInterpreterNames() { return INTERPRETER_NAMES; } + @Override protected IInterpreterInstall doCreateInterpreterInstall(String id) { return new GenericTclInstall(this, id); } - protected void filterEnvironment(Map environment) { + @Override + protected void filterEnvironment(Map<String, String> environment) { // make sure that $auto_path is clean environment.remove("TCLLIBPATH"); // block wish from showing window under linux environment.remove("DISPLAY"); } - public IStatus validateInstallLocation(IFileHandle installLocation, - EnvironmentVariable[] variables, LibraryLocation[] libraries, - IProgressMonitor monitor) { - /* Progress monitoring */monitor.beginTask("Validate Tcl interpreter", - 100); + @Override + public IStatus validateInstallLocation(IFileHandle installLocation, EnvironmentVariable[] variables, + LibraryLocation[] libraries, IProgressMonitor monitor) { + /* Progress monitoring */monitor.beginTask("Validate Tcl interpreter", 100); try { if (!installLocation.exists() || !installLocation.isFile()) { - return createStatus( - IStatus.ERROR, - InterpreterMessages.errNonExistentOrInvalidInstallLocation, - null); + return createStatus(IStatus.ERROR, InterpreterMessages.errNonExistentOrInvalidInstallLocation, null); } IEnvironment environment = installLocation.getEnvironment(); - IExecutionEnvironment executionEnvironment = (IExecutionEnvironment) environment - .getAdapter(IExecutionEnvironment.class); - /* Progress monitoring */monitor - .subTask("Deploy validation script"); + IExecutionEnvironment executionEnvironment = environment.getAdapter(IExecutionEnvironment.class); + /* Progress monitoring */monitor.subTask("Deploy validation script"); IDeployment deployment = executionEnvironment.createDeployment(); if (deployment == null) { // happens if RSE is not initialized yet or no connection // established return createStatus(IStatus.ERROR, - "Failed to deploy validation script to host:" - + environment.getName(), null); + "Failed to deploy validation script to host:" + environment.getName(), null); } List<String> output = null; Bundle bundle = TclPlugin.getDefault().getBundle(); try { - IFileHandle builderFile = deployment.getFile(deployment.add( - bundle, "scripts/dltk.tcl")); + IFileHandle builderFile = deployment.getFile(deployment.add(bundle, "scripts/dltk.tcl")); /* Progress monitoring */monitor.worked(10); - InterpreterConfig config = ScriptLaunchUtil - .createInterpreterConfig(executionEnvironment, - builderFile, builderFile.getParent()); + InterpreterConfig config = ScriptLaunchUtil.createInterpreterConfig(executionEnvironment, builderFile, + builderFile.getParent()); config.addScriptArg("get-pkgs"); // Configure environment variables - final Map<String, String> envVars = new HashMap<String, String>(); + final Map<String, String> envVars = new HashMap<>(); - Map<String, String> envVars2 = executionEnvironment - .getEnvironmentVariables(false); + Map<String, String> envVars2 = executionEnvironment.getEnvironmentVariables(false); if (envVars2 != null) { envVars.putAll(envVars2); } @@ -141,27 +134,21 @@ config.addEnvVars(envVars); config.removeEnvVar("DISPLAY"); //$NON-NLS-1$ TclLibpathUtils.addTclLibPath(config, libraries, environment); - /* Progress monitoring */monitor - .subTask("Running validation script"); - String[] cmdLine = config.renderCommandLine( - executionEnvironment.getEnvironment(), installLocation - .toOSString()); + /* Progress monitoring */monitor.subTask("Running validation script"); + String[] cmdLine = config.renderCommandLine(executionEnvironment.getEnvironment(), + installLocation.toOSString()); - String[] environmentAsStrings = config - .getEnvironmentAsStringsIncluding(variables); + String[] environmentAsStrings = config.getEnvironmentAsStringsIncluding(variables); IPath workingDirectoryPath = config.getWorkingDirectoryPath(); if (DLTKLaunchingPlugin.TRACE_EXECUTION) { - ScriptLaunchUtil.traceExecution( - "runScript with interpreter", cmdLine, //$NON-NLS-1$ + ScriptLaunchUtil.traceExecution("runScript with interpreter", cmdLine, //$NON-NLS-1$ environmentAsStrings); } - final Process process = executionEnvironment.exec(cmdLine, - workingDirectoryPath, environmentAsStrings); + final Process process = executionEnvironment.exec(cmdLine, workingDirectoryPath, environmentAsStrings); /* Progress monitoring */monitor.worked(10); SubProgressMonitor sm = new SubProgressMonitor(monitor, 70); - sm.beginTask("Running validation script", - IProgressMonitor.UNKNOWN); + sm.beginTask("Running validation script", IProgressMonitor.UNKNOWN); sm.done(); output = ProcessOutputCollector.execute(process, sm); @@ -172,9 +159,7 @@ exitValue = -1; } if (exitValue != 0) { - return createStatus(IStatus.ERROR, - "Interpreter return abnormal exit code:" - + exitValue, null); + return createStatus(IStatus.ERROR, "Interpreter return abnormal exit code:" + exitValue, null); } } catch (IOException e1) { if (DLTKCore.DEBUG) { @@ -190,9 +175,7 @@ deployment.dispose(); } if (output == null) { - return createStatus(IStatus.ERROR, - InterpreterMessages.errNoInterpreterExecutablesFound, - null); + return createStatus(IStatus.ERROR, InterpreterMessages.errNoInterpreterExecutablesFound, null); } boolean correct = output.contains(TclPackagesManager.END_OF_STREAM); @@ -200,48 +183,44 @@ monitor.subTask("Processing validation result"); // Parse list of packages from output // Generate fake interpreter install - TclInterpreterInfo info = TclPackagesFactory.eINSTANCE - .createTclInterpreterInfo(); + TclInterpreterInfo info = TclPackagesFactory.eINSTANCE.createTclInterpreterInfo(); TclPackagesManager.fillPackagesFromContent(output, info); monitor.worked(10); return new StatusWithPackages(info); } else { - return createStatus(IStatus.ERROR, - InterpreterMessages.errNoInterpreterExecutablesFound, - null); + return createStatus(IStatus.ERROR, InterpreterMessages.errNoInterpreterExecutablesFound, null); } } finally { monitor.done(); } } - protected ILookupRunnable createLookupRunnable( - final IFileHandle installLocation, final List locations, - final EnvironmentVariable[] variables) { - return new ILookupRunnable() { - public void run(IProgressMonitor monitor) { - // This retrieval could not receive paths in some cases. - // String result = retrivePaths(installLocation, locations, - // monitor, createPathFile(), variables); - // This is safe retrieval - // String[] autoPath = DLTKTclHelper.getDefaultPath( - // installLocation, variables); - // IEnvironment env = installLocation.getEnvironment(); - // if (autoPath != null) { - // for (int i = 0; i < autoPath.length; i++) { - // Path libraryPath = new Path(autoPath[i]); - // IFileHandle file = env.getFile(libraryPath); - // if (file.exists()) { - // locations.add(new LibraryLocation(libraryPath)); - // } - // } - // } - } + @Override + protected ILookupRunnable createLookupRunnable(final IFileHandle installLocation, + final List<LibraryLocation> locations, final EnvironmentVariable[] variables) { + return monitor -> { + // This retrieval could not receive paths in some cases. + // String result = retrivePaths(installLocation, locations, + // monitor, createPathFile(), variables); + // This is safe retrieval + // String[] autoPath = DLTKTclHelper.getDefaultPath( + // installLocation, variables); + // IEnvironment env = installLocation.getEnvironment(); + // if (autoPath != null) { + // for (int i = 0; i < autoPath.length; i++) { + // Path libraryPath = new Path(autoPath[i]); + // IFileHandle file = env.getFile(libraryPath); + // if (file.exists()) { + // locations.add(new LibraryLocation(libraryPath)); + // } + // } + // } }; } + @Override protected String[] parsePaths(String res) { - ArrayList paths = new ArrayList(); + ArrayList<String> paths = new ArrayList<>(); String subs = null; int index = 0; String result = res; @@ -250,8 +229,7 @@ } while (index < result.length()) { // skip whitespaces - while (index < result.length() - && Character.isWhitespace(result.charAt(index))) + while (index < result.length() && Character.isWhitespace(result.charAt(index))) index++; if (index == result.length()) break; @@ -274,13 +252,15 @@ index++; } - return (String[]) paths.toArray(new String[paths.size()]); + return paths.toArray(new String[paths.size()]); } + @Override protected ILog getLog() { return TclLaunchingPlugin.getDefault().getLog(); } + @Override protected IPath createPathFile(IDeployment deployment) throws IOException { return null; }
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/TclInterpreterRunner.java b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/TclInterpreterRunner.java index d20eeff..deff4cf 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/TclInterpreterRunner.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/internal/launching/TclInterpreterRunner.java
@@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 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 * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.tcl.internal.launching; @@ -43,6 +42,7 @@ super(install); } + @Override protected String getProcessType() { return TclLaunchConfigurationConstants.ID_TCL_PROCESS_TYPE; } @@ -53,32 +53,26 @@ if (vars != null) { String var = config.getEnvVar(TclLibpathUtils.TCLLIBPATH); if (var != null) { - List<EnvironmentVariable> resultingVars = new ArrayList<EnvironmentVariable>(); + List<EnvironmentVariable> resultingVars = new ArrayList<>(); for (EnvironmentVariable envVar : vars) { if (envVar.getName().equals(TclLibpathUtils.TCLLIBPATH)) { - EnvironmentVariable[] variables = EnvironmentResolver - .resolve(config.getEnvVars(), - new EnvironmentVariable[] { envVar }, - true); - String newValue = var - + " " - + TclLibpathUtils - .convertToTclLibPathFormat(variables[0] - .getValue()); + EnvironmentVariable[] variables = EnvironmentResolver.resolve(config.getEnvVars(), + new EnvironmentVariable[] { envVar }, true); + String newValue = var + " " + + TclLibpathUtils.convertToTclLibPathFormat(variables[0].getValue()); config.addEnvVar(TclLibpathUtils.TCLLIBPATH, newValue); } else { resultingVars.add(envVar); } } - return config - .getEnvironmentAsStringsIncluding(resultingVars - .toArray(new EnvironmentVariable[resultingVars - .size()])); + return config.getEnvironmentAsStringsIncluding( + resultingVars.toArray(new EnvironmentVariable[resultingVars.size()])); } } return config.getEnvironmentAsStringsIncluding(vars); } + @Override protected void alterConfig(ILaunch launch, InterpreterConfig config) { super.alterConfig(launch, config); if (!ILaunchManager.RUN_MODE.equals(launch.getLaunchMode())) { @@ -90,9 +84,7 @@ boolean useTclConsole = false; try { useTclConsole = configuration - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, - false); + .getAttribute(ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, false); } catch (CoreException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); @@ -103,30 +95,21 @@ String port = Integer.toString(server.getPort()); try { - IExecutionEnvironment executionEnvironment = config - .getExecutionEnvironment(); - IDeployment deployment = executionEnvironment - .createDeployment(); + IExecutionEnvironment executionEnvironment = config.getExecutionEnvironment(); + IDeployment deployment = executionEnvironment.createDeployment(); if (deployment == null) { - throw new CoreException( - new Status(IStatus.ERROR, - TclLaunchingPlugin.PLUGIN_ID, - "Could not establish connection with environment.")); + throw new CoreException(new Status(IStatus.ERROR, TclLaunchingPlugin.PLUGIN_ID, + "Could not establish connection with environment.")); } - DeploymentManager.getInstance().addDeployment(launch, - deployment); - IPath path = deployment.add(TclLaunchingPlugin.getDefault() - .getBundle(), TclLaunchingPlugin.getDefault() - .getConsoleProxy()); + DeploymentManager.getInstance().addDeployment(launch, deployment); + IPath path = deployment.add(TclLaunchingPlugin.getDefault().getBundle(), + TclLaunchingPlugin.getDefault().getConsoleProxy()); IFileHandle scriptFile = deployment.getFile(path); - String id = configuration - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_CONSOLE_ID, - (String) null); + String id = configuration.getAttribute(ScriptLaunchConfigurationConstants.ATTR_DLTK_CONSOLE_ID, + (String) null); config.addInterpreterArg(scriptFile.toOSString()); - config.addInterpreterArg(DLTKDebugPlugin.getDefault() - .getBindAddress()); + config.addInterpreterArg(DLTKDebugPlugin.getDefault().getBindAddress()); IPath scriptFilePath = config.getScriptFilePath(); if (scriptFilePath == null) { config.setScriptFile(new Path("--noscript")); @@ -136,10 +119,8 @@ if (id != null) { config.addInterpreterArg(id); } else { - throw new CoreException( - new Status(IStatus.ERROR, - TclLaunchingPlugin.PLUGIN_ID, - "Error to obtain console ID. Please update launch configuratin.")); + throw new CoreException(new Status(IStatus.ERROR, TclLaunchingPlugin.PLUGIN_ID, + "Error to obtain console ID. Please update launch configuratin.")); } } catch (IOException e) { if (DLTKCore.DEBUG) {
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/launching/TclLaunchingPlugin.java b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/launching/TclLaunchingPlugin.java index aff2307..17dc16d 100644 --- a/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/launching/TclLaunchingPlugin.java +++ b/tcl/plugins/org.eclipse.dltk.tcl.launching/src/org/eclipse/dltk/tcl/launching/TclLaunchingPlugin.java
@@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 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 * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.tcl.launching; @@ -32,10 +31,12 @@ plugin = this; } + @Override public void start(BundleContext context) throws Exception { super.start(context); } + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); @@ -43,7 +44,7 @@ /** * Returns the shared instance - * + * * @return the shared instance */ public static TclLaunchingPlugin getDefault() { @@ -59,13 +60,11 @@ } public static void log(String message) { - log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, - message, null)); + log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null)); } public static void log(Throwable e) { - log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e - .getMessage(), e)); + log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e)); } public String getConsoleProxy() {