diff options
author | Alexander Kurtakov | 2017-02-26 21:12:35 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-02-26 21:12:35 +0000 |
commit | d9f00abd4deedd91c33cd7348458a5d509b5fb49 (patch) | |
tree | 8216eefadcb6ffe8d54128eb478afee753387bc3 | |
parent | 1c4322afe048347cb3a186a4e2cfaa75287f7d90 (diff) | |
download | org.eclipse.dltk.tcl-d9f00abd4deedd91c33cd7348458a5d509b5fb49.tar.gz org.eclipse.dltk.tcl-d9f00abd4deedd91c33cd7348458a5d509b5fb49.tar.xz org.eclipse.dltk.tcl-d9f00abd4deedd91c33cd7348458a5d509b5fb49.zip |
Modernize o.e.dltk.itcl.core.R5_7_1
* Move to Java 8.
* Enable warnings and fix them.
* Enable save actions to automate changes.
Change-Id: I8d946dcdd7c416dc3eb729bb610679526c66db88
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
38 files changed, 524 insertions, 653 deletions
diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/.classpath b/itcl/plugins/org.eclipse.dltk.itcl.core/.classpath index 64c5e31b..eca7bdba 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/.classpath +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/.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/itcl/plugins/org.eclipse.dltk.itcl.core/.settings/org.eclipse.jdt.core.prefs b/itcl/plugins/org.eclipse.dltk.itcl.core/.settings/org.eclipse.jdt.core.prefs index 55b91ebf..0c68a61d 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/.settings/org.eclipse.jdt.core.prefs +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,7 @@ -#Wed Jun 10 18:13:59 NOVST 2009 eclipse.preferences.version=1 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.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/.settings/org.eclipse.jdt.ui.prefs b/itcl/plugins/org.eclipse.dltk.itcl.core/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..fbac55c1 --- /dev/null +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/.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/itcl/plugins/org.eclipse.dltk.itcl.core/META-INF/MANIFEST.MF b/itcl/plugins/org.eclipse.dltk.itcl.core/META-INF/MANIFEST.MF index c37ea9dc..154b75aa 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/META-INF/MANIFEST.MF +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/META-INF/MANIFEST.MF @@ -13,5 +13,5 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.emf.ecore Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTCLPlugin.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTCLPlugin.java index 60a5f69c..d721df0a 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTCLPlugin.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTCLPlugin.java @@ -21,22 +21,14 @@ public class IncrTCLPlugin extends Plugin { public IncrTCLPlugin() { } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; IncrTclClassesManager.getDefault().startup(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ + @Override public void stop(BundleContext context) throws Exception { IncrTclClassesManager.getDefault().shutdown(); plugin = null; @@ -45,7 +37,7 @@ public class IncrTCLPlugin extends Plugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static IncrTCLPlugin getDefault() { diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclKeywords.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclKeywords.java index f68b4c8f..b82d0c65 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclKeywords.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclKeywords.java @@ -3,17 +3,17 @@ package org.eclipse.dltk.itcl.internal.core; import org.eclipse.dltk.tcl.core.ITclKeywords; public class IncrTclKeywords implements ITclKeywords { - private static String[] IncrTclKeywords = { "class", "itcl", "body", - "code", "configbody", "delete", "ensemble", "scope", "part", - "constructor", "destructor", "common", "public", "protected", - "inherit", "private", "method", "itcl::class", "itcl::body", - "itcl::code", "itcl::configbody", "itcl::delete", "itcl::ensemble", + private static String[] IncrTclKeywords = { "class", "itcl", "body", "code", "configbody", "delete", "ensemble", + "scope", "part", "constructor", "destructor", "common", "public", "protected", "inherit", "private", + "method", "itcl::class", "itcl::body", "itcl::code", "itcl::configbody", "itcl::delete", "itcl::ensemble", "itcl::scope" }; + @Override public String[] getKeywords() { return IncrTclKeywords; } + @Override public String[] getKeywords(int type) { return IncrTclKeywords; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclLanguageExtension.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclLanguageExtension.java index 74ee98d4..363a6612 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclLanguageExtension.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclLanguageExtension.java @@ -16,26 +16,32 @@ public class IncrTclLanguageExtension implements ITclLanguageExtension { public IncrTclLanguageExtension() { } + @Override public ICompletionExtension createCompletionExtension() { return new IncrTclCompletionExtension(); } + @Override public IMatchLocatorExtension createMatchLocatorExtension() { return new IncrTclMatchLocatorExtension(); } + @Override public IMixinBuildVisitorExtension createMixinBuildVisitorExtension() { return new IncrTclMixinBuildVisitorExtension(); } + @Override public ISelectionExtension createSelectionExtension() { return new IncrTclSelectionExtension(); } + @Override public ISourceElementRequestVisitorExtension createSourceElementRequestVisitorExtension() { return new IncrTclSourceElementRequestVisitorExtension(); } + @Override public String getName() { return "Itcl"; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclResolver.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclResolver.java index c49a4ceb..c8cd908f 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclResolver.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/IncrTclResolver.java @@ -34,25 +34,19 @@ public class IncrTclResolver { while (!supersToHandle.isEmpty()) { String superClass = (String) supersToHandle.get(0); supersToHandle.remove(0); - String memberkey = TclParseUtil.getFQNFromModelElement(parent - .getParent(), IMixinRequestor.MIXIN_NAME_SEPARATOR) - + IMixinRequestor.MIXIN_NAME_SEPARATOR - + TclParseUtil.tclNameTo(superClass, - IMixinRequestor.MIXIN_NAME_SEPARATOR); + String memberkey = TclParseUtil.getFQNFromModelElement(parent.getParent(), + IMixinRequestor.MIXIN_NAME_SEPARATOR) + IMixinRequestor.MIXIN_NAME_SEPARATOR + + TclParseUtil.tclNameTo(superClass, IMixinRequestor.MIXIN_NAME_SEPARATOR); if (memberkey.startsWith(IMixinRequestor.MIXIN_NAME_SEPARATOR)) { - memberkey = memberkey - .substring(IMixinRequestor.MIXIN_NAME_SEPARATOR - .length()); + memberkey = memberkey.substring(IMixinRequestor.MIXIN_NAME_SEPARATOR.length()); } String[] split = TclParseUtil.tclSplit(superClass); - IModelElement[] types = findTypeMixin(memberkey, - split[split.length - 1], method.getScriptProject()); + IModelElement[] types = findTypeMixin(memberkey, split[split.length - 1], method.getScriptProject()); for (int j = 0; j < types.length; j++) { IType type = (IType) types[j]; IMethod[] methods = type.getMethods(); for (int i = 0; i < methods.length; i++) { - if (methods[i].getElementName().equals( - method.getElementName())) { + if (methods[i].getElementName().equals(method.getElementName())) { return methods[i]; } } @@ -84,25 +78,20 @@ public class IncrTclResolver { } public static ModuleDeclaration parseModule(IModelElement method) { - ISourceModule sourceModule = (ISourceModule) method - .getAncestor(IModelElement.SOURCE_MODULE); + ISourceModule sourceModule = (ISourceModule) method.getAncestor(IModelElement.SOURCE_MODULE); - ModuleDeclaration module = SourceParserUtil - .getModuleDeclaration(sourceModule); + ModuleDeclaration module = SourceParserUtil.getModuleDeclaration(sourceModule); return module; } - public static IModelElement[] findTypeMixin(String pattern, String name, - IScriptProject project) { - IMixinElement[] find = TclMixinModel.getInstance().getMixin(project) - .find(pattern + "*"); - List elements = new ArrayList(); + public static IModelElement[] findTypeMixin(String pattern, String name, IScriptProject project) { + IMixinElement[] find = TclMixinModel.getInstance().getMixin(project).find(pattern + "*"); + List<IModelElement> elements = new ArrayList<>(); for (int i = 0; i < find.length; i++) { Object[] allObjects = find[i].getAllObjects(); for (int j = 0; j < allObjects.length; j++) { - if (allObjects[j] != null - && (allObjects[j] instanceof IncrTclClass)) { + if (allObjects[j] != null && (allObjects[j] instanceof IncrTclClass)) { String name2 = null; if (allObjects[j] instanceof IncrTclClass) { IncrTclClass field = (IncrTclClass) allObjects[j]; @@ -110,13 +99,11 @@ public class IncrTclResolver { } if (name2 != null && name.equals(name2)) { // this.selectionElements.add(field.getModelElement()); - elements.add(((ITclMixinElement) allObjects[j]) - .getModelElement()); + elements.add(((ITclMixinElement) allObjects[j]).getModelElement()); } } } } - return (IModelElement[]) elements.toArray(new IModelElement[elements - .size()]); + return elements.toArray(new IModelElement[elements.size()]); } } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/classes/IncrTclClassesManager.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/classes/IncrTclClassesManager.java index 881b839a..5111b42d 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/classes/IncrTclClassesManager.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/classes/IncrTclClassesManager.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) @@ -57,7 +57,7 @@ public class IncrTclClassesManager implements IResourceChangeListener { private boolean dirty = false; private int changes = 0; - private Set classNames = new HashSet(); + private Set<String> classNames = new HashSet<>(); public void clean() { this.classNames.clear(); @@ -87,17 +87,14 @@ public class IncrTclClassesManager implements IResourceChangeListener { } private synchronized void load() { - IPath packages = IncrTCLPlugin.getDefault().getStateLocation().append( - PATH_ITCL_CLASSES); + IPath packages = IncrTCLPlugin.getDefault().getStateLocation().append(PATH_ITCL_CLASSES); File packagesFile = packages.toFile(); if (packagesFile.exists()) { - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); - BufferedInputStream stream = new BufferedInputStream( - new FileInputStream(packagesFile)); + BufferedInputStream stream = new BufferedInputStream(new FileInputStream(packagesFile)); Document document = builder.parse(stream); stream.close(); populate(document.getDocumentElement()); @@ -144,8 +141,7 @@ public class IncrTclClassesManager implements IResourceChangeListener { return; } dirty = false; - IPath packages = IncrTCLPlugin.getDefault().getStateLocation().append( - PATH_ITCL_CLASSES); + IPath packages = IncrTCLPlugin.getDefault().getStateLocation().append(PATH_ITCL_CLASSES); File packagesFile = packages.toFile(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; @@ -188,10 +184,10 @@ public class IncrTclClassesManager implements IResourceChangeListener { } private void save(Document doc) { - Element packages = doc.createElement(CLASSES_TAG); //$NON-NLS-1$ + Element packages = doc.createElement(CLASSES_TAG); // $NON-NLS-1$ doc.appendChild(packages); - for (Iterator iterator = this.classNames.iterator(); iterator.hasNext();) { - String value = (String) iterator.next(); + for (Iterator<String> iterator = this.classNames.iterator(); iterator.hasNext();) { + String value = iterator.next(); Element el = doc.createElement(CLASS_TAG); el.setAttribute("value", value); packages.appendChild(el); @@ -211,6 +207,7 @@ public class IncrTclClassesManager implements IResourceChangeListener { return sInstance; } + @Override public void resourceChanged(IResourceChangeEvent event) { // TODO Auto-generated method stub diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclParseUtil.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclParseUtil.java index f871d9dd..66c21749 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclParseUtil.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclParseUtil.java @@ -11,33 +11,27 @@ import org.eclipse.dltk.tcl.core.TclParseUtil; import org.eclipse.dltk.tcl.internal.core.codeassist.TclASTUtil; public class IncrTclParseUtil { - public static FieldDeclaration findInstanceVariableDeclarationFrom( - ModuleDeclaration module, ASTNode parent, String commandNameValue) { - List levels = TclParseUtil.findLevelsTo(module, parent); + public static FieldDeclaration findInstanceVariableDeclarationFrom(ModuleDeclaration module, ASTNode parent, + String commandNameValue) { + List<ASTNode> levels = TclParseUtil.findLevelsTo(module, parent); int len = levels.size(); for (int j = 0; j < len; ++j) { - ASTNode astNodeParent = (ASTNode) levels.get(len - 1 - j); + ASTNode astNodeParent = levels.get(len - 1 - j); List childs = TclASTUtil.getStatements(astNodeParent); if (childs == null) { continue; } for (int i = 0; i < childs.size(); i++) { if ((childs.get(i) instanceof IncrTclInstanceVariable)) { - IncrTclInstanceVariable inst = (IncrTclInstanceVariable) childs - .get(i); - String elementFQN = TclParseUtil.getElementFQN(inst, "::", - module); - if (inst.getName().equals(commandNameValue) - || elementFQN.equals(commandNameValue)) { + IncrTclInstanceVariable inst = (IncrTclInstanceVariable) childs.get(i); + String elementFQN = TclParseUtil.getElementFQN(inst, "::", module); + if (inst.getName().equals(commandNameValue) || elementFQN.equals(commandNameValue)) { return inst; } } else if (childs.get(i) instanceof IncrTclExInstanceVariable) { - IncrTclExInstanceVariable inst = (IncrTclExInstanceVariable) childs - .get(i); - String elementFQN = TclParseUtil.getElementFQN(inst, "::", - module); - if (inst.getName().equals(commandNameValue) - || elementFQN.equals(commandNameValue)) { + IncrTclExInstanceVariable inst = (IncrTclExInstanceVariable) childs.get(i); + String elementFQN = TclParseUtil.getElementFQN(inst, "::", module); + if (inst.getName().equals(commandNameValue) || elementFQN.equals(commandNameValue)) { return inst; } } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclSourceElementRequestVisitorExtension.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclSourceElementRequestVisitorExtension.java index f20277d7..3abddec4 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclSourceElementRequestVisitorExtension.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/IncrTclSourceElementRequestVisitorExtension.java @@ -3,6 +3,7 @@ package org.eclipse.dltk.itcl.internal.core.parser; import java.util.List; import org.eclipse.dltk.ast.ASTListNode; +import org.eclipse.dltk.ast.ASTNode; import org.eclipse.dltk.ast.declarations.Declaration; import org.eclipse.dltk.ast.declarations.FieldDeclaration; import org.eclipse.dltk.ast.declarations.MethodDeclaration; @@ -16,9 +17,9 @@ import org.eclipse.dltk.tcl.core.extensions.ISourceElementRequestVisitorExtensio import org.eclipse.dltk.tcl.internal.parser.TclSourceElementRequestVisitor; import org.eclipse.dltk.tcl.internal.parser.TclSourceElementRequestVisitor.ExitFromType; -public class IncrTclSourceElementRequestVisitorExtension implements - ISourceElementRequestVisitorExtension { +public class IncrTclSourceElementRequestVisitorExtension implements ISourceElementRequestVisitorExtension { + @Override public int getModifiers(Declaration s) { if ((s.getModifiers() & IIncrTclModifiers.AccIncrTcl) != 0) { // This is ordinary class. @@ -27,22 +28,22 @@ public class IncrTclSourceElementRequestVisitorExtension implements return 0; } - public boolean visit(Statement statement, - TclSourceElementRequestVisitor original) { + @Override + public boolean visit(Statement statement, TclSourceElementRequestVisitor original) { if (statement instanceof IncrTclMethodCallStatement) { IncrTclMethodCallStatement call = (IncrTclMethodCallStatement) statement; SimpleReference callName = call.getCallName(); int len = 0; if (call.getArgs() != null) { ASTListNode arguments = call.getArgs(); - List childs = arguments.getChilds(); + List<ASTNode> childs = arguments.getChilds(); if (childs != null) { len = childs.size(); } } - original.getRequestor().acceptMethodReference(callName.getName(), - len, call.sourceStart(), call.sourceEnd()); + original.getRequestor().acceptMethodReference(callName.getName(), len, call.sourceStart(), + call.sourceEnd()); return true; // Also lets add type references from here. @@ -50,8 +51,8 @@ public class IncrTclSourceElementRequestVisitorExtension implements return false; } - public ExitFromType getExitExtended(MethodDeclaration method, - TclSourceElementRequestVisitor original) { + @Override + public ExitFromType getExitExtended(MethodDeclaration method, TclSourceElementRequestVisitor original) { String tName = method.getDeclaringTypeName(); if (tName == null) { tName = ""; @@ -59,8 +60,8 @@ public class IncrTclSourceElementRequestVisitorExtension implements return original.resolveType(method, tName + "::dummy", false); } - public boolean extendedExitRequired(MethodDeclaration method, - TclSourceElementRequestVisitor original) { + @Override + public boolean extendedExitRequired(MethodDeclaration method, TclSourceElementRequestVisitor original) { if (method instanceof IncrTclBodyDeclaration) { return true; } @@ -68,8 +69,8 @@ public class IncrTclSourceElementRequestVisitorExtension implements // != 0; } - public ExitFromType processField(FieldDeclaration decl, - TclSourceElementRequestVisitor original) { + @Override + public ExitFromType processField(FieldDeclaration decl, TclSourceElementRequestVisitor original) { // TclParseUtil.getScopeParent(decl,) MethodDeclaration method = original.getCurrentMethod(); if (method != null && method instanceof IncrTclBodyDeclaration) { @@ -83,17 +84,17 @@ public class IncrTclSourceElementRequestVisitorExtension implements return null; } - public boolean skipMethod(MethodDeclaration method, - TclSourceElementRequestVisitor tclSourceElementRequestVisitor) { + @Override + public boolean skipMethod(MethodDeclaration method, TclSourceElementRequestVisitor tclSourceElementRequestVisitor) { // if (method instanceof IncrTclBodyDeclaration) { // return true; // } return false; } - private static final int MOD_CONSTRUCTOR = IIncrTclModifiers.AccIncrTcl - | IIncrTclModifiers.AccConstructor; + private static final int MOD_CONSTRUCTOR = IIncrTclModifiers.AccIncrTcl | IIncrTclModifiers.AccConstructor; + @Override public boolean isConstructor(MethodDeclaration declaration) { if (declaration instanceof ExtendedTclMethodDeclaration && (declaration.getModifiers() & MOD_CONSTRUCTOR) == MOD_CONSTRUCTOR) { diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclConfigBody.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclConfigBody.java index 0fa51b85..a3fb755e 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclConfigBody.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclConfigBody.java @@ -38,6 +38,7 @@ public class IncrTclConfigBody extends Declaration { return this.body; } + @Override public void traverse(ASTVisitor visitor) throws Exception { if (visitor.visit(this)) { // Body diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemble.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemble.java index 8201dd52..8a1b9116 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemble.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemble.java @@ -8,43 +8,44 @@ import org.eclipse.dltk.ast.ASTVisitor; import org.eclipse.dltk.ast.declarations.Declaration; /** - * + * * ensemble ensName ?command arg arg...? or ensemble ensName { - * + * * part partName args body - * + * * ... - * + * * ensemble partName { - * + * * part subPartName args body - * + * * part subPartName args body - * + * * ... } } - * + * */ public class IncrTclEnsemble extends Declaration { - private List ensembles; - private List parts; + private List<IncrTclEnsemble> ensembles; + private List<IncrTclEnsemblePart> parts; public IncrTclEnsemble(int start, int end) { super(start, end); } + @Override public void traverse(ASTVisitor visitor) throws Exception { if (visitor.visit(this)) { if (this.ensembles != null) { - Iterator it = this.ensembles.iterator(); + Iterator<IncrTclEnsemble> it = this.ensembles.iterator(); while (it.hasNext()) { - IncrTclEnsemble arg = (IncrTclEnsemble) it.next(); + IncrTclEnsemble arg = it.next(); arg.traverse(visitor); } } if (this.parts != null) { - Iterator it = this.parts.iterator(); + Iterator<IncrTclEnsemblePart> it = this.parts.iterator(); while (it.hasNext()) { - IncrTclEnsemblePart arg = (IncrTclEnsemblePart) it.next(); + IncrTclEnsemblePart arg = it.next(); arg.traverse(visitor); } } @@ -59,29 +60,29 @@ public class IncrTclEnsemble extends Declaration { private void initialize() { if (this.ensembles == null) { - this.ensembles = new ArrayList(); + this.ensembles = new ArrayList<>(); } if (this.parts == null) { - this.parts = new ArrayList(); + this.parts = new ArrayList<>(); } } - public List getEnsembles() { + public List<IncrTclEnsemble> getEnsembles() { initialize(); return ensembles; } - public void setEnsembles(List ensembles) { + public void setEnsembles(List<IncrTclEnsemble> ensembles) { this.ensembles = ensembles; initialize(); } - public List getParts() { + public List<IncrTclEnsemblePart> getParts() { initialize(); return parts; } - public void setParts(List parts) { + public void setParts(List<IncrTclEnsemblePart> parts) { this.parts = parts; initialize(); } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemblePart.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemblePart.java index 2ab7eee6..8fbc1697 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemblePart.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclEnsemblePart.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.eclipse.dltk.ast.ASTNode; import org.eclipse.dltk.ast.ASTVisitor; import org.eclipse.dltk.ast.declarations.Argument; import org.eclipse.dltk.ast.declarations.Declaration; @@ -15,7 +16,7 @@ import org.eclipse.dltk.ast.statements.Block; public class IncrTclEnsemblePart extends Declaration { private Block body; - protected List arguments = new ArrayList(); + protected List<Argument> arguments = new ArrayList<>(); public IncrTclEnsemblePart(int start, int end) { super(start, end); @@ -35,7 +36,7 @@ public class IncrTclEnsemblePart extends Declaration { } } - public List getStatements() { + public List<ASTNode> getStatements() { if (this.body == null) { this.body = new Block(this.sourceStart(), this.sourceEnd()); } @@ -46,13 +47,14 @@ public class IncrTclEnsemblePart extends Declaration { return this.body; } + @Override public void traverse(ASTVisitor visitor) throws Exception { if (visitor.visit(this)) { // Arguments if (this.arguments != null) { - Iterator it = this.arguments.iterator(); + Iterator<Argument> it = this.arguments.iterator(); while (it.hasNext()) { - Argument arg = (Argument) it.next(); + Argument arg = it.next(); arg.traverse(visitor); } } @@ -65,7 +67,7 @@ public class IncrTclEnsemblePart extends Declaration { } } - public List getArguments() { + public List<Argument> getArguments() { return this.arguments; } @@ -73,7 +75,7 @@ public class IncrTclEnsemblePart extends Declaration { this.arguments.add(arg); } - public void acceptArguments(List arguments) { + public void acceptArguments(List<Argument> arguments) { this.arguments = arguments; } } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclMethodCallStatement.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclMethodCallStatement.java index 6746c95c..840c9c56 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclMethodCallStatement.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/ast/IncrTclMethodCallStatement.java @@ -8,12 +8,13 @@ import org.eclipse.dltk.ast.references.SimpleReference; public class IncrTclMethodCallStatement extends CallExpression { private FieldDeclaration instanceVariable; - public IncrTclMethodCallStatement(int start, int end, SimpleReference name, - FieldDeclaration var, CallArgumentsList args) { + public IncrTclMethodCallStatement(int start, int end, SimpleReference name, FieldDeclaration var, + CallArgumentsList args) { super(start, end, var, name, args); this.instanceVariable = var; } + @Override public int getKind() { return 0; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclBodyCommandProcessor.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclBodyCommandProcessor.java index 8d52eb7a..fd2ec2d4 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclBodyCommandProcessor.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclBodyCommandProcessor.java @@ -24,14 +24,13 @@ public class IncrTclBodyCommandProcessor extends AbstractTclCommandProcessor { public IncrTclBodyCommandProcessor() { } - public ASTNode process(TclStatement statement, ITclParser parser, - ASTNode parent) { + @Override + public ASTNode process(TclStatement statement, ITclParser parser, ASTNode parent) { if (statement == null || (statement.getCount() == 0)) { return null; } if (statement.getCount() < 4) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(parent, statement); return statement; @@ -40,8 +39,7 @@ public class IncrTclBodyCommandProcessor extends AbstractTclCommandProcessor { String sName = IncrTclUtils.extractMethodName(procName); if (sName == null || sName.length() == 0) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(parent, statement); return statement; @@ -51,12 +49,11 @@ public class IncrTclBodyCommandProcessor extends AbstractTclCommandProcessor { List arguments = IncrTclUtils.extractMethodArguments(procArguments); - IncrTclBodyDeclaration method = new IncrTclBodyDeclaration(statement - .sourceStart(), statement.sourceEnd()); + IncrTclBodyDeclaration method = new IncrTclBodyDeclaration(statement.sourceStart(), statement.sourceEnd()); int index = sName.lastIndexOf("::"); if (index == -1) { - this.report(parser, "Wrong Class name", statement.sourceStart(), - statement.sourceEnd(), ProblemSeverities.Error); + this.report(parser, "Wrong Class name", statement.sourceStart(), statement.sourceEnd(), + ProblemSeverities.Error); return statement; } String className = sName.substring(0, index); @@ -73,15 +70,12 @@ public class IncrTclBodyCommandProcessor extends AbstractTclCommandProcessor { // method.setModifier(IIncrTclModifiers.AccIncrTcl | // IIncrTclModifiers.AccPublic); if (TclVisibilityUtils.isPrivate(sName)) { - method.setModifier(IIncrTclModifiers.AccIncrTcl - | Modifiers.AccPrivate); + method.setModifier(IIncrTclModifiers.AccIncrTcl | Modifiers.AccPrivate); } else { - method.setModifier(IIncrTclModifiers.AccIncrTcl - | Modifiers.AccPublic); + method.setModifier(IIncrTclModifiers.AccIncrTcl | Modifiers.AccPublic); } ModuleDeclaration module = this.getModuleDeclaration(); - TypeDeclaration possiblyType = TclParseUtil.findTclTypeDeclarationFrom( - module, parent, className, false); + TypeDeclaration possiblyType = TclParseUtil.findTclTypeDeclarationFrom(module, parent, className, false); if (possiblyType != null) { MethodDeclaration[] methods = possiblyType.getMethods(); boolean found = false; @@ -89,8 +83,7 @@ public class IncrTclBodyCommandProcessor extends AbstractTclCommandProcessor { if (methods[i].getName().equals(methodName)) { method.setModifiers(methods[i].getModifiers()); method.setDeclaringType(possiblyType); - method.setDeclaringTypeName(TclParseUtil.getElementFQN( - possiblyType, "::", module)); + method.setDeclaringTypeName(TclParseUtil.getElementFQN(possiblyType, "::", module)); this.addToParent(parent, method); found = true; break; @@ -99,16 +92,14 @@ public class IncrTclBodyCommandProcessor extends AbstractTclCommandProcessor { if (!found) { // May be not correct this.addToParent(parent, method); - this.report(parser, "Function " + method.getName() - + " is not defined in class " + possiblyType.getName(), - statement.sourceStart(), statement.sourceEnd(), - ProblemSeverities.Warning); + this.report(parser, + "Function " + method.getName() + " is not defined in class " + possiblyType.getName(), + statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Warning); } } else { if (!IncrTclClassesManager.getDefault().isClass(className)) { - this.report(parser, "Body declaration for unknown class", - statement.sourceStart(), statement.sourceEnd(), - ProblemSeverities.Error); + this.report(parser, "Body declaration for unknown class", statement.sourceStart(), + statement.sourceEnd(), ProblemSeverities.Error); } this.addToParent(parent, method); } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassCommandProcessor.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassCommandProcessor.java index 5a235731..ece9eac4 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassCommandProcessor.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassCommandProcessor.java @@ -21,10 +21,9 @@ import org.eclipse.dltk.tcl.core.TclParseUtil; import org.eclipse.dltk.tcl.core.ast.ExtendedTclMethodDeclaration; public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { - public ASTNode process(TclStatement statement, ITclParser parser, - ASTNode parent) { - if (statement == null - || (statement != null && statement.getCount() == 0)) { + @Override + public ASTNode process(TclStatement statement, ITclParser parser, ASTNode parent) { + if (statement == null || (statement != null && statement.getCount() == 0)) { return null; } if (statement.getCount() != 3) { @@ -33,13 +32,11 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { } Expression classNameExpr = statement.getAt(1); Expression blockExpr = statement.getAt(2); - if (classNameExpr instanceof SimpleReference - && blockExpr instanceof TclBlockExpression) { + if (classNameExpr instanceof SimpleReference && blockExpr instanceof TclBlockExpression) { TclBlockExpression block = (TclBlockExpression) blockExpr; - TypeDeclaration type = new TypeDeclaration( - ((SimpleReference) classNameExpr).getName(), classNameExpr - .sourceStart(), classNameExpr.sourceEnd(), - statement.sourceStart(), statement.sourceEnd()); + TypeDeclaration type = new TypeDeclaration(((SimpleReference) classNameExpr).getName(), + classNameExpr.sourceStart(), classNameExpr.sourceEnd(), statement.sourceStart(), + statement.sourceEnd()); type.setModifiers(IIncrTclModifiers.AccIncrTcl); this.addToParent(parent, type); // Report type to list of types. @@ -52,22 +49,17 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { TclStatement st = (TclStatement) nde; Expression commandName = st.getAt(0); if (commandName instanceof SimpleReference) { - String commandNameStr = ((SimpleReference) commandName) - .getName(); + String commandNameStr = ((SimpleReference) commandName).getName(); if ("inherit".equals(commandNameStr)) { handleInherit(st, type, parser); } else if ("public".equals(commandNameStr)) { - handleWithModifierSub(st, type, - Modifiers.AccPublic, parser); + handleWithModifierSub(st, type, Modifiers.AccPublic, parser); } else if ("protected".equals(commandNameStr)) { - handleWithModifierSub(st, type, - Modifiers.AccProtected, parser); + handleWithModifierSub(st, type, Modifiers.AccProtected, parser); } else if ("private".equals(commandNameStr)) { - handleWithModifierSub(st, type, - Modifiers.AccPrivate, parser); + handleWithModifierSub(st, type, Modifiers.AccPrivate, parser); } else { - handleWithModifier(commandNameStr, st, type, - Modifiers.AccPrivate, parser); + handleWithModifier(commandNameStr, st, type, Modifiers.AccPrivate, parser); } } } @@ -77,33 +69,29 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { return null; } - private void handleDestructor(TclStatement statement, TypeDeclaration type, - ITclParser parser) { + private void handleDestructor(TclStatement statement, TypeDeclaration type, ITclParser parser) { if (statement.getCount() != 2) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(type, statement); return; } Expression procCode = statement.getAt(1); - ExtendedTclMethodDeclaration method = new ExtendedTclMethodDeclaration( - statement.sourceStart(), statement.sourceEnd()); + ExtendedTclMethodDeclaration method = new ExtendedTclMethodDeclaration(statement.sourceStart(), + statement.sourceEnd()); method.setName("destructor"); Expression o = statement.getAt(0); method.setNameStart(o.sourceStart()); method.setNameEnd(o.sourceEnd()); - method.setModifier(IIncrTclModifiers.AccIncrTcl - | IIncrTclModifiers.AccDestructor); + method.setModifier(IIncrTclModifiers.AccIncrTcl | IIncrTclModifiers.AccDestructor); method.setDeclaringType(type); IncrTclUtils.parseBlockAdd(parser, procCode, method); type.getMethodList().add(method); this.addToParent(type, method); } - private void handleWithModifierSub(TclStatement statement, - TypeDeclaration type, int modifier, ITclParser parser) { + private void handleWithModifierSub(TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { List expressions = statement.getExpressions(); List newExpressions = new ArrayList(); newExpressions.addAll(expressions); @@ -113,16 +101,13 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { TclStatement sub = new TclStatement(newExpressions); Expression commandName = sub.getAt(0); if (commandName instanceof SimpleReference) { - handleWithModifier(((SimpleReference) commandName).getName(), sub, - type, modifier, parser); + handleWithModifier(((SimpleReference) commandName).getName(), sub, type, modifier, parser); } } - private void handleConstructor(TclStatement statement, - TypeDeclaration type, ITclParser parser) { + private void handleConstructor(TclStatement statement, TypeDeclaration type, ITclParser parser) { if (statement.getCount() < 3) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(type, statement); return; @@ -139,30 +124,27 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { List arguments = IncrTclUtils.extractMethodArguments(procArguments); - ExtendedTclMethodDeclaration method = new ExtendedTclMethodDeclaration( - statement.sourceStart(), statement.sourceEnd()); + ExtendedTclMethodDeclaration method = new ExtendedTclMethodDeclaration(statement.sourceStart(), + statement.sourceEnd()); method.setDeclaringType(type); method.setName("constructor"); Expression o = statement.getAt(0); method.setNameStart(o.sourceStart()); method.setNameEnd(o.sourceEnd()); method.acceptArguments(arguments); - method.setModifier(IIncrTclModifiers.AccIncrTcl - | IIncrTclModifiers.AccConstructor); + method.setModifier(IIncrTclModifiers.AccIncrTcl | IIncrTclModifiers.AccConstructor); IncrTclUtils.parseBlockAdd(parser, procCode, method); type.getMethodList().add(method); this.addToParent(type, method); } - private void handleWithModifier(String commandNameStr, - TclStatement statement, TypeDeclaration type, int modifier, + private void handleWithModifier(String commandNameStr, TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { if ("method".equals(commandNameStr)) { handleMethod(statement, type, modifier, parser); } else if ("proc".equals(commandNameStr)) { - handleMethod(statement, type, modifier - | IIncrTclModifiers.AccIncrTclProc, parser); + handleMethod(statement, type, modifier | IIncrTclModifiers.AccIncrTclProc, parser); } else if ("variable".equals(commandNameStr)) { handleVariable(statement, type, modifier, parser); } else if ("common".equals(commandNameStr)) { @@ -178,17 +160,13 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { } } - private void handleSet(TclStatement statement, TypeDeclaration type, - int modifier, ITclParser parser) { + private void handleSet(TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { processVariable(statement, type, modifier, parser); } - private void processVariable(TclStatement statement, TypeDeclaration type, - int modifier, ITclParser parser) { + private void processVariable(TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { if (statement.getCount() < 2) { - this.report(parser, - "Syntax error: at least one argument expected.", statement, - ProblemSeverities.Error); + this.report(parser, "Syntax error: at least one argument expected.", statement, ProblemSeverities.Error); return; } Expression variableName = statement.getAt(1); @@ -200,9 +178,8 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { } SimpleReference variable = TclParseUtil.makeVariable(variableName); if (variable != null) { - IncrTclFieldDeclaration var = new IncrTclFieldDeclaration(variable - .getName(), variable.sourceStart(), variable.sourceEnd(), - statement.sourceStart(), statement.sourceEnd()); + IncrTclFieldDeclaration var = new IncrTclFieldDeclaration(variable.getName(), variable.sourceStart(), + variable.sourceEnd(), statement.sourceStart(), statement.sourceEnd()); var.setModifier(IIncrTclModifiers.AccIncrTcl | modifier); var.setDeclaringType(type); this.addToParent(type, var); @@ -210,16 +187,13 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { } } - private void handleArray(TclStatement statement, TypeDeclaration type, - int modifier) { + private void handleArray(TclStatement statement, TypeDeclaration type, int modifier) { // processVariable(statement, type, modifier, parser); } - private void handleCommon(TclStatement statement, TypeDeclaration type, - int modifier, ITclParser parser) { + private void handleCommon(TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { if (statement.getCount() < 2) { - this.report(parser, "Syntax error: one argument expected.", - statement, ProblemSeverities.Error); + this.report(parser, "Syntax error: one argument expected.", statement, ProblemSeverities.Error); return; } Expression variableName = statement.getAt(1); @@ -228,25 +202,21 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { } SimpleReference variable = TclParseUtil.makeVariable(variableName); if (variable != null) { - IncrTclFieldDeclaration var = new IncrTclFieldDeclaration(variable - .getName(), variable.sourceStart(), variable.sourceEnd(), - statement.sourceStart(), statement.sourceEnd()); + IncrTclFieldDeclaration var = new IncrTclFieldDeclaration(variable.getName(), variable.sourceStart(), + variable.sourceEnd(), statement.sourceStart(), statement.sourceEnd()); var.setModifier(IIncrTclModifiers.AccIncrTcl | modifier); var.setDeclaringType(type); this.addToParent(type, var); } } - private void handleVariable(TclStatement statement, TypeDeclaration type, - int modifier, ITclParser parser) { + private void handleVariable(TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { processVariable(statement, type, modifier, parser); } - private void handleMethod(TclStatement statement, TypeDeclaration type, - int modifier, ITclParser parser) { + private void handleMethod(TclStatement statement, TypeDeclaration type, int modifier, ITclParser parser) { if (statement.getCount() < 2) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(type, statement); return; @@ -255,8 +225,7 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { String sName = IncrTclUtils.extractMethodName(procName); if (sName == null || sName.length() == 0) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(type, statement); return; @@ -272,8 +241,7 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { List arguments = IncrTclUtils.extractMethodArguments(procArguments); - IncrTclMethodDeclaration method = new IncrTclMethodDeclaration( - statement.sourceStart(), statement.sourceEnd()); + IncrTclMethodDeclaration method = new IncrTclMethodDeclaration(statement.sourceStart(), statement.sourceEnd()); method.setName(sName); method.setNameStart(procName.sourceStart()); method.setNameEnd(procName.sourceEnd()); @@ -291,8 +259,7 @@ public class IncrTclClassCommandProcessor extends AbstractTclCommandProcessor { this.addToParent(type, method); } - private void handleInherit(TclStatement statement, TypeDeclaration type, - ITclParser parser) { + private void handleInherit(TclStatement statement, TypeDeclaration type, ITclParser parser) { for (int i = 1; i < statement.getCount(); i++) { Expression expr = statement.getAt(i); if (expr instanceof SimpleReference) { diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassMethodCallCommandProcessor.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassMethodCallCommandProcessor.java index b24917b5..41aec75a 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassMethodCallCommandProcessor.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassMethodCallCommandProcessor.java @@ -11,14 +11,13 @@ import org.eclipse.dltk.tcl.ast.TclStatement; import org.eclipse.dltk.tcl.core.AbstractTclCommandProcessor; import org.eclipse.dltk.tcl.core.ITclParser; -public class IncrTclClassMethodCallCommandProcessor extends - AbstractTclCommandProcessor { +public class IncrTclClassMethodCallCommandProcessor extends AbstractTclCommandProcessor { public IncrTclClassMethodCallCommandProcessor() { } - public ASTNode process(TclStatement statement, ITclParser parser, - ASTNode parent) { + @Override + public ASTNode process(TclStatement statement, ITclParser parser, ASTNode parent) { Object param = this.getDetectedParameter(); if (param == null || !(param instanceof FieldDeclaration)) { return null; @@ -33,14 +32,13 @@ public class IncrTclClassMethodCallCommandProcessor extends SimpleReference name = (SimpleReference) nameExpr; CallArgumentsList args = null; if (statement.getCount() > 2) { - args = new CallArgumentsList(name.sourceEnd() + 1, statement - .sourceEnd()); + args = new CallArgumentsList(name.sourceEnd() + 1, statement.sourceEnd()); for (int i = 2; i < statement.getCount(); i++) { args.addNode(statement.getAt(i)); } } - IncrTclMethodCallStatement call = new IncrTclMethodCallStatement(statement - .sourceStart(), statement.sourceEnd(), name, inst, args); + IncrTclMethodCallStatement call = new IncrTclMethodCallStatement(statement.sourceStart(), statement.sourceEnd(), + name, inst, args); call.setInstNameRef((SimpleReference) statement.getAt(0)); call.setStart(statement.sourceStart()); call.setEnd(statement.sourceEnd()); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassNewInstanceCommandProcessor.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassNewInstanceCommandProcessor.java index 4cc88f87..d8d326c2 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassNewInstanceCommandProcessor.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclClassNewInstanceCommandProcessor.java @@ -13,17 +13,15 @@ import org.eclipse.dltk.tcl.ast.TclStatement; import org.eclipse.dltk.tcl.core.AbstractTclCommandProcessor; import org.eclipse.dltk.tcl.core.ITclParser; -public class IncrTclClassNewInstanceCommandProcessor extends - AbstractTclCommandProcessor { +public class IncrTclClassNewInstanceCommandProcessor extends AbstractTclCommandProcessor { public IncrTclClassNewInstanceCommandProcessor() { } - public ASTNode process(TclStatement statement, ITclParser parser, - ASTNode parent) { + @Override + public ASTNode process(TclStatement statement, ITclParser parser, ASTNode parent) { Object param = this.getDetectedParameter(); - if (param == null - || !(param instanceof TypeDeclaration || param instanceof IncrTclGlobalClassParameter)) { + if (param == null || !(param instanceof TypeDeclaration || param instanceof IncrTclGlobalClassParameter)) { return null; } @@ -33,17 +31,14 @@ public class IncrTclClassNewInstanceCommandProcessor extends Expression e = statement.getAt(1); String name = extractSimpleReference(e); if (name == null) { - this.report(parser, - "An instance name expected after class name.", e, - ProblemSeverities.Error); + this.report(parser, "An instance name expected after class name.", e, ProblemSeverities.Error); return null; } - + if (param instanceof TypeDeclaration) { TypeDeclaration type = (TypeDeclaration) param; - IncrTclInstanceVariable var = new IncrTclInstanceVariable( - name, e.sourceStart(), e.sourceEnd(), statement - .sourceStart(), statement.sourceEnd()); + IncrTclInstanceVariable var = new IncrTclInstanceVariable(name, e.sourceStart(), e.sourceEnd(), + statement.sourceStart(), statement.sourceEnd()); var.setClassInstanceName((SimpleReference) statement.getAt(0)); var.setDeclaringType(type); var.setModifier(IIncrTclModifiers.AccIncrTcl); @@ -51,9 +46,8 @@ public class IncrTclClassNewInstanceCommandProcessor extends return var; } else { IncrTclGlobalClassParameter classParam = (IncrTclGlobalClassParameter) param; - IncrTclExInstanceVariable var = new IncrTclExInstanceVariable( - name, e.sourceStart(), e.sourceEnd(), statement - .sourceStart(), statement.sourceEnd()); + IncrTclExInstanceVariable var = new IncrTclExInstanceVariable(name, e.sourceStart(), e.sourceEnd(), + statement.sourceStart(), statement.sourceEnd()); var.setClassInstanceName((SimpleReference) statement.getAt(0)); var.setDeclaringClassParameter(classParam); var.setModifier(IIncrTclModifiers.AccIncrTcl); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclConfigBodyCommandProcessor.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclConfigBodyCommandProcessor.java index 8f923747..ab1255b4 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclConfigBodyCommandProcessor.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclConfigBodyCommandProcessor.java @@ -10,21 +10,18 @@ import org.eclipse.dltk.tcl.ast.TclStatement; import org.eclipse.dltk.tcl.core.AbstractTclCommandProcessor; import org.eclipse.dltk.tcl.core.ITclParser; -public class IncrTclConfigBodyCommandProcessor extends - AbstractTclCommandProcessor { +public class IncrTclConfigBodyCommandProcessor extends AbstractTclCommandProcessor { public IncrTclConfigBodyCommandProcessor() { } - public ASTNode process(TclStatement statement, ITclParser parser, - ASTNode parent) { - if (statement == null - || (statement != null && statement.getCount() == 0)) { + @Override + public ASTNode process(TclStatement statement, ITclParser parser, ASTNode parent) { + if (statement == null || (statement != null && statement.getCount() == 0)) { return null; } if (statement.getCount() < 3) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(parent, statement); return statement; @@ -33,16 +30,14 @@ public class IncrTclConfigBodyCommandProcessor extends String sName = IncrTclUtils.extractMethodName(procName); if (sName == null || sName.length() == 0) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(parent, statement); return statement; } Expression procCode = statement.getAt(2); - IncrTclConfigBody configBody = new IncrTclConfigBody(statement - .sourceStart(), statement.sourceEnd()); + IncrTclConfigBody configBody = new IncrTclConfigBody(statement.sourceStart(), statement.sourceEnd()); configBody.setName(sName); configBody.setNameStart(procName.sourceStart()); configBody.setNameEnd(procName.sourceEnd()); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclEnsembleCommandProcessor.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclEnsembleCommandProcessor.java index ac44a618..7fe5d7b7 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclEnsembleCommandProcessor.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/processors/IncrTclEnsembleCommandProcessor.java @@ -15,28 +15,24 @@ import org.eclipse.dltk.tcl.ast.expressions.TclBlockExpression; import org.eclipse.dltk.tcl.core.AbstractTclCommandProcessor; import org.eclipse.dltk.tcl.core.ITclParser; -public class IncrTclEnsembleCommandProcessor extends - AbstractTclCommandProcessor { +public class IncrTclEnsembleCommandProcessor extends AbstractTclCommandProcessor { public IncrTclEnsembleCommandProcessor() { } - public ASTNode process(TclStatement statement, ITclParser parser, - ASTNode parent) { - if (statement == null - || (statement != null && statement.getCount() == 0)) { + @Override + public ASTNode process(TclStatement statement, ITclParser parser, ASTNode parent) { + if (statement == null || (statement != null && statement.getCount() == 0)) { return null; } return processEnsemble(parent, statement, parser); } - private ASTNode processEnsemble(ASTNode parent, TclStatement statement, - ITclParser parser) { + private ASTNode processEnsemble(ASTNode parent, TclStatement statement, ITclParser parser) { Expression classNameExpr = statement.getAt(1); Expression blockExpr = statement.getAt(2); if (classNameExpr instanceof SimpleReference) { - IncrTclEnsemble ensamble = new IncrTclEnsemble(statement - .sourceStart(), statement.sourceEnd()); + IncrTclEnsemble ensamble = new IncrTclEnsemble(statement.sourceStart(), statement.sourceEnd()); ensamble.setName(((SimpleReference) classNameExpr).getName()); ensamble.setNameStart(classNameExpr.sourceStart()); ensamble.setNameEnd(classNameExpr.sourceEnd()); @@ -53,8 +49,7 @@ public class IncrTclEnsembleCommandProcessor extends TclStatement st = (TclStatement) nde; Expression commandName = st.getAt(0); if (commandName instanceof SimpleReference) { - String commandNameValue = ((SimpleReference) commandName) - .getName(); + String commandNameValue = ((SimpleReference) commandName).getName(); if (commandNameValue.equals("ensemble")) { processEnsemble(ensamble, st, parser); } else if (commandNameValue.equals("part")) { @@ -64,8 +59,8 @@ public class IncrTclEnsembleCommandProcessor extends } } } else { - List expressions = statement.getExpressions(); - List subList = expressions.subList(2, expressions.size()); + List<ASTNode> expressions = statement.getExpressions(); + List<ASTNode> subList = expressions.subList(2, expressions.size()); TclStatement subSt = new TclStatement(subList); processPart(ensamble, subSt, parser); } @@ -74,11 +69,9 @@ public class IncrTclEnsembleCommandProcessor extends return null; } - private void processPart(IncrTclEnsemble ensamble, TclStatement statement, - ITclParser parser) { + private void processPart(IncrTclEnsemble ensamble, TclStatement statement, ITclParser parser) { if (statement.getCount() < 2) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); addToParent(ensamble, statement); return; @@ -87,8 +80,7 @@ public class IncrTclEnsembleCommandProcessor extends String sName = IncrTclUtils.extractMethodName(procName); if (sName == null || sName.length() == 0) { - this.report(parser, "Wrong number of arguments", statement - .sourceStart(), statement.sourceEnd(), + this.report(parser, "Wrong number of arguments", statement.sourceStart(), statement.sourceEnd(), ProblemSeverities.Error); return; } @@ -103,30 +95,27 @@ public class IncrTclEnsembleCommandProcessor extends List arguments = IncrTclUtils.extractMethodArguments(procArguments); - IncrTclEnsemblePart part = new IncrTclEnsemblePart(statement - .sourceStart(), statement.sourceEnd()); + IncrTclEnsemblePart part = new IncrTclEnsemblePart(statement.sourceStart(), statement.sourceEnd()); part.setName(sName); part.setNameStart(procName.sourceStart()); part.setNameEnd(procName.sourceEnd()); part.acceptArguments(arguments); part.setModifier(IIncrTclModifiers.AccIncrTcl); if (procCode != null) { - Block block = new Block(procCode.sourceStart(), procCode - .sourceEnd()); + Block block = new Block(procCode.sourceStart(), procCode.sourceEnd()); part.acceptBody(block); IncrTclUtils.parseAddToBlock(parser, procCode, block); } this.addToParent(ensamble, part); } + @Override public void addToParent(ASTNode parent, ASTNode node) { - if (parent instanceof IncrTclEnsemble - && node instanceof IncrTclEnsemble) { + if (parent instanceof IncrTclEnsemble && node instanceof IncrTclEnsemble) { IncrTclEnsemble ensemble = (IncrTclEnsemble) parent; ensemble.addEnsamble((IncrTclEnsemble) node); } - if (parent instanceof IncrTclEnsemble - && node instanceof IncrTclEnsemblePart) { + if (parent instanceof IncrTclEnsemble && node instanceof IncrTclEnsemblePart) { IncrTclEnsemble ensemble = (IncrTclEnsemble) parent; ensemble.addPart((IncrTclEnsemblePart) node); } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/CommandImpl.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/CommandImpl.java index 2b1c60fd..4436901c 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/CommandImpl.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/CommandImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 xored software, Inc. + * Copyright (c) 2010, 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 @@ -23,26 +23,32 @@ class CommandImpl implements ICommand { this.command = cmd; } + @Override public TclArgument getName() { return command.getName(); } + @Override public int getEnd() { return command.getEnd(); } + @Override public int getStart() { return command.getStart(); } + @Override public TclArgument getArgument(int index) { return command.getArguments().get(index); } + @Override public int getArgumentCount() { return command.getArguments().size(); } + @Override public TclArgument[] getArguments() { final EList<TclArgument> args = command.getArguments(); return args.toArray(new TclArgument[args.size()]); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclBody.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclBody.java index 24fbe3a5..f6cef5af 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclBody.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclBody.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -32,8 +32,8 @@ import org.eclipse.dltk.tcl.structure.TclModelProblem; public class IncrTclBody extends AbstractTclCommandModelBuilder { - public boolean process(TclCommand command, ITclModelBuildContext context) - throws TclModelProblem { + @Override + public boolean process(TclCommand command, ITclModelBuildContext context) throws TclModelProblem { if (command.getArguments().size() != 3) { throw new TclModelProblem("Wrong number of arguments"); } @@ -54,11 +54,9 @@ public class IncrTclBody extends AbstractTclCommandModelBuilder { clazz = names.resolve(className); } int procModifiers = IIncrTclModifiers.AccIncrTcl - | (TclVisibilityUtils.isPrivate(procName) ? Modifiers.AccPrivate - : Modifiers.AccPublic); + | (TclVisibilityUtils.isPrivate(procName) ? Modifiers.AccPrivate : Modifiers.AccPublic); if (clazz == null) { - report(context, nameArg, "Class not found", - ProblemSeverities.Warning); + report(context, nameArg, "Class not found", ProblemSeverities.Warning); } else { className = clazz.getName(); if (className.startsWith("::")) { @@ -68,8 +66,7 @@ public class IncrTclBody extends AbstractTclCommandModelBuilder { if (method != null) { procModifiers = method.getModifiers(); } else { - report(context, nameArg, "Method not found", - ProblemSeverities.Warning); + report(context, nameArg, "Method not found", ProblemSeverities.Warning); } } TypeInfo ti = new TypeInfo(); @@ -80,15 +77,14 @@ public class IncrTclBody extends AbstractTclCommandModelBuilder { if (clazz != null) { ti.superclasses = clazz.getSuperClasses(); } - ITclTypeHandler resolvedType = context.get(ITclTypeResolver.class) - .resolveType(ti, command.getEnd(), className); + ITclTypeHandler resolvedType = context.get(ITclTypeResolver.class).resolveType(ti, command.getEnd(), className); MethodInfo mi = new MethodInfo(); mi.declarationStart = command.getStart(); mi.nameSourceStart = nameArg.getStart(); mi.nameSourceEnd = nameArg.getEnd() - 1; mi.modifiers = procModifiers; mi.name = procName; - List<Parameter> parameters = new ArrayList<Parameter>(); + List<Parameter> parameters = new ArrayList<>(); parseRawParameters(command.getArguments().get(1), parameters); fillParameters(mi, parameters); context.getRequestor().enterMethodRemoveSame(mi); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclClass.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclClass.java index 7a3fd3ea..79cd4dbc 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclClass.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclClass.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -21,10 +21,10 @@ import org.eclipse.dltk.compiler.IElementRequestor.TypeInfo; import org.eclipse.dltk.itcl.internal.core.IIncrTclModifiers; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IClass; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMember; -import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMethod; -import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IVariable; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMember.Visibility; +import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMethod; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMethod.MethodKind; +import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IVariable; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IVariable.VariableKind; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.impl.ClassImpl; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.impl.Method; @@ -40,8 +40,8 @@ import org.eclipse.dltk.tcl.structure.TclModelProblem; public class IncrTclClass extends AbstractTclCommandModelBuilder { - public boolean process(TclCommand command, ITclModelBuildContext context) - throws TclModelProblem { + @Override + public boolean process(TclCommand command, ITclModelBuildContext context) throws TclModelProblem { if (command.getArguments().size() != 2) { return false; } @@ -51,8 +51,7 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { } final ClassImpl clazz = new ClassImpl(); // TODO parse without processors - final Script classBody = context.parse(command.getArguments().get(1), - ITclModelBuildContext.NO_TRAVERSE); + final Script classBody = context.parse(command.getArguments().get(1), ITclModelBuildContext.NO_TRAVERSE); processContent(clazz, classBody.getCommands(), context); final TypeInfo ti = new TypeInfo(); ti.declarationStart = command.getStart(); @@ -60,8 +59,8 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { ti.nameSourceEnd = className.getEnd() - 1; ti.modifiers = IIncrTclModifiers.AccIncrTcl; ti.superclasses = clazz.getSuperClasses(); - ITclTypeHandler resolvedType = context.get(ITclTypeResolver.class) - .resolveType(ti, command.getEnd(), asSymbol(className)); + ITclTypeHandler resolvedType = context.get(ITclTypeResolver.class).resolveType(ti, command.getEnd(), + asSymbol(className)); context.enterNamespace(resolvedType); clazz.setName(resolvedType.getNamespace()); IncrTclNames.create(context).addType(clazz); @@ -98,15 +97,13 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { return false; } - private void processContent(IClass clazz, List<TclCommand> bodyCommands, - ITclModelBuildContext context) { + private void processContent(IClass clazz, List<TclCommand> bodyCommands, ITclModelBuildContext context) { for (TclCommand cmd : bodyCommands) { processContent(clazz, new CommandImpl(cmd), context); } } - private void processContent(IClass clazz, ICommand cmd, - ITclModelBuildContext context) { + private void processContent(IClass clazz, ICommand cmd, ITclModelBuildContext context) { TclArgument cmdName = cmd.getName(); if (isSymbol(cmdName)) { Handler handler = handlers.get(asSymbol(cmdName)); @@ -117,72 +114,24 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { } private interface Handler { - void handle(IClass clazz, ICommand command, - ITclModelBuildContext context); + void handle(IClass clazz, ICommand command, ITclModelBuildContext context); } - private Map<String, Handler> handlers = new HashMap<String, Handler>(); + private Map<String, Handler> handlers = new HashMap<>(); { - handlers.put("inherit", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleInherit(clazz, command); - } - }); - handlers.put("constructor", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleConstructor(clazz, command); - } - }); - handlers.put("destructor", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleDestructor(clazz, command); - } - }); - handlers.put("method", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleProc(clazz, command, MethodKind.METHOD); - } - }); - handlers.put("proc", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleProc(clazz, command, MethodKind.PROC); - } - }); - handlers.put("variable", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleVariable(clazz, command, VariableKind.VARIABLE); - } - }); - handlers.put("common", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleVariable(clazz, command, VariableKind.COMMON); - } - }); - handlers.put("public", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleVisibility(clazz, command, context, Visibility.PUBLIC); - } - }); - handlers.put("protected", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleVisibility(clazz, command, context, Visibility.PROTECTED); - } - }); - handlers.put("private", new Handler() { - public void handle(IClass clazz, ICommand command, - ITclModelBuildContext context) { - handleVisibility(clazz, command, context, Visibility.PRIVATE); - } - }); + handlers.put("inherit", (clazz, command, context) -> handleInherit(clazz, command)); + handlers.put("constructor", (clazz, command, context) -> handleConstructor(clazz, command)); + handlers.put("destructor", (clazz, command, context) -> handleDestructor(clazz, command)); + handlers.put("method", (clazz, command, context) -> handleProc(clazz, command, MethodKind.METHOD)); + handlers.put("proc", (clazz, command, context) -> handleProc(clazz, command, MethodKind.PROC)); + handlers.put("variable", (clazz, command, context) -> handleVariable(clazz, command, VariableKind.VARIABLE)); + handlers.put("common", (clazz, command, context) -> handleVariable(clazz, command, VariableKind.COMMON)); + handlers.put("public", + (clazz, command, context) -> handleVisibility(clazz, command, context, Visibility.PUBLIC)); + handlers.put("protected", + (clazz, command, context) -> handleVisibility(clazz, command, context, Visibility.PROTECTED)); + handlers.put("private", + (clazz, command, context) -> handleVisibility(clazz, command, context, Visibility.PRIVATE)); } /** @@ -205,8 +154,7 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { * @param command * @param kind */ - protected void handleVariable(IClass clazz, ICommand command, - VariableKind kind) { + protected void handleVariable(IClass clazz, ICommand command, VariableKind kind) { if (command.getArgumentCount() == 0) { return; } @@ -240,8 +188,7 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { method.setKind(kind); method.setVisibility(clazz.peekVisibility()); if (command.getArgumentCount() >= 2) { - parseRawParameters(command.getArgument(1), method - .getParameters()); + parseRawParameters(command.getArgument(1), method.getParameters()); } if (command.getArgumentCount() == 3) { method.addBody(command.getArgument(2)); @@ -297,8 +244,8 @@ public class IncrTclClass extends AbstractTclCommandModelBuilder { * @param command * @param visibility */ - protected void handleVisibility(IClass clazz, ICommand command, - ITclModelBuildContext context, Visibility visibility) { + protected void handleVisibility(IClass clazz, ICommand command, ITclModelBuildContext context, + Visibility visibility) { if (command.getArgumentCount() == 0) { return; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclModelDetector.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclModelDetector.java index 7facc75e..45ba9d19 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclModelDetector.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclModelDetector.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -17,14 +17,10 @@ import org.eclipse.dltk.tcl.structure.ITclModelBuildContext; import org.eclipse.dltk.tcl.structure.ITclModelBuilderDetector; import org.eclipse.dltk.tcl.structure.TclModelBuilderUtil; -public class IncrTclModelDetector extends TclModelBuilderUtil implements - ITclModelBuilderDetector { +public class IncrTclModelDetector extends TclModelBuilderUtil implements ITclModelBuilderDetector { - @SuppressWarnings("nls") - private static final String[] NAMESPACES = new String[] { "::itcl::", - "itcl::" }; + private static final String[] NAMESPACES = new String[] { "::itcl::", "itcl::" }; - @SuppressWarnings("nls") private static final String[] COMMANDS = new String[] { "class", "body" }; // , @@ -36,7 +32,7 @@ public class IncrTclModelDetector extends TclModelBuilderUtil implements /** * Remove iTcl namespaces from the specified command name - * + * * @param commandName * @return command name without namespace */ @@ -49,8 +45,8 @@ public class IncrTclModelDetector extends TclModelBuilderUtil implements return commandName; } - public String detect(String commandName, TclCommand command, - ITclModelBuildContext context) { + @Override + public String detect(String commandName, TclCommand command, ITclModelBuildContext context) { if (commandName == null) { return null; } @@ -69,8 +65,7 @@ public class IncrTclModelDetector extends TclModelBuilderUtil implements * @param context * @return */ - private String checkInstanceOperations(TclCommand command, - String commandName, ITclModelBuildContext context) { + private String checkInstanceOperations(TclCommand command, String commandName, ITclModelBuildContext context) { final IncrTclNames names = IncrTclNames.get(context); if (names != null) { final IClass type = names.resolve(commandName); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclNewInstance.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclNewInstance.java index bafab1df..ac8bf547 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclNewInstance.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/IncrTclNewInstance.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -24,8 +24,8 @@ import org.eclipse.dltk.tcl.structure.TclModelProblem; public class IncrTclNewInstance extends AbstractTclCommandModelBuilder { - public boolean process(TclCommand command, ITclModelBuildContext context) - throws TclModelProblem { + @Override + public boolean process(TclCommand command, ITclModelBuildContext context) throws TclModelProblem { if (command.getArguments().isEmpty()) { return false; } @@ -41,8 +41,8 @@ public class IncrTclNewInstance extends AbstractTclCommandModelBuilder { fi.nameSourceEnd = varName.getEnd() - 1; fi.name = asSymbol(varName); fi.modifiers = IIncrTclModifiers.AccIncrTcl; - ITclTypeHandler typeHandler = context.get(ITclTypeResolver.class) - .resolveMemberType(fi, command.getEnd(), fi.name); + ITclTypeHandler typeHandler = context.get(ITclTypeResolver.class).resolveMemberType(fi, command.getEnd(), + fi.name); if (context.getRequestor().enterFieldCheckDuplicates(fi)) { context.getRequestor().exitField(command.getEnd()); } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/PrefixedCommandImpl.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/PrefixedCommandImpl.java index 4af35242..af033f0d 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/PrefixedCommandImpl.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/PrefixedCommandImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 xored software, Inc. + * Copyright (c) 2010, 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 @@ -23,33 +23,38 @@ class PrefixedCommandImpl implements ICommand { Assert.isTrue(command.getArgumentCount() >= 1); } + @Override public TclArgument getArgument(int index) { return command.getArgument(index + 1); } + @Override public int getArgumentCount() { return command.getArgumentCount() - 1; } + @Override public TclArgument[] getArguments() { final TclArgument[] arguments = command.getArguments(); if (arguments.length == 0) { - throw new IllegalStateException( - "No more arguments in the original command"); + throw new IllegalStateException("No more arguments in the original command"); } final TclArgument[] result = new TclArgument[arguments.length - 1]; System.arraycopy(arguments, 1, 0, 0, arguments.length - 1); return result; } + @Override public TclArgument getName() { return command.getArgument(0); } + @Override public int getEnd() { return command.getEnd(); } + @Override public int getStart() { return command.getArgument(0).getStart(); } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/ClassImpl.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/ClassImpl.java index d95a49f2..4be03d4a 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/ClassImpl.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/ClassImpl.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -17,45 +17,52 @@ import java.util.Stack; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IClass; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMember; -import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMethod; import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMember.Visibility; +import org.eclipse.dltk.itcl.internal.core.parser.structure.model.IMethod; public class ClassImpl implements IClass { - private final List<String> superclasses = new ArrayList<String>(); - private final List<IMember> members = new ArrayList<IMember>(); - private final Stack<Visibility> visibilities = new Stack<Visibility>(); + private final List<String> superclasses = new ArrayList<>(); + private final List<IMember> members = new ArrayList<>(); + private final Stack<Visibility> visibilities = new Stack<>(); private String name; + @Override public void addMember(IMember member) { members.add(member); } + @Override public void addSuperclass(String name) { superclasses.add(name); } + @Override public Visibility peekVisibility() { - return visibilities.isEmpty() ? Visibility.PRIVATE : visibilities - .peek(); + return visibilities.isEmpty() ? Visibility.PRIVATE : visibilities.peek(); } + @Override public Visibility popVisibility() { return visibilities.pop(); } + @Override public void pushVisibility(Visibility visibility) { visibilities.push(visibility); } + @Override public String[] getSuperClasses() { return superclasses.toArray(new String[superclasses.size()]); } + @Override public List<IMember> getMembers() { return members; } + @Override public IMethod findMethod(String name) { for (IMember member : members) { if (member instanceof IMethod && name.equals(member.getName())) { @@ -68,6 +75,7 @@ public class ClassImpl implements IClass { /** * @return the name */ + @Override public String getName() { return name; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Member.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Member.java index 36629110..e2b38b2f 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Member.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Member.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -24,65 +24,80 @@ public abstract class Member implements IMember { private int start; private int end; + @Override public int getNameStart() { return nameStart; } + @Override public void setNameStart(int nameStart) { this.nameStart = nameStart; } + @Override public int getNameEnd() { return nameEnd; } + @Override public void setNameEnd(int nameEnd) { this.nameEnd = nameEnd; } + @Override public int getStart() { return start; } + @Override public void setStart(int start) { this.start = start; } + @Override public int getEnd() { return end; } + @Override public void setEnd(int end) { this.end = end; } + @Override public void setNameRange(Node node) { setNameStart(node.getStart()); setNameEnd(node.getEnd() - 1); } + @Override public void setRange(Node node) { setStart(node.getStart()); setEnd(node.getEnd()); } + @Override public void setRange(IRange range) { setStart(range.getStart()); setEnd(range.getEnd()); } + @Override public String getName() { return name; } + @Override public Visibility getVisibility() { return visibility; } + @Override public void setName(String name) { this.name = name; } + @Override public void setVisibility(Visibility visibility) { this.visibility = visibility; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Method.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Method.java index 8cfc549d..d0ca917b 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Method.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Method.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -24,35 +24,40 @@ import org.eclipse.dltk.tcl.structure.AbstractTclCommandModelBuilder.Parameter; public class Method extends Member implements IMethod { private MethodKind kind = MethodKind.METHOD; - private final List<Parameter> parameters = new ArrayList<Parameter>(); + private final List<Parameter> parameters = new ArrayList<>(); private List<TclArgument> bodies = null; + @Override public MethodKind getKind() { return kind; } + @Override public void setKind(MethodKind kind) { this.kind = kind; } + @Override public List<Parameter> getParameters() { return parameters; } + @Override public List<TclArgument> getBodies() { - return bodies != null ? bodies : Collections.<TclArgument> emptyList(); + return bodies != null ? bodies : Collections.<TclArgument>emptyList(); } + @Override public void addBody(TclArgument body) { if (bodies == null) { - bodies = new ArrayList<TclArgument>(); + bodies = new ArrayList<>(); } bodies.add(body); } + @Override public int getModifiers() { - int modifiers = IIncrTclModifiers.AccIncrTcl - | getVisibility().getModifiers() | getKind().getModifiers(); + int modifiers = IIncrTclModifiers.AccIncrTcl | getVisibility().getModifiers() | getKind().getModifiers(); if (getKind().isMaskVisibility()) { modifiers &= ~(Modifiers.AccPublic | Modifiers.AccProtected | Modifiers.AccPrivate); } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Variable.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Variable.java index f12b6d06..2ffb95ed 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Variable.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/parser/structure/model/impl/Variable.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 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 (Alex Panchenko) @@ -18,14 +18,17 @@ public class Variable extends Member implements IVariable { private VariableKind kind = VariableKind.VARIABLE; + @Override public VariableKind getKind() { return kind; } + @Override public void setKind(VariableKind kind) { this.kind = kind; } + @Override public int getModifiers() { return getVisibility().getModifiers() | IIncrTclModifiers.AccIncrTcl; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclMatchLocatorExtension.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclMatchLocatorExtension.java index 4cd5604e..7aba7b54 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclMatchLocatorExtension.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclMatchLocatorExtension.java @@ -15,25 +15,22 @@ import org.eclipse.dltk.tcl.internal.core.search.TclMatchLocator; public class IncrTclMatchLocatorExtension implements IMatchLocatorExtension { - public void visitGeneral(ASTNode node, PatternLocator locator, - MatchingNodeSet nodeSet) { + @Override + public void visitGeneral(ASTNode node, PatternLocator locator, MatchingNodeSet nodeSet) { if (node instanceof IncrTclMethodCallStatement) { IncrTclMethodCallStatement st = (IncrTclMethodCallStatement) node; FieldDeclaration instanceVariable = st.getInstanceVariable(); - CallExpression call = new CallExpression(instanceVariable, st - .getName(), null); + CallExpression call = new CallExpression(instanceVariable, st.getName(), null); locator.match(call, nodeSet); } } - public IModelElement createMethodHandle(ISourceModule parent, - MethodDeclaration method, TclMatchLocator locator) { + @Override + public IModelElement createMethodHandle(ISourceModule parent, MethodDeclaration method, TclMatchLocator locator) { if (method instanceof IncrTclBodyDeclaration) { - String methodName = method.getDeclaringTypeName() + "::" - + method.getName(); - return locator.createMethodHandle((ISourceModule) parent, - methodName); + String methodName = method.getDeclaringTypeName() + "::" + method.getName(); + return locator.createMethodHandle(parent, methodName); } return null; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclSelectionExtension.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclSelectionExtension.java index 0f93c84b..201a2dc5 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclSelectionExtension.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/IncrTclSelectionExtension.java @@ -38,20 +38,18 @@ import org.eclipse.dltk.tcl.internal.core.search.mixin.TclMixinModel; public class IncrTclSelectionExtension implements ISelectionExtension { - public void selectionOnKeywordOrFunction(SelectionOnKeywordOrFunction key, - TclSelectionEngine engine) { + @Override + public void selectionOnKeywordOrFunction(SelectionOnKeywordOrFunction key, TclSelectionEngine engine) { ASTNode originalNode = key.getOriginalNode(); if (originalNode instanceof TclStatement) { processIncrTclCommandCalls((TclStatement) originalNode, engine); } } - private void processIncrTclInstanceVariable(IncrTclInstanceVariable node, - TclSelectionEngine engine) { + private void processIncrTclInstanceVariable(IncrTclInstanceVariable node, TclSelectionEngine engine) { SimpleReference classInstanceName = node.getClassInstanceName(); if (classInstanceName.sourceStart() <= engine.getActualSelectionStart() - && engine.getActualSelectionStart() <= classInstanceName - .sourceEnd()) { + && engine.getActualSelectionStart() <= classInstanceName.sourceEnd()) { TypeDeclaration declaringType = node.getDeclaringType(); IModelElement type = engine.findElementFromNode(declaringType); if (type != null) { @@ -60,46 +58,36 @@ public class IncrTclSelectionExtension implements ISelectionExtension { } } - private void processIncrTclCommandCalls(TclStatement node, - TclSelectionEngine engine) { + private void processIncrTclCommandCalls(TclStatement node, TclSelectionEngine engine) { // System.out.println("CoOL:" + node); if (node.getCount() == 0) { return; } - ASTNode parent = TclParseUtil.getPrevParent(engine.getAssistParser() - .getModule(), node); - String prefix = TclParseUtil.getElementFQN(parent, - IMixinRequestor.MIXIN_NAME_SEPARATOR, engine.getAssistParser() - .getModule()); + ASTNode parent = TclParseUtil.getPrevParent(engine.getAssistParser().getModule(), node); + String prefix = TclParseUtil.getElementFQN(parent, IMixinRequestor.MIXIN_NAME_SEPARATOR, + engine.getAssistParser().getModule()); Expression commandExpr = node.getAt(0); String command = TclParseUtil.getNameFromNode(commandExpr); if ("$this".equals(command)) { - ASTNode scopeParent = TclParseUtil.getScopeParent(engine - .getAssistParser().getModule(), node); + ASTNode scopeParent = TclParseUtil.getScopeParent(engine.getAssistParser().getModule(), node); if (scopeParent instanceof IncrTclMethodDeclaration) { IncrTclMethodDeclaration method = (IncrTclMethodDeclaration) scopeParent; ASTNode type = method.getDeclaringType(); - TclResolver resolver = new TclResolver((ISourceModule) engine - .getSourceModule(), engine.getAssistParser().getModule()); + TclResolver resolver = new TclResolver((ISourceModule) engine.getSourceModule(), + engine.getAssistParser().getModule()); IModelElement typeElement = resolver.findModelElementFrom(type); - if (commandExpr.sourceStart() <= engine - .getActualSelectionStart() - && engine.getActualSelectionStart() <= commandExpr - .sourceEnd()) { + if (commandExpr.sourceStart() <= engine.getActualSelectionStart() + && engine.getActualSelectionStart() <= commandExpr.sourceEnd()) { engine.addSelectionElement(typeElement); } if (node.getCount() > 1) { ASTNode callExpr = node.getAt(1); - if (callExpr.sourceStart() <= engine - .getActualSelectionStart() - && engine.getActualSelectionStart() <= callExpr - .sourceEnd() - && callExpr instanceof SimpleReference - && typeElement instanceof IParent) { + if (callExpr.sourceStart() <= engine.getActualSelectionStart() + && engine.getActualSelectionStart() <= callExpr.sourceEnd() + && callExpr instanceof SimpleReference && typeElement instanceof IParent) { SimpleReference callName = (SimpleReference) callExpr; - IModelElement child = TclResolver.findChildrenByName( - callName.getName(), (IParent) typeElement); + IModelElement child = TclResolver.findChildrenByName(callName.getName(), (IParent) typeElement); if (child != null) { engine.addSelectionElement(child); } @@ -113,46 +101,37 @@ public class IncrTclSelectionExtension implements ISelectionExtension { String name = command.substring(2); // Check class proc call String[] split = TclParseUtil.tclSplit(name); - IModelElement[] typeMixin = IncrTclResolver.findTypeMixin(engine - .tclNameToKey(name), split[split.length - 1], engine - .getScriptProject()); - checkMixinTypeForMethod(node, commandExpr, typeMixin, prefix, - engine); + IModelElement[] typeMixin = IncrTclResolver.findTypeMixin(engine.tclNameToKey(name), + split[split.length - 1], engine.getScriptProject()); + checkMixinTypeForMethod(node, commandExpr, typeMixin, prefix, engine); } else if (command != null) { String[] split = TclParseUtil.tclSplit(command); if (parent instanceof ModuleDeclaration) { - IModelElement[] typeMixin = IncrTclResolver.findTypeMixin( - engine.tclNameToKey(command), split[split.length - 1], - engine.getScriptProject()); - checkMixinTypeForMethod(node, commandExpr, typeMixin, prefix, - engine); + IModelElement[] typeMixin = IncrTclResolver.findTypeMixin(engine.tclNameToKey(command), + split[split.length - 1], engine.getScriptProject()); + checkMixinTypeForMethod(node, commandExpr, typeMixin, prefix, engine); } else { IModelElement[] typeMixin = IncrTclResolver.findTypeMixin( - prefix + IMixinRequestor.MIXIN_NAME_SEPARATOR - + engine.tclNameToKey(command), + prefix + IMixinRequestor.MIXIN_NAME_SEPARATOR + engine.tclNameToKey(command), split[split.length - 1], engine.getScriptProject()); - checkMixinTypeForMethod(node, commandExpr, typeMixin, prefix, - engine); + checkMixinTypeForMethod(node, commandExpr, typeMixin, prefix, engine); } } } - private boolean checkMixinTypeForMethod(TclStatement node, - Expression commandExpr, IModelElement[] typeMixin, String prefix, - TclSelectionEngine engine) { + private boolean checkMixinTypeForMethod(TclStatement node, Expression commandExpr, IModelElement[] typeMixin, + String prefix, TclSelectionEngine engine) { for (int i = 0; i < typeMixin.length; i++) { // Select type if point on type if (commandExpr.sourceStart() <= engine.getActualSelectionStart() - && engine.getActualSelectionStart() <= commandExpr - .sourceEnd()) { + && engine.getActualSelectionStart() <= commandExpr.sourceEnd()) { engine.addSelectionElement(typeMixin[i]); return true; } Expression callExpr = node.getAt(1); if (node.getCount() > 1 && typeMixin[i] instanceof IParent) { if (callExpr.sourceStart() <= engine.getActualSelectionStart() - && engine.getActualSelectionStart() <= callExpr - .sourceEnd()) { + && engine.getActualSelectionStart() <= callExpr.sourceEnd()) { String call = TclParseUtil.getNameFromNode(callExpr); IParent eParent = (IParent) typeMixin[i]; if (call != null) { @@ -167,8 +146,7 @@ public class IncrTclSelectionExtension implements ISelectionExtension { if (children != null) { for (int j = 0; j < children.length; j++) { if (children[j].getElementType() == IModelElement.METHOD - && children[j].getElementName().equals( - call)) { + && children[j].getElementName().equals(call)) { engine.addSelectionElement(children[j]); return true; } @@ -179,26 +157,17 @@ public class IncrTclSelectionExtension implements ISelectionExtension { IType type = (IType) eParent; try { String[] superClasses = type.getSuperClasses(); - String command = TclParseUtil - .getNameFromNode(commandExpr); + String command = TclParseUtil.getNameFromNode(commandExpr); if (superClasses != null) { for (int j = 0; j < superClasses.length; j++) { - IModelElement[] ptypeMixin = IncrTclResolver - .findTypeMixin( - (prefix.length() > 0 ? prefix - + IMixinRequestor.MIXIN_NAME_SEPARATOR - : "") - + engine - .tclNameToKey(superClasses[j]), - superClasses[j], - engine - .getScriptProject()); - String[] split = TclParseUtil - .tclSplit(superClasses[j]); - checkMixinTypeForMethod(node, - commandExpr, ptypeMixin, - split[split.length - 1], engine); + IModelElement[] ptypeMixin = IncrTclResolver.findTypeMixin( + (prefix.length() > 0 ? prefix + IMixinRequestor.MIXIN_NAME_SEPARATOR + : "") + engine.tclNameToKey(superClasses[j]), + superClasses[j], engine.getScriptProject()); + String[] split = TclParseUtil.tclSplit(superClasses[j]); + checkMixinTypeForMethod(node, commandExpr, ptypeMixin, split[split.length - 1], + engine); } } } catch (ModelException e) { @@ -214,162 +183,115 @@ public class IncrTclSelectionExtension implements ISelectionExtension { return false; } - private void processSelectIncrTclMethodDeclaration( - ExtendedTclMethodDeclaration node, int position, + private void processSelectIncrTclMethodDeclaration(ExtendedTclMethodDeclaration node, int position, TclSelectionEngine engine) { ASTNode type = node.getDeclaringType(); if (type instanceof TypeDeclaration) { SimpleReference ref = node.getTypeNameRef(); IModelElement parent = engine.findElementFromNode(type); if (parent != null && parent instanceof IParent) { - if (node.getNameStart() <= position - && position <= node.getNameEnd()) { + if (node.getNameStart() <= position && position <= node.getNameEnd()) { - IModelElement methodElement = TclResolver - .findChildrenByName(node.getName(), - (IParent) parent); + IModelElement methodElement = TclResolver.findChildrenByName(node.getName(), (IParent) parent); engine.addSelectionElement(methodElement); return; - } else if (ref != null && ref.sourceStart() <= position - && position <= ref.sourceEnd()) { + } else if (ref != null && ref.sourceStart() <= position && position <= ref.sourceEnd()) { engine.addSelectionElement(parent); } } } } - private void processSelectIncrTclMethod(IncrTclMethodCallStatement call, - int position, TclSelectionEngine engine) { + private void processSelectIncrTclMethod(IncrTclMethodCallStatement call, int position, TclSelectionEngine engine) { FieldDeclaration instanceVar = call.getInstanceVariable(); SimpleReference callName = call.getCallName(); SimpleReference instName = call.getInstNameRef(); - if (instanceVar != null - && instanceVar instanceof IncrTclInstanceVariable) { + if (instanceVar != null && instanceVar instanceof IncrTclInstanceVariable) { // Check for method - if (callName.sourceStart() <= position - && position <= callName.sourceEnd()) { + if (callName.sourceStart() <= position && position <= callName.sourceEnd()) { IncrTclInstanceVariable instanceVariable = (IncrTclInstanceVariable) instanceVar; - TypeDeclaration declaringType = instanceVariable - .getDeclaringType(); + TypeDeclaration declaringType = instanceVariable.getDeclaringType(); if (declaringType != null) { - IModelElement parent = engine - .findElementFromNode(declaringType); + IModelElement parent = engine.findElementFromNode(declaringType); if (parent != null) { - if (engine.checkMethodFrom(declaringType, callName, - parent)) { + if (engine.checkMethodFrom(declaringType, callName, parent)) { return; } // Check mixin for selected class. - String typeMixin = TclParseUtil.getElementFQN( - declaringType, - IMixinRequestor.MIXIN_NAME_SEPARATOR, engine - .getAssistParser().getModule()) + String typeMixin = TclParseUtil.getElementFQN(declaringType, + IMixinRequestor.MIXIN_NAME_SEPARATOR, engine.getAssistParser().getModule()) + IMixinRequestor.MIXIN_NAME_SEPARATOR; - engine.findMethodMixin(typeMixin - + engine.tclNameToKey(callName.getName()), - callName.getName()); + engine.findMethodMixin(typeMixin + engine.tclNameToKey(callName.getName()), callName.getName()); // Check super. - ASTNode nde = TclParseUtil.getPrevParent(engine - .getAssistParser().getModule(), declaringType); + ASTNode nde = TclParseUtil.getPrevParent(engine.getAssistParser().getModule(), declaringType); List supersToHandle = new ArrayList(); - engine - .fillSuperClassesTo(declaringType, - supersToHandle); + engine.fillSuperClassesTo(declaringType, supersToHandle); TypeDeclaration prev = declaringType; while (supersToHandle.size() > 0) { - String superClassName = (String) supersToHandle - .get(0); + String superClassName = (String) supersToHandle.get(0); supersToHandle.remove(0); - TypeDeclaration sType = TclParseUtil - .findXOTclTypeDeclarationFrom(engine - .getAssistParser().getModule(), nde, - superClassName); + TypeDeclaration sType = TclParseUtil.findXOTclTypeDeclarationFrom( + engine.getAssistParser().getModule(), nde, superClassName); if (sType != null) { prev = sType; - engine - .fillSuperClassesTo(sType, - supersToHandle); - IModelElement sParent = engine - .findElementFromNode(sType); - if (engine.checkMethodFrom(sType, callName, - sParent)) { + engine.fillSuperClassesTo(sType, supersToHandle); + IModelElement sParent = engine.findElementFromNode(sType); + if (engine.checkMethodFrom(sType, callName, sParent)) { return; } - String sTypeMixin = TclParseUtil.getElementFQN( - sType, - IMixinRequestor.MIXIN_NAME_SEPARATOR, - engine.getAssistParser().getModule()) + String sTypeMixin = TclParseUtil.getElementFQN(sType, + IMixinRequestor.MIXIN_NAME_SEPARATOR, engine.getAssistParser().getModule()) + IMixinRequestor.MIXIN_NAME_SEPARATOR; - findIncrTclMethodMixin(sTypeMixin - + engine.tclNameToKey(callName - .getName()), + findIncrTclMethodMixin(sTypeMixin + engine.tclNameToKey(callName.getName()), callName.getName(), engine); // System.out.println("COOL"); } else { String sTypeMixin = ""; if (prev != null) { ASTNode prevParent = TclParseUtil - .getPrevParent(engine.getAssistParser() - .getModule(), prev); + .getPrevParent(engine.getAssistParser().getModule(), prev); if (prevParent instanceof ModuleDeclaration) { - sTypeMixin = engine - .tclNameToKey(superClassName) + sTypeMixin = engine.tclNameToKey(superClassName) + IMixinRequestor.MIXIN_NAME_SEPARATOR; } else { - sTypeMixin = TclParseUtil - .getElementFQN( - prevParent, - IMixinRequestor.MIXIN_NAME_SEPARATOR, - engine.getAssistParser() - .getModule()) + sTypeMixin = TclParseUtil.getElementFQN(prevParent, + IMixinRequestor.MIXIN_NAME_SEPARATOR, + engine.getAssistParser().getModule()) + IMixinRequestor.MIXIN_NAME_SEPARATOR - + engine - .tclNameToKey(superClassName) + + engine.tclNameToKey(superClassName) + IMixinRequestor.MIXIN_NAME_SEPARATOR; } } - findIncrTclMethodMixin(sTypeMixin - + engine.tclNameToKey(callName - .getName()), + findIncrTclMethodMixin(sTypeMixin + engine.tclNameToKey(callName.getName()), callName.getName(), engine); // Lets also look to toplevel - findIncrTclMethodMixin(engine - .tclNameToKey(superClassName) - + IMixinRequestor.MIXIN_NAME_SEPARATOR - + engine.tclNameToKey(callName - .getName()), + findIncrTclMethodMixin( + engine.tclNameToKey(superClassName) + IMixinRequestor.MIXIN_NAME_SEPARATOR + + engine.tclNameToKey(callName.getName()), callName.getName(), engine); } } } } } - } else if (instanceVar != null - && instanceVar instanceof IncrTclExInstanceVariable) { + } else if (instanceVar != null && instanceVar instanceof IncrTclExInstanceVariable) { // Check for method IncrTclExInstanceVariable instanceVariable = (IncrTclExInstanceVariable) instanceVar; - IType type = (IType) instanceVariable.getDeclaringClassParameter() - .resolveElement(); - if (type != null - && (instName.sourceStart() <= position && position <= instName - .sourceEnd())) { + IType type = (IType) instanceVariable.getDeclaringClassParameter().resolveElement(); + if (type != null && (instName.sourceStart() <= position && position <= instName.sourceEnd())) { // Selection to field declaration engine.addElementFromASTNode(instanceVariable); - } else if (type != null && callName.sourceStart() <= position - && position <= callName.sourceEnd()) { + } else if (type != null && callName.sourceStart() <= position && position <= callName.sourceEnd()) { - String typeMixin = TclParseUtil.getFQNFromModelElement(type, - "::"); + String typeMixin = TclParseUtil.getFQNFromModelElement(type, "::"); if (typeMixin.startsWith("::")) { typeMixin = typeMixin.substring(2); } - findIncrTclMethodMixin(engine.tclNameToKey(typeMixin) - + IMixinRequestor.MIXIN_NAME_SEPARATOR - + engine.tclNameToKey(callName.getName()), callName - .getName(), engine); + findIncrTclMethodMixin(engine.tclNameToKey(typeMixin) + IMixinRequestor.MIXIN_NAME_SEPARATOR + + engine.tclNameToKey(callName.getName()), callName.getName(), engine); // Check super. List supersToHandle = new ArrayList(); String[] superClasses = null; @@ -393,8 +315,7 @@ public class IncrTclSelectionExtension implements ISelectionExtension { String superClassName = (String) supersToHandle.get(0); supersToHandle.remove(0); if (superClassName.startsWith("::")) { - findIncrTclMethodMixin(superClassName.substring(2) - + engine.tclNameToKey(callName.getName()), + findIncrTclMethodMixin(superClassName.substring(2) + engine.tclNameToKey(callName.getName()), callName.getName(), engine); } else { // remove one level from prev class @@ -403,29 +324,24 @@ public class IncrTclSelectionExtension implements ISelectionExtension { } } if (engine.getSelectionElementsSize() == 0) { - if (instName.sourceStart() <= position - && position <= instName.sourceEnd()) { + if (instName.sourceStart() <= position && position <= instName.sourceEnd()) { engine.addElementFromASTNode(instanceVar); } } } - private void findIncrTclMethodMixin(String pattern, String name, - TclSelectionEngine engine) { + private void findIncrTclMethodMixin(String pattern, String name, TclSelectionEngine engine) { IScriptProject project = engine.getScriptProject(); - IMixinElement[] find = TclMixinModel.getInstance().getMixin(project) - .find(pattern + "*"); + IMixinElement[] find = TclMixinModel.getInstance().getMixin(project).find(pattern + "*"); int pos = pattern.indexOf(IMixinRequestor.MIXIN_NAME_SEPARATOR); if (find.length == 0 && pos != -1) { String newPattern = pattern.substring(0, pos); - find = TclMixinModel.getInstance().getMixin(project).find( - newPattern + "*"); + find = TclMixinModel.getInstance().getMixin(project).find(newPattern + "*"); } for (int i = 0; i < find.length; i++) { Object[] allObjects = find[i].getAllObjects(); for (int j = 0; j < allObjects.length; j++) { - if (allObjects[j] != null - && allObjects[j] instanceof IncrTclInstProc) { + if (allObjects[j] != null && allObjects[j] instanceof IncrTclInstProc) { IncrTclInstProc field = (IncrTclInstProc) allObjects[j]; if (name.equals(field.getName())) { engine.addSelectionElement(field.getModelElement()); @@ -436,46 +352,41 @@ public class IncrTclSelectionExtension implements ISelectionExtension { } } + @Override public void selectionOnAST(ASTNode node, TclSelectionEngine engine) { if (node instanceof IncrTclMethodDeclaration) { - processSelectIncrTclMethodDeclaration( - (ExtendedTclMethodDeclaration) node, engine - .getActualSelectionStart(), engine); + processSelectIncrTclMethodDeclaration((ExtendedTclMethodDeclaration) node, engine.getActualSelectionStart(), + engine); if (engine.getSelectionElementsSize() > 0) { return; } } } - public void selectionOnNode(ASTNode node, int position, - TclSelectionEngine engine) { + @Override + public void selectionOnNode(ASTNode node, int position, TclSelectionEngine engine) { if (node instanceof IncrTclMethodCallStatement) { - processSelectIncrTclMethod((IncrTclMethodCallStatement) node, - position, engine); + processSelectIncrTclMethod((IncrTclMethodCallStatement) node, position, engine); } else if (node instanceof IncrTclMethodDeclaration) { - processSelectIncrTclMethodDeclaration( - (ExtendedTclMethodDeclaration) node, engine - .getActualSelectionStart(), engine); + processSelectIncrTclMethodDeclaration((ExtendedTclMethodDeclaration) node, engine.getActualSelectionStart(), + engine); } else if (node instanceof TclStatement) { // We need to check for XOTcl command calls. processIncrTclCommandCalls((TclStatement) node, engine); } else if (node instanceof IncrTclInstanceVariable) { - processIncrTclInstanceVariable((IncrTclInstanceVariable) node, - engine); + processIncrTclInstanceVariable((IncrTclInstanceVariable) node, engine); } else if (node instanceof IncrTclExInstanceVariable) { IncrTclExInstanceVariable ex = (IncrTclExInstanceVariable) node; - IncrTclGlobalClassParameter declaringClassParameter = ex - .getDeclaringClassParameter(); - IModelElement resolveElement = declaringClassParameter - .resolveElement(); + IncrTclGlobalClassParameter declaringClassParameter = ex.getDeclaringClassParameter(); + IModelElement resolveElement = declaringClassParameter.resolveElement(); if (resolveElement != null) { engine.addSelectionElement(resolveElement); } } } - public IModelElement findElementParent(ASTNode node, String name, - IParent parent, TclSelectionEngine engine) { + @Override + public IModelElement findElementParent(ASTNode node, String name, IParent parent, TclSelectionEngine engine) { if (node instanceof IncrTclBodyDeclaration) { IncrTclBodyDeclaration body = (IncrTclBodyDeclaration) node; ASTNode type = body.getDeclaringType(); @@ -483,21 +394,18 @@ public class IncrTclSelectionExtension implements ISelectionExtension { ISourceModule module = (ISourceModule) ((IModelElement) parent) .getAncestor(IModelElement.SOURCE_MODULE); - TclResolver resolver = new TclResolver(module, engine - .getAssistParser().getModule()); - IModelElement parentElement = resolver - .findModelElementFrom(type); + TclResolver resolver = new TclResolver(module, engine.getAssistParser().getModule()); + IModelElement parentElement = resolver.findModelElementFrom(type); if (parentElement != null && parentElement instanceof IParent) { - return TclResolver.findChildrenByName(body.getName(), - (IParent) parentElement); + return TclResolver.findChildrenByName(body.getName(), (IParent) parentElement); } } } return null; } - public void findVariables(String name, ASTNode parent, int beforePosition, - TclSelectionEngine engine) { + @Override + public void findVariables(String name, ASTNode parent, int beforePosition, TclSelectionEngine engine) { if (parent instanceof IncrTclMethodDeclaration) { if (name.startsWith("$")) { name = name.substring(1); @@ -506,8 +414,7 @@ public class IncrTclSelectionExtension implements ISelectionExtension { TypeDeclaration type = (TypeDeclaration) method.getDeclaringType(); if (type != null) { List fieldList = type.getFieldList(); - for (Iterator iterator = fieldList.iterator(); iterator - .hasNext();) { + for (Iterator iterator = fieldList.iterator(); iterator.hasNext();) { FieldDeclaration field = (FieldDeclaration) iterator.next(); if (field.getName().equals(name)) { engine.addElementFromASTNode(field); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/IncrTclMixinBuildVisitorExtension.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/IncrTclMixinBuildVisitorExtension.java index b65ee9ea..5e0ab1ee 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/IncrTclMixinBuildVisitorExtension.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/IncrTclMixinBuildVisitorExtension.java @@ -22,9 +22,9 @@ import org.eclipse.dltk.tcl.internal.core.search.mixin.TclMixinBuildVisitor; import org.eclipse.dltk.tcl.internal.core.search.mixin.model.TclField; import org.eclipse.dltk.tcl.internal.core.search.mixin.model.TclProc; -public class IncrTclMixinBuildVisitorExtension implements - IMixinBuildVisitorExtension { +public class IncrTclMixinBuildVisitorExtension implements IMixinBuildVisitorExtension { + @Override public boolean visit(MethodDeclaration s, TclMixinBuildVisitor original) { if (s instanceof IncrTclMethodDeclaration) { this.visitIncrTclMethod(s, original); @@ -33,8 +33,7 @@ public class IncrTclMixinBuildVisitorExtension implements return false; } - private void visitIncrTclMethod(MethodDeclaration s, - TclMixinBuildVisitor original) { + private void visitIncrTclMethod(MethodDeclaration s, TclMixinBuildVisitor original) { ExtendedTclMethodDeclaration method = (ExtendedTclMethodDeclaration) s; ElementInfo info = new ElementInfo(); @@ -42,10 +41,8 @@ public class IncrTclMixinBuildVisitorExtension implements String name = s.getName(); ASTNode declaringType = method.getDeclaringType(); if (declaringType != null && declaringType instanceof TypeDeclaration) { - List levels = TclParseUtil.findLevelsTo(original - .getModuleDeclaration(), declaringType); - info.key = original.getKeyFromLevels(levels) - + IMixinRequestor.MIXIN_NAME_SEPARATOR + List<ASTNode> levels = TclParseUtil.findLevelsTo(original.getModuleDeclaration(), declaringType); + info.key = original.getKeyFromLevels(levels) + IMixinRequestor.MIXIN_NAME_SEPARATOR + original.tclNameToKey(name); } if (original.getSignature()) { @@ -64,12 +61,12 @@ public class IncrTclMixinBuildVisitorExtension implements // System.out.println("Report proc or instproc:" + info.key); } + @Override public boolean visit(TypeDeclaration s, TclMixinBuildVisitor original) { if ((s.getModifiers() & IIncrTclModifiers.AccIncrTcl) != 0) { ElementInfo info = new ElementInfo(); - info.key = original.getNamespacePrefix() - + original.tclNameToKey(s.getName()); + info.key = original.getNamespacePrefix() + original.tclNameToKey(s.getName()); if (info.key.startsWith("{")) { info.key = info.key.substring(1); } @@ -90,11 +87,11 @@ public class IncrTclMixinBuildVisitorExtension implements return false; } + @Override public boolean visit(Statement s, TclMixinBuildVisitor original) { if (s instanceof IncrTclInstanceVariable) { IncrTclInstanceVariable instanceVar = (IncrTclInstanceVariable) s; - List levels = TclParseUtil.findLevelsTo(original - .getModuleDeclaration(), instanceVar); + List<ASTNode> levels = TclParseUtil.findLevelsTo(original.getModuleDeclaration(), instanceVar); ElementInfo info = new ElementInfo(); info.key = original.getKeyFromLevels(levels); if (original.getSignature()) { @@ -106,12 +103,10 @@ public class IncrTclMixinBuildVisitorExtension implements IncrTclFieldDeclaration var = (IncrTclFieldDeclaration) s; String name = var.getName(); TypeDeclaration type = var.getDeclaringType(); - List levels = TclParseUtil.findLevelsTo(original - .getModuleDeclaration(), type); + List<ASTNode> levels = TclParseUtil.findLevelsTo(original.getModuleDeclaration(), type); ElementInfo info = new ElementInfo(); - info.key = original.getKeyFromLevels(levels) - + IMixinRequestor.MIXIN_NAME_SEPARATOR + info.key = original.getKeyFromLevels(levels) + IMixinRequestor.MIXIN_NAME_SEPARATOR + original.tclNameToKey(name); if (original.getSignature()) { info.object = new TclField(); diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClass.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClass.java index d852338d..d4700264 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClass.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClass.java @@ -7,18 +7,24 @@ import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.itcl.internal.core.IIncrTclModifiers; import org.eclipse.dltk.tcl.internal.core.search.mixin.model.TclMixinElement; - public class IncrTclClass extends TclMixinElement implements IIncrTclMixinConstants { private String namespaceKey; + + @Override public int getType() { return ELEMENT_INCRTCL_CLASS; } + + @Override public String toString() { return "incrtclclass"; } + public void setNamespace(String namespacePrefix) { this.namespaceKey = namespacePrefix; } + + @Override protected boolean isValidModelElement(IModelElement element) { if (!(element.getElementType() == IModelElement.TYPE)) { return false; @@ -29,7 +35,7 @@ public class IncrTclClass extends TclMixinElement implements IIncrTclMixinConsta return true; } } catch (ModelException e) { - if( DLTKCore.DEBUG ) { + if (DLTKCore.DEBUG) { e.printStackTrace(); } } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClassInstance.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClassInstance.java index f9a49bf5..902a0687 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClassInstance.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclClassInstance.java @@ -3,16 +3,18 @@ package org.eclipse.dltk.itcl.internal.core.search.mixin.model; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.tcl.internal.core.search.mixin.model.TclMixinElement; -public class IncrTclClassInstance extends TclMixinElement implements - IIncrTclMixinConstants { +public class IncrTclClassInstance extends TclMixinElement implements IIncrTclMixinConstants { + @Override public int getType() { return ELEMENT_INCRTCL_CLASS_INSTANCE; } + @Override public String toString() { return "incr_class_instance"; } + @Override protected boolean isValidModelElement(IModelElement element) { return element.getElementType() == IModelElement.FIELD; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclInstProc.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclInstProc.java index b9c8a6ea..3a000b17 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclInstProc.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclInstProc.java @@ -4,12 +4,17 @@ import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.tcl.internal.core.search.mixin.model.TclMixinElement; public class IncrTclInstProc extends TclMixinElement implements IIncrTclMixinConstants { + @Override public int getType() { return ELEMENT_INCRTCL_INSTPROC; } + + @Override public String toString() { return "incrtclinstproc"; } + + @Override protected boolean isValidModelElement(IModelElement element) { return element.getElementType() == IModelElement.METHOD; } diff --git a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclProc.java b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclProc.java index 85b5fe96..2f4084e5 100644 --- a/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclProc.java +++ b/itcl/plugins/org.eclipse.dltk.itcl.core/src/org/eclipse/dltk/itcl/internal/core/search/mixin/model/IncrTclProc.java @@ -4,12 +4,17 @@ import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.tcl.internal.core.search.mixin.model.TclMixinElement; public class IncrTclProc extends TclMixinElement implements IIncrTclMixinConstants { + @Override public int getType() { return ELEMENT_INCRTCL_PROC; } + + @Override public String toString() { return "incrtclproc"; } + + @Override protected boolean isValidModelElement(IModelElement element) { return element.getElementType() == IModelElement.METHOD; } |