tcl.formatter: Move to Java 1.8.

Enable warnings, fix them and enable save actions.

Change-Id: If801e8d6c2d7c69eae2d7c9649eb7e6a2dd9be83
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.formatter/.classpath b/tcl/plugins/org.eclipse.dltk.tcl.formatter/.classpath
index 64c5e31..eca7bdb 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/.classpath
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/.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.formatter/.settings/org.eclipse.jdt.core.prefs b/tcl/plugins/org.eclipse.dltk.tcl.formatter/.settings/org.eclipse.jdt.core.prefs
index f053d4c..05ff4a1 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/.settings/org.eclipse.jdt.core.prefs
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,109 @@
-#Wed Dec 09 14:49:15 NOVT 2009
 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.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+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
+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.source=1.5
+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.formatter/.settings/org.eclipse.jdt.ui.prefs b/tcl/plugins/org.eclipse.dltk.tcl.formatter/.settings/org.eclipse.jdt.ui.prefs
index ce28544..79706d3 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/.settings/org.eclipse.jdt.ui.prefs
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,61 @@
-#Fri Oct 03 18:04:11 NOVST 2008
 eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
 org.eclipse.jdt.ui.javadoc=false
 org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\r\n * Copyright (c) 2008 xored software, Inc.  \r\n *\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html  \r\n *\r\n * Contributors\:\r\n *     xored software, Inc. - initial API and Implementation (Sergey Kanshin)\r\n *******************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+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.formatter/META-INF/MANIFEST.MF b/tcl/plugins/org.eclipse.dltk.tcl.formatter/META-INF/MANIFEST.MF
index e2c3910..372c772 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/META-INF/MANIFEST.MF
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/META-INF/MANIFEST.MF
@@ -18,6 +18,6 @@
  org.eclipse.dltk.formatter;bundle-version="0.0.0",
  org.eclipse.emf.ecore
 Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-Vendor: %pluginProvider
 Export-Package: org.eclipse.dltk.tcl.formatter
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatter.java b/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatter.java
index c08b11a..3c6f436 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatter.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatter.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 (Sergey Kanshin)
@@ -41,18 +41,15 @@
 
 @SuppressWarnings("restriction")
 public class TclFormatter extends AbstractScriptFormatter {
-	protected static final String[] INDENTING = {
-			TclFormatterConstants.INDENT_SCRIPT,
+	protected static final String[] INDENTING = { TclFormatterConstants.INDENT_SCRIPT,
 			TclFormatterConstants.INDENT_AFTER_BACKSLASH };
 
-	protected static final String[] BLANK_LINES = {
-			TclFormatterConstants.LINES_FILE_AFTER_PACKAGE,
+	protected static final String[] BLANK_LINES = { TclFormatterConstants.LINES_FILE_AFTER_PACKAGE,
 			TclFormatterConstants.LINES_FILE_BETWEEN_PROC };
 
 	private final String lineDelimiter;
 
-	@SuppressWarnings("unchecked")
-	public TclFormatter(String lineDelimiter, Map preferences) {
+	public TclFormatter(String lineDelimiter, Map<String, ? extends Object> preferences) {
 		super(preferences);
 		this.lineDelimiter = lineDelimiter;
 	}
@@ -64,27 +61,22 @@
 		}
 		final String input = document.get();
 		List<TclCommand> commands = parse(input);
-		final FormatterIndentDetector detector = new FormatterIndentDetector(
-				offset);
+		final FormatterIndentDetector detector = new FormatterIndentDetector(offset);
 		return detector.getLevel(commands);
 	}
 
-	public TextEdit format(String source, int offset, int length, int indent)
-			throws FormatterException {
+	@Override
+	public TextEdit format(String source, int offset, int length, int indent) throws FormatterException {
 		final String input = source.substring(offset, offset + length);
 		List<TclCommand> commands = parse(input);
 		final String output = format(input, commands, indent);
 		if (output != null) {
 			if (!input.equals(output)) {
-				if (!isValidation()
-						|| equalsIgnoreBlanks(new StringReader(input),
-								new StringReader(output))) {
+				if (!isValidation() || equalsIgnoreBlanks(new StringReader(input), new StringReader(output))) {
 					return new ReplaceEdit(offset, length, output);
 				} else {
-					TclFormatterPlugin.log(new Status(IStatus.ERROR,
-							TclFormatterPlugin.PLUGIN_ID, IStatus.OK,
-							Messages.TclFormatter_contentCorrupted,
-							new DumpContentException(input)));
+					TclFormatterPlugin.log(new Status(IStatus.ERROR, TclFormatterPlugin.PLUGIN_ID, IStatus.OK,
+							Messages.TclFormatter_contentCorrupted, new DumpContentException(input)));
 				}
 			} else {
 				return new MultiTextEdit(); // NOP
@@ -99,20 +91,16 @@
 		return parser.parse(input, 0);
 	}
 
-	private String format(String input, List<TclCommand> commands, int indent)
-			throws FormatterException {
+	private String format(String input, List<TclCommand> commands, int indent) throws FormatterException {
 		FormatterDocument document = createDocument(input);
-		final TclFormatterWriter writer = new TclFormatterWriter(document,
-				lineDelimiter, createIndentGenerator());
-		writer
-				.setWrapLength(getInt(TclFormatterConstants.WRAP_COMMENTS_LENGTH));
+		final TclFormatterWriter writer = new TclFormatterWriter(document, lineDelimiter, createIndentGenerator());
+		writer.setWrapLength(getInt(TclFormatterConstants.WRAP_COMMENTS_LENGTH));
 		writer.setLinesPreserve(getInt(TclFormatterConstants.LINES_PRESERVE));
 		// tclWriter.setTrimEmptyLines(false);
 		// tclWriter.setTrimTrailingSpaces(false);
 		try {
 			final FormatterContext context = new FormatterContext(indent);
-			final FormatterWorker worker = new FormatterWorker(writer,
-					document, context);
+			final FormatterWorker worker = new FormatterWorker(writer, document, context);
 			worker.format(commands);
 			writer.flush(context);
 			return writer.getOutput();
@@ -129,10 +117,8 @@
 		for (int i = 0; i < BLANK_LINES.length; ++i) {
 			document.setInt(BLANK_LINES[i], getInt(BLANK_LINES[i]));
 		}
-		document.setInt(TclFormatterConstants.FORMATTER_TAB_SIZE,
-				getInt(TclFormatterConstants.FORMATTER_TAB_SIZE));
-		document.setBoolean(TclFormatterConstants.WRAP_COMMENTS,
-				getBoolean(TclFormatterConstants.WRAP_COMMENTS));
+		document.setInt(TclFormatterConstants.FORMATTER_TAB_SIZE, getInt(TclFormatterConstants.FORMATTER_TAB_SIZE));
+		document.setBoolean(TclFormatterConstants.WRAP_COMMENTS, getBoolean(TclFormatterConstants.WRAP_COMMENTS));
 		return document;
 	}
 
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatterFactory.java b/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatterFactory.java
index c92f653..8c32e65 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatterFactory.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/TclFormatterFactory.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 (Sergey Kanshin)
@@ -26,32 +26,26 @@
 
 public class TclFormatterFactory extends AbstractScriptFormatterFactory {
 
-	private static final String[] KEYS = {
-			TclFormatterConstants.FORMATTER_TAB_CHAR,
-			TclFormatterConstants.FORMATTER_INDENTATION_SIZE,
-			TclFormatterConstants.FORMATTER_TAB_SIZE,
-			TclFormatterConstants.INDENT_SCRIPT,
-			TclFormatterConstants.INDENT_AFTER_BACKSLASH,
-			TclFormatterConstants.LINES_PRESERVE,
-			TclFormatterConstants.LINES_FILE_AFTER_PACKAGE,
-			TclFormatterConstants.LINES_FILE_BETWEEN_PROC,
-			TclFormatterConstants.WRAP_COMMENTS,
+	private static final String[] KEYS = { TclFormatterConstants.FORMATTER_TAB_CHAR,
+			TclFormatterConstants.FORMATTER_INDENTATION_SIZE, TclFormatterConstants.FORMATTER_TAB_SIZE,
+			TclFormatterConstants.INDENT_SCRIPT, TclFormatterConstants.INDENT_AFTER_BACKSLASH,
+			TclFormatterConstants.LINES_PRESERVE, TclFormatterConstants.LINES_FILE_AFTER_PACKAGE,
+			TclFormatterConstants.LINES_FILE_BETWEEN_PROC, TclFormatterConstants.WRAP_COMMENTS,
 			TclFormatterConstants.WRAP_COMMENTS_LENGTH };
 
-	@SuppressWarnings("unchecked")
-	public IScriptFormatter createFormatter(String lineDelimiter,
-			Map preferences) {
+	@Override
+	public IScriptFormatter createFormatter(String lineDelimiter, Map<String, String> preferences) {
 		return new TclFormatter(lineDelimiter, preferences);
 	}
 
+	@Override
 	public PreferenceKey[] getPreferenceKeys() {
 		final PreferenceKey[] result = new PreferenceKey[KEYS.length];
 		for (int i = 0; i < KEYS.length; ++i) {
 			final String key = KEYS[i];
 			final String qualifier;
 			if (TclFormatterConstants.FORMATTER_TAB_CHAR.equals(key)
-					|| TclFormatterConstants.FORMATTER_INDENTATION_SIZE
-							.equals(key)
+					|| TclFormatterConstants.FORMATTER_INDENTATION_SIZE.equals(key)
 					|| TclFormatterConstants.FORMATTER_TAB_SIZE.equals(key)) {
 				qualifier = TclUI.PLUGIN_ID;
 			} else {
@@ -63,20 +57,17 @@
 	}
 
 	@Override
-	public Map<String, String> changeToIndentingOnly(
-			Map<String, String> preferences) {
-		Map<String, String> result = new HashMap<String, String>(preferences);
-		result.put(TclFormatterConstants.LINES_FILE_AFTER_PACKAGE, String
-				.valueOf(-1));
-		result.put(TclFormatterConstants.LINES_FILE_BETWEEN_PROC, String
-				.valueOf(-1));
+	public Map<String, String> changeToIndentingOnly(Map<String, String> preferences) {
+		Map<String, String> result = new HashMap<>(preferences);
+		result.put(TclFormatterConstants.LINES_FILE_AFTER_PACKAGE, String.valueOf(-1));
+		result.put(TclFormatterConstants.LINES_FILE_BETWEEN_PROC, String.valueOf(-1));
 		result.put(TclFormatterConstants.LINES_PRESERVE, String.valueOf(-1));
 		result.put(TclFormatterConstants.WRAP_COMMENTS, String.valueOf(false));
 		return result;
 	}
 
-	public IFormatterModifyDialog createDialog(
-			IFormatterModifyDialogOwner dialogOwner) {
+	@Override
+	public IFormatterModifyDialog createDialog(IFormatterModifyDialogOwner dialogOwner) {
 		return new TclFormatterModifyDialog(dialogOwner, this);
 	}
 
@@ -85,15 +76,14 @@
 		return getClass().getResource("preferences/formatterPreview.txt"); //$NON-NLS-1$
 	}
 
+	@Override
 	public PreferenceKey getActiveProfileKey() {
-		return new PreferenceKey(TclFormatterPlugin.PLUGIN_ID,
-				TclFormatterConstants.FORMATTER_PROFILES);
+		return new PreferenceKey(TclFormatterPlugin.PLUGIN_ID, TclFormatterConstants.FORMATTER_PROFILES);
 	}
 
 	@Override
 	public PreferenceKey getProfilesKey() {
-		return new PreferenceKey(TclFormatterPlugin.PLUGIN_ID,
-				TclFormatterConstants.FORMATTER_ACTIVE_PROFILE);
+		return new PreferenceKey(TclFormatterPlugin.PLUGIN_ID, TclFormatterConstants.FORMATTER_ACTIVE_PROFILE);
 	}
 
 }
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/internal/FormatterWorker.java b/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/internal/FormatterWorker.java
index bff5dcf..041eb08 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/internal/FormatterWorker.java
+++ b/tcl/plugins/org.eclipse.dltk.tcl.formatter/src/org/eclipse/dltk/tcl/formatter/internal/FormatterWorker.java
@@ -40,23 +40,19 @@
 	 * @param indentGenerator
 	 * @param wrapLength
 	 */
-	public FormatterWorker(TclFormatterWriter writer,
-			IFormatterDocument document, IFormatterContext context) {
+	public FormatterWorker(TclFormatterWriter writer, IFormatterDocument document, IFormatterContext context) {
 		this.writer = writer;
 		this.document = document;
 		this.context = context;
 	}
 
-	private static boolean isBackSlashLine(final IFormatterDocument document,
-			String line) {
-		return document
-				.getBoolean(TclFormatterConstants.INDENT_AFTER_BACKSLASH)
-				&& (line.contains(BACKSLASH + "\n") || line.contains(BACKSLASH
-						+ "\r"));
+	private static boolean isBackSlashLine(final IFormatterDocument document, String line) {
+		return document.getBoolean(TclFormatterConstants.INDENT_AFTER_BACKSLASH)
+				&& (line.contains(BACKSLASH + "\n") || line.contains(BACKSLASH + "\r"));
 	}
 
 	private static List<String> splitComments(String input) {
-		List<String> result = new ArrayList<String>();
+		List<String> result = new ArrayList<>();
 		List<String> lines = splitLines(input);
 		StringBuffer sb = new StringBuffer();
 		for (String line : lines) {
@@ -74,7 +70,7 @@
 
 	private static List<String> splitLines(String text) {
 		char[] input = text.toCharArray();
-		List<String> lines = new ArrayList<String>();
+		List<String> lines = new ArrayList<>();
 		StringBuffer sb = new StringBuffer();
 		for (int i = 0; i < input.length; i++) {
 			sb.append(input[i]);
@@ -98,11 +94,9 @@
 	}
 
 	private static boolean isIf0Comment(TclCommand command) {
-		return "if".equals(command.getQualifiedName())
-				&& command.getArguments().size() == 2
+		return "if".equals(command.getQualifiedName()) && command.getArguments().size() == 2
 				&& command.getArguments().get(0) instanceof StringArgument
-				&& "0".equals(((StringArgument) command.getArguments().get(0))
-						.getValue())
+				&& "0".equals(((StringArgument) command.getArguments().get(0)).getValue())
 				&& command.getArguments().get(1) instanceof Script;
 	}
 
@@ -111,7 +105,7 @@
 	}
 
 	/**
-	 * 
+	 *
 	 * @param commands
 	 * @param document
 	 * @return formatted code
@@ -134,19 +128,16 @@
 			}
 			wasPackageDirective = true;
 		} else if (wasPackageDirective) {
-			context.setBlankLines(document
-					.getInt(TclFormatterConstants.LINES_FILE_AFTER_PACKAGE));
+			context.setBlankLines(document.getInt(TclFormatterConstants.LINES_FILE_AFTER_PACKAGE));
 			wasPackageDirective = false;
 		}
 		// 'proc' directive handling
 		if (PROC_DIRECTIVE.equals(command.getQualifiedName())) {
-			List<String> comments = splitComments(document.get(lastReaderPos,
-					command.getStart()));
+			List<String> comments = splitComments(document.get(lastReaderPos, command.getStart()));
 			for (int i = 0; i < comments.size() - 1; i++) {
 				write(lastReaderPos + comments.get(i).length());
 			}
-			context.setBlankLines(document
-					.getInt(TclFormatterConstants.LINES_FILE_BETWEEN_PROC));
+			context.setBlankLines(document.getInt(TclFormatterConstants.LINES_FILE_BETWEEN_PROC));
 		} else if (isIf0Comment(command)) { // if 0 { comments }
 			lastComment = true;
 			write(command.getEnd());
@@ -159,8 +150,7 @@
 	@Override
 	public void endVisit(TclCommand command) {
 		if (PROC_DIRECTIVE.equals(command.getQualifiedName())) {
-			context.setBlankLines(document
-					.getInt(TclFormatterConstants.LINES_FILE_BETWEEN_PROC));
+			context.setBlankLines(document.getInt(TclFormatterConstants.LINES_FILE_BETWEEN_PROC));
 		}
 	}
 
@@ -283,8 +273,7 @@
 			// Wrapping comments option
 			if (line.trim().startsWith("#")) {
 				final boolean savedWrapping = context.isWrapping();
-				context.setWrapping(document
-						.getBoolean(TclFormatterConstants.WRAP_COMMENTS));
+				context.setWrapping(document.getBoolean(TclFormatterConstants.WRAP_COMMENTS));
 				try {
 					writer.write(context, lastReaderPos, end);
 				} catch (Exception e) {