diff -Nru eclipse-jdt-ui-4.12/debian/build.xml eclipse-jdt-ui-4.15/debian/build.xml --- eclipse-jdt-ui-4.12/debian/build.xml 2019-07-17 11:32:57.000000000 +0000 +++ eclipse-jdt-ui-4.15/debian/build.xml 2020-05-07 11:52:58.000000000 +0000 @@ -26,6 +26,7 @@ + diff -Nru eclipse-jdt-ui-4.12/debian/changelog eclipse-jdt-ui-4.15/debian/changelog --- eclipse-jdt-ui-4.12/debian/changelog 2019-08-06 07:14:34.000000000 +0000 +++ eclipse-jdt-ui-4.15/debian/changelog 2020-05-07 21:39:22.000000000 +0000 @@ -1,3 +1,14 @@ +eclipse-jdt-ui (4.15-1) unstable; urgency=medium + + * New upstream release + - Depend on libeclipse-jdt-core-java (>= 3.20) + - Depend on libeclipse-jface-text-java (>= 3.16) + - Updated the bundle dependencies + * Standards-Version updated to 4.5.0 + * Switch to debhelper level 12 + + -- Emmanuel Bourg Thu, 07 May 2020 23:39:22 +0200 + eclipse-jdt-ui (4.12-1) unstable; urgency=medium * New upstream release diff -Nru eclipse-jdt-ui-4.12/debian/compat eclipse-jdt-ui-4.15/debian/compat --- eclipse-jdt-ui-4.12/debian/compat 2019-07-17 11:32:57.000000000 +0000 +++ eclipse-jdt-ui-4.15/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru eclipse-jdt-ui-4.12/debian/control eclipse-jdt-ui-4.15/debian/control --- eclipse-jdt-ui-4.12/debian/control 2019-08-06 07:14:20.000000000 +0000 +++ eclipse-jdt-ui-4.15/debian/control 2020-05-07 11:56:11.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Debian Java Maintainers Uploaders: Emmanuel Bourg Build-Depends: - debhelper (>= 11), + debhelper-compat (= 12), default-jdk, ant, junit, @@ -23,10 +23,10 @@ libeclipse-debug-core-java, libeclipse-debug-ui-java, libeclipse-help-java, - libeclipse-jdt-core-java (>= 3.18), + libeclipse-jdt-core-java (>= 3.20), libeclipse-jdt-launching-java (>= 3.11), libeclipse-jface-java (>= 3.14), - libeclipse-jface-text-java (>= 3.15), + libeclipse-jface-text-java (>= 3.16), libeclipse-search-java, libeclipse-team-core-java, libeclipse-team-ui-java, @@ -48,7 +48,7 @@ libicu4j-java, libswt-gtk-4-java, eclipse-debian-helper -Standards-Version: 4.4.0 +Standards-Version: 4.5.0 Vcs-Git: https://salsa.debian.org/java-team/eclipse-jdt-ui.git Vcs-Browser: https://salsa.debian.org/java-team/eclipse-jdt-ui Homepage: https://www.eclipse.org/jdt/ui/ @@ -105,13 +105,14 @@ Depends: ${misc:Depends}, ${bundle:Depends}, + libeclipse-core-contenttype-java, libeclipse-core-expressions-java, libeclipse-core-filebuffers-java, libeclipse-core-filesystem-java, libeclipse-core-jobs-java, libeclipse-core-resources-java, libeclipse-core-runtime-java, - libeclipse-jdt-core-java (>= 3.18), + libeclipse-jdt-core-java (>= 3.20), libeclipse-jdt-launching-java, libeclipse-text-java (>= 3.8), libequinox-common-java, @@ -274,7 +275,7 @@ libeclipse-jdt-core-java (>= 3.16), libeclipse-jdt-launching-java (>= 3.11), libeclipse-jface-java (>= 3.14), - libeclipse-jface-text-java (>= 3.15), + libeclipse-jface-text-java (>= 3.16), libeclipse-search-java, libeclipse-team-core-java, libeclipse-team-ui-java, diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/build.properties eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/build.properties --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/build.properties 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/build.properties 2020-02-26 15:31:57.000000000 +0000 @@ -20,5 +20,5 @@ source.. = src/ output.. = bin/ -jre.compilation.profile = JavaSE-1.7 +jre.compilation.profile = JavaSE-1.8 javacDefaultEncoding.. = UTF-8 diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/META-INF/MANIFEST.MF eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/META-INF/MANIFEST.MF --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/META-INF/MANIFEST.MF 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/META-INF/MANIFEST.MF 2020-02-26 15:31:57.000000000 +0000 @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.astview; singleton:=true -Bundle-Version: 1.4.0.qualifier +Bundle-Version: 1.4.300.qualifier Eclipse-SourceReferences: scm:git:git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui.git;path="org.eclipse.jdt.astview";tag=R4_4 Bundle-Activator: org.eclipse.jdt.astview.ASTViewPlugin Bundle-Vendor: %providerName diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/pom.xml eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/pom.xml --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/pom.xml 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/pom.xml 2020-02-26 15:31:57.000000000 +0000 @@ -14,10 +14,10 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.12.0-SNAPSHOT + 4.15.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.astview - 1.4.0-SNAPSHOT + 1.4.300-SNAPSHOT eclipse-plugin diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/.settings/org.eclipse.jdt.ui.prefs eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/.settings/org.eclipse.jdt.ui.prefs --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/.settings/org.eclipse.jdt.ui.prefs 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/.settings/org.eclipse.jdt.ui.prefs 2020-02-26 15:31:57.000000000 +0000 @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_JDT UI Code Style Conventions formatter_settings_version=12 org.eclipse.jdt.ui.exception.name=e @@ -9,3 +10,69 @@ org.eclipse.jdt.ui.ondemandthreshold=99 org.eclipse.jdt.ui.overrideannotation=true org.eclipse.jdt.ui.staticondemandthreshold=99 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=false +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=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +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.number_suffix=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.push_down_negation=false +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_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +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_array_creation=false +sp_cleanup.remove_unnecessary_casts=false +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +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.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=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 +sp_cleanup.use_unboxing=false diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewPlugin.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewPlugin.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewPlugin.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewPlugin.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -27,7 +27,7 @@ public ASTViewPlugin() { fgDefault= this; } - + public static String getPluginId() { return "org.eclipse.jdt.astview"; //$NON-NLS-1$ } @@ -38,15 +38,15 @@ public static ASTViewPlugin getDefault() { return fgDefault; } - + public static void log(IStatus status) { getDefault().getLog().log(status); } - + public static void logErrorMessage(String message) { log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null)); } - + public static void logErrorStatus(String message, IStatus status) { if (status == null) { logErrorMessage(message); @@ -56,9 +56,9 @@ multi.add(status); log(multi); } - + public static void log(String message, Throwable e) { log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, e)); } - + } diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/EditorUtility.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/EditorUtility.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/EditorUtility.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/EditorUtility.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -18,6 +18,8 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; @@ -34,7 +36,7 @@ } public static IEditorPart getActiveEditor() { - IWorkbenchWindow window= ASTViewPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) { @@ -43,7 +45,7 @@ } return null; } - + public static ITypeRoot getJavaInput(IEditorPart part) { IEditorInput editorInput= part.getEditorInput(); if (editorInput != null) { @@ -52,7 +54,7 @@ return (ITypeRoot) input; } } - return null; + return null; } public static void selectInEditor(ITextEditor editor, int offset, int length) { diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/TreeInfoCollector.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/TreeInfoCollector.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/TreeInfoCollector.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/TreeInfoCollector.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,7 +1,7 @@ /******************************************************************************* * Copyright (c) 2000, 2013 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ @@ -21,18 +21,18 @@ * */ public class TreeInfoCollector { - + public static class NodeCounter extends ASTVisitor { public int numberOfNodes= 0; - + @Override public void preVisit(ASTNode node) { numberOfNodes++; } } - - + + private final CompilationUnit fRoot; public TreeInfoCollector(CompilationUnit root) { @@ -42,12 +42,12 @@ public int getSize() { return fRoot.subtreeBytes(); } - + public int getNumberOfNodes() { NodeCounter counter= new NodeCounter(); fRoot.accept(counter); return counter.numberOfNodes; } - + } diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTAttribute.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTAttribute.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTAttribute.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTAttribute.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -21,14 +21,14 @@ * */ public abstract class ASTAttribute { - + protected static final Object[] EMPTY= new Object[0]; public abstract Object getParent(); public abstract Object[] getChildren(); public abstract String getLabel(); public abstract Image getImage(); - + public ASTNode getParentASTNode() { Object parent= getParent(); while (parent instanceof ASTAttribute) { @@ -39,5 +39,5 @@ } return null; } - + } diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,7 +1,7 @@ /******************************************************************************* * Copyright (c) 2000, 2017 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ @@ -62,16 +62,16 @@ @Override public void inputChanged(Viewer v, Object oldInput, Object newInput) { } - + @Override public void dispose() { } - + @Override public Object[] getElements(Object parent) { return getChildren(parent); } - + @Override public Object getParent(Object child) { if (child instanceof ASTNode) { @@ -96,7 +96,7 @@ } return new Object[0]; } - + private Object[] getNodeChildren(ASTNode node) { ArrayList res= new ArrayList<>(); @@ -104,7 +104,7 @@ Expression expression= (Expression) node; ITypeBinding expressionTypeBinding= expression.resolveTypeBinding(); res.add(createExpressionTypeBinding(node, expressionTypeBinding)); - + // expressions: if (expression instanceof Name) { IBinding binding= ((Name) expression).resolveBinding(); @@ -154,7 +154,7 @@ // Expression attributes: res.add(new GeneralAttribute(expression, "Boxing: " + expression.resolveBoxing() + "; Unboxing: " + expression.resolveUnboxing())); //$NON-NLS-1$ //$NON-NLS-2$ res.add(new GeneralAttribute(expression, "ConstantExpressionValue", expression.resolveConstantExpressionValue())); //$NON-NLS-1$ - + // references: } else if (node instanceof ConstructorInvocation) { IMethodBinding binding= ((ConstructorInvocation) node).resolveConstructorBinding(); @@ -171,7 +171,7 @@ } else if (node instanceof Type) { IBinding binding= ((Type) node).resolveBinding(); res.add(createBinding(node, binding)); - + // declarations: } else if (node instanceof AbstractTypeDeclaration) { IBinding binding= ((AbstractTypeDeclaration) node).resolveBinding(); @@ -209,15 +209,15 @@ IBinding binding= ((ModuleDeclaration) node).resolveBinding(); res.add(createBinding(node, binding)); } - - - + + + List list= node.structuralPropertiesForType(); for (int i= 0; i < list.size(); i++) { StructuralPropertyDescriptor curr= list.get(i); res.add(new NodeProperty(node, curr)); } - + if (node instanceof CompilationUnit) { CompilationUnit root= (CompilationUnit) node; res.add(new JavaElement(root, root.getJavaElement())); @@ -226,10 +226,10 @@ res.add(new SettingsProperty(root)); res.add(new WellKnownTypesProperty(root)); } - + return res.toArray(); } - + private Binding createBinding(ASTNode parent, IBinding binding) { String label= Binding.getBindingLabel(binding); return new Binding(parent, label, binding, true); @@ -239,7 +239,7 @@ String label= "> (Expression) type binding"; //$NON-NLS-1$ return new Binding(parent, label, binding, true); } - + @Override public boolean hasChildren(Object parent) { return getChildren(parent).length > 0; diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java 2020-02-26 15:31:57.000000000 +0000 @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -121,7 +121,6 @@ import org.eclipse.jdt.core.dom.ASTRequestor; import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.Block; -import org.eclipse.jdt.core.dom.BreakStatement; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.ExpressionStatement; @@ -129,41 +128,47 @@ import org.eclipse.jdt.core.dom.NodeFinder; import org.eclipse.jdt.core.dom.Statement; import org.eclipse.jdt.core.dom.SwitchExpression; -import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.dom.YieldStatement; import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.ui.JavaUI; public class ASTView extends ViewPart implements IShowInSource, IShowInTargetList { - - static final int JLS_LATEST= AST.JLS12; + static final int JLS_LATEST= AST.JLS13; + + private static final int JLS13= AST.JLS13; + + /** + * @deprecated to get rid of deprecation warnings in code + */ + @Deprecated private static final int JLS12= AST.JLS12; - + /** * @deprecated to get rid of deprecation warnings in code */ @Deprecated private static final int JLS11= AST.JLS11; - + /** * @deprecated to get rid of deprecation warnings in code */ @Deprecated private static final int JLS10= AST.JLS10; - + /** * @deprecated to get rid of deprecation warnings in code */ @Deprecated private static final int JLS9= AST.JLS9; - + /** * @deprecated to get rid of deprecation warnings in code */ @Deprecated private static final int JLS8= AST.JLS8; - + /** * @deprecated to get rid of deprecation warnings in code */ @@ -221,23 +226,23 @@ setChecked(true); } } - + public int getLevel() { return fLevel; } - + @Override public void run() { setASTLevel(fLevel, true); } } - + private class ASTInputKindAction extends Action { public static final int USE_PARSER= 1; public static final int USE_RECONCILE= 2; public static final int USE_CACHE= 3; public static final int USE_FOCAL= 4; - + private int fInputKind; public ASTInputKindAction(String label, int inputKind) { @@ -247,27 +252,27 @@ setChecked(true); } } - + public int getInputKind() { return fInputKind; } - + @Override public void run() { setASTInputType(fInputKind); } } - - + + private static class ListenerMix implements ISelectionListener, IFileBufferListener, IDocumentListener, ISelectionChangedListener, IDoubleClickListener, IPartListener2 { - + private boolean fASTViewVisible= true; private ASTView fView; - + public ListenerMix(ASTView view) { fView= view; } - + public void dispose() { fView= null; } @@ -350,7 +355,7 @@ public void doubleClick(DoubleClickEvent event) { fView.handleDoubleClick(); } - + @Override public void partHidden(IWorkbenchPartReference partRef) { IWorkbenchPart part= partRef.getPart(false); @@ -398,28 +403,25 @@ } } - private static final class BreakStatementChecker extends ASTVisitor { + private static final class StatementChecker extends ASTVisitor { @Override - public boolean visit(BreakStatement node) { + public boolean visit(YieldStatement node) { try { - if (node != null && node.isImplicit() && isInSwitchExpressionOrStatement(node)) { + if (node != null && node.isImplicit() && isInSwitchExpression(node)) { ASTNode parent= node.getParent(); List statements= null; if (parent instanceof Block) { statements= ((Block) parent).statements(); } else if (parent instanceof SwitchExpression) { statements= ((SwitchExpression) parent).statements(); - } else if (parent instanceof SwitchStatement) { - statements= ((SwitchStatement) parent).statements(); } if (statements == null) { return true; } Expression exp= node.getExpression(); if (exp == null) { - statements.remove(node); - return false; + return true; } else { int index= statements.indexOf(node); statements.remove(node); @@ -437,11 +439,11 @@ return true; } - private boolean isInSwitchExpressionOrStatement(BreakStatement node) { + private boolean isInSwitchExpression(YieldStatement node) { boolean result= false; ASTNode parent= node; while (parent != null) { - if (parent instanceof SwitchStatement || parent instanceof SwitchExpression) { + if (parent instanceof SwitchExpression) { result= true; break; } @@ -464,7 +466,7 @@ private TreeViewer fViewer; private ASTViewLabelProvider fASTLabelProvider; private TreeViewer fTray; - + private DrillDownAdapter fDrillDownAdapter; private Action fFocusAction; private Action fRefreshAction; @@ -484,34 +486,34 @@ private Action fLinkWithEditor; private Action fAddToTrayAction; private Action fDeleteAction; - + private ASTLevelToggle[] fASTVersionToggleActions; private int fCurrentASTLevel; - + private ASTInputKindAction[] fASTInputKindActions; private int fCurrentInputKind; - + private ITextEditor fEditor; private ITypeRoot fTypeRoot; private CompilationUnit fRoot; private IDocument fCurrentDocument; private ArrayList fTrayRoots; - + private boolean fDoLinkWithEditor; private boolean fCreateBindings; private NonRelevantFilter fNonRelevantFilter; private boolean fStatementsRecovery; private boolean fBindingsRecovery; private boolean fIgnoreMethodBodies; - + private Object fPreviousDouble; - + private ListenerMix fSuperListener; private ISelectionChangedListener fTrayUpdater; private IDialogSettings fDialogSettings; - + public ASTView() { fSuperListener= null; fDialogSettings= ASTViewPlugin.getDefault().getDialogSettings(); @@ -537,6 +539,7 @@ case JLS10: case JLS11: case JLS12: + case JLS13: fCurrentASTLevel= level; } } catch (NumberFormatException e) { @@ -545,7 +548,7 @@ fNonRelevantFilter= new NonRelevantFilter(); fNonRelevantFilter.setShowNonRelevant(fDialogSettings.getBoolean(SETTINGS_SHOW_NON_RELEVANT)); } - + final void notifyWorkbenchPartClosed(IWorkbenchPartReference partRef) { if (fEditor != null && fEditor.equals(partRef.getPart(false))) { try { @@ -561,18 +564,18 @@ super.setSite(site); if (fSuperListener == null) { fSuperListener= new ListenerMix(this); - + ISelectionService service= site.getWorkbenchWindow().getSelectionService(); service.addPostSelectionListener(fSuperListener); site.getPage().addPartListener(fSuperListener); FileBuffers.getTextFileBufferManager().addFileBufferListener(fSuperListener); } } - + public int getCurrentASTLevel() { return fCurrentASTLevel; } - + public int getCurrentInputKind() { return fCurrentInputKind; } @@ -581,17 +584,17 @@ if (fEditor != null) { uninstallModificationListener(); } - + fEditor= null; fRoot= null; - + if (editor != null) { ITypeRoot typeRoot= EditorUtility.getJavaInput(editor); if (typeRoot == null) { throw new CoreException(getErrorStatus("Editor not showing a CU or class file", null)); //$NON-NLS-1$ } fTypeRoot= typeRoot; - + ISelection selection= editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection= (ITextSelection) selection; @@ -602,12 +605,12 @@ } } - + private CompilationUnit internalSetInput(ITypeRoot input, int offset, int length) throws CoreException { if (input.getBuffer() == null) { throw new CoreException(getErrorStatus("Input has no buffer", null)); //$NON-NLS-1$ } - + CompilationUnit root; try { root= createAST(input, offset); @@ -619,7 +622,7 @@ } catch (RuntimeException e) { throw new CoreException(getErrorStatus("Could not create AST:\n" + e.getMessage(), e)); //$NON-NLS-1$ } - + try { ASTNode node= NodeFinder.perform(root, offset, length); if (node != null) { @@ -634,15 +637,15 @@ } catch (RuntimeException e) { showAndLogError("Could not select node for editor selection", e); //$NON-NLS-1$ } - + return root; } - + private void clearView() { resetView(null); setContentDescription("Open a Java editor and press the 'Show AST of active editor' toolbar button"); //$NON-NLS-1$ } - + private void resetView(CompilationUnit root) { fViewer.setInput(root); @@ -656,12 +659,12 @@ fFindDeclaringNodeAction.setEnabled(root != null); fPreviousDouble= null; // avoid leaking AST } - + private CompilationUnit createAST(ITypeRoot input, int offset) throws JavaModelException, CoreException { long startTime; long endTime; CompilationUnit root; - + if ((getCurrentInputKind() == ASTInputKindAction.USE_RECONCILE)) { final IProblemRequestor problemRequestor= new IProblemRequestor() { //strange: don't get bindings when supplying null as problemRequestor @Override @@ -696,13 +699,13 @@ } finally { wc.discardWorkingCopy(); } - + } else if (input instanceof ICompilationUnit && (getCurrentInputKind() == ASTInputKindAction.USE_CACHE)) { ICompilationUnit cu= (ICompilationUnit) input; startTime= System.currentTimeMillis(); root= SharedASTProviderCore.getAST(cu, SharedASTProviderCore.WAIT_NO, null); endTime= System.currentTimeMillis(); - + } else { ASTParser parser= ASTParser.newParser(fCurrentASTLevel); parser.setResolveBindings(fCreateBindings); @@ -718,8 +721,8 @@ endTime= System.currentTimeMillis(); } if (root != null) { - root.accept(new BreakStatementChecker()); - updateContentDescription(input, root, endTime - startTime); + root.accept(new StatementChecker()); + updateContentDescription(input, root, endTime - startTime); } return root; } @@ -738,19 +741,25 @@ fStatementsRecoveryAction.setEnabled(enabled); fBindingsRecoveryAction.setEnabled(enabled); fIgnoreMethodBodiesAction.setEnabled(enabled); - for (int i= 0; i < fASTVersionToggleActions.length; i++) { - fASTVersionToggleActions[i].setEnabled(enabled); + for (ASTView.ASTLevelToggle action : fASTVersionToggleActions) { + action.setEnabled(enabled); } } private void updateContentDescription(IJavaElement element, CompilationUnit root, long time) { String version= "AST Level " + root.getAST().apiLevel(); - if (getCurrentInputKind() == ASTInputKindAction.USE_RECONCILE) { + switch (getCurrentInputKind()) { + case ASTInputKindAction.USE_RECONCILE: version+= ", from reconciler"; //$NON-NLS-1$ - } else if (getCurrentInputKind() == ASTInputKindAction.USE_CACHE) { + break; + case ASTInputKindAction.USE_CACHE: version+= ", from ASTProvider"; //$NON-NLS-1$ - } else if (getCurrentInputKind() == ASTInputKindAction.USE_FOCAL) { + break; + case ASTInputKindAction.USE_FOCAL: version+= ", using focal position"; //$NON-NLS-1$ + break; + default: + break; } TreeInfoCollector collector= new TreeInfoCollector(root); @@ -780,11 +789,11 @@ } super.dispose(); } - + private IStatus getErrorStatus(String message, Throwable th) { return new Status(IStatus.ERROR, ASTViewPlugin.getPluginId(), IStatus.ERROR, message, th); } - + @Override public void createPartControl(Composite parent) { fSash= new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH); @@ -804,16 +813,16 @@ } }); fViewer.addFilter(fNonRelevantFilter); - - + + ViewForm trayForm= new ViewForm(fSash, SWT.NONE); Label label= new Label(trayForm, SWT.NONE); label.setText(" Comparison Tray (* = selection in the upper tree):"); //$NON-NLS-1$ trayForm.setTopLeft(label); - + fTray= new TreeViewer(trayForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); trayForm.setContent(fTray.getTree()); - + fTrayRoots= new ArrayList<>(); fTray.setContentProvider(new TrayContentProvider()); final TrayLabelProvider trayLabelProvider= new TrayLabelProvider(); @@ -859,13 +868,13 @@ fDeleteAction.setEnabled(false); } }); - + makeActions(); hookContextMenu(); hookTrayContextMenu(); contributeToActionBars(); getSite().setSelectionProvider(new ASTViewSelectionProvider()); - + try { IEditorPart part= EditorUtility.getActiveEditor(); if (part instanceof ITextEditor) { @@ -912,7 +921,7 @@ fTray.getControl().setMenu(menu); getSite().registerContextMenu("#TrayPopupMenu", menuMgr, fTray); //$NON-NLS-1$ } - + private void contributeToActionBars() { IActionBars bars = getViewSite().getActionBars(); fillLocalPullDown(bars.getMenuManager()); @@ -920,14 +929,14 @@ bars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction); bars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fFocusAction); bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), fDeleteAction); - + IHandlerService handlerService= getViewSite().getService(IHandlerService.class); handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fLinkWithEditor)); } private void fillLocalPullDown(IMenuManager manager) { - for (int i= 0; i < fASTVersionToggleActions.length; i++) { - manager.add(fASTVersionToggleActions[i]); + for (ASTView.ASTLevelToggle action : fASTVersionToggleActions) { + manager.add(action); } manager.add(new Separator()); manager.add(fCreateBindingsAction); @@ -935,8 +944,8 @@ manager.add(fBindingsRecoveryAction); manager.add(fIgnoreMethodBodiesAction); manager.add(new Separator()); - for (int i= 0; i < fASTInputKindActions.length; i++) { - manager.add(fASTInputKindActions[i]); + for (ASTView.ASTInputKindAction action : fASTInputKindActions) { + manager.add(action); } manager.add(new Separator()); manager.add(fFindDeclaringNodeAction); @@ -996,11 +1005,11 @@ manager.add(fCollapseAction); manager.add(fLinkWithEditor); } - + private void setASTUptoDate(boolean isuptoDate) { fRefreshAction.setEnabled(!isuptoDate && fTypeRoot != null); } - + private void makeActions() { fRefreshAction = new Action() { @Override @@ -1023,14 +1032,14 @@ fClearAction.setToolTipText("Clear AST and release memory"); //$NON-NLS-1$ fClearAction.setEnabled(false); ASTViewImages.setImageDescriptors(fClearAction, ASTViewImages.CLEAR); - + fASTInputKindActions= new ASTInputKindAction[] { new ASTInputKindAction("Use ASTParser.&createAST", ASTInputKindAction.USE_PARSER), //$NON-NLS-1$ new ASTInputKindAction("Use ASTParser with &focal position", ASTInputKindAction.USE_FOCAL), //$NON-NLS-1$ new ASTInputKindAction("Use ICompilationUnit.&reconcile", ASTInputKindAction.USE_RECONCILE), //$NON-NLS-1$ new ASTInputKindAction("Use SharedASTProvider.&getAST", ASTInputKindAction.USE_CACHE) //$NON-NLS-1$ }; - + fCreateBindingsAction = new Action("&Create Bindings", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { @@ -1040,7 +1049,7 @@ fCreateBindingsAction.setChecked(fCreateBindings); fCreateBindingsAction.setToolTipText("Create Bindings"); //$NON-NLS-1$ fCreateBindingsAction.setEnabled(true); - + fStatementsRecoveryAction = new Action("&Statements Recovery", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { @@ -1049,7 +1058,7 @@ }; fStatementsRecoveryAction.setChecked(fStatementsRecovery); fStatementsRecoveryAction.setEnabled(true); - + fBindingsRecoveryAction = new Action("&Bindings Recovery", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { @@ -1058,7 +1067,7 @@ }; fBindingsRecoveryAction.setChecked(fBindingsRecovery); fBindingsRecoveryAction.setEnabled(true); - + fIgnoreMethodBodiesAction = new Action("&Ignore Method Bodies", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { @@ -1067,7 +1076,7 @@ }; fIgnoreMethodBodiesAction.setChecked(fIgnoreMethodBodies); fIgnoreMethodBodiesAction.setEnabled(true); - + fFilterNonRelevantAction = new Action("&Hide Non-Relevant Attributes", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { @@ -1086,7 +1095,7 @@ }; fFindDeclaringNodeAction.setToolTipText("Find Declaring Node..."); //$NON-NLS-1$ fFindDeclaringNodeAction.setEnabled(false); - + fParseBindingFromElementAction= new Action("&Parse Binding from &Element Handle...", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ @Override public void run() { @@ -1095,7 +1104,7 @@ }; fParseBindingFromElementAction.setToolTipText("Parse Binding from Element Handle..."); //$NON-NLS-1$ fParseBindingFromElementAction.setEnabled(true); - + fParseBindingFromKeyAction= new Action("Parse Binding from &Key...", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ @Override public void run() { @@ -1104,7 +1113,7 @@ }; fParseBindingFromKeyAction.setToolTipText("Parse Binding from Key..."); //$NON-NLS-1$ fParseBindingFromKeyAction.setEnabled(true); - + fFocusAction = new Action() { @Override public void run() { @@ -1113,7 +1122,7 @@ }; fFocusAction.setText("&Show AST of active editor"); //$NON-NLS-1$ fFocusAction.setToolTipText("Show AST of active editor"); //$NON-NLS-1$ - fFocusAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); //$NON-NLS-1$ + fFocusAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); ASTViewImages.setImageDescriptors(fFocusAction, ASTViewImages.SETFOCUS); fCollapseAction = new Action() { @@ -1126,7 +1135,7 @@ fCollapseAction.setToolTipText("Collapse Selected Node"); //$NON-NLS-1$ fCollapseAction.setEnabled(false); ASTViewImages.setImageDescriptors(fCollapseAction, ASTViewImages.COLLAPSE); - + fExpandAction = new Action() { @Override public void run() { @@ -1137,16 +1146,16 @@ fExpandAction.setToolTipText("Expand Selected Node"); //$NON-NLS-1$ fExpandAction.setEnabled(false); ASTViewImages.setImageDescriptors(fExpandAction, ASTViewImages.EXPAND); - + fCopyAction= new TreeCopyAction(new Tree[] {fViewer.getTree(), fTray.getTree()}); - + fDoubleClickAction = new Action() { @Override public void run() { performDoubleClick(); } }; - + fLinkWithEditor = new Action() { @Override public void run() { @@ -1158,7 +1167,7 @@ fLinkWithEditor.setToolTipText("Link With Editor"); //$NON-NLS-1$ fLinkWithEditor.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR); ASTViewImages.setImageDescriptors(fLinkWithEditor, ASTViewImages.LINK_WITH_EDITOR); - + fASTVersionToggleActions= new ASTLevelToggle[] { new ASTLevelToggle("AST Level &2 (1.2)", JLS2), //$NON-NLS-1$ new ASTLevelToggle("AST Level &3 (1.5)", JLS3), //$NON-NLS-1$ @@ -1168,8 +1177,9 @@ new ASTLevelToggle("AST Level 1&0 (10)", JLS10), //$NON-NLS-1$ new ASTLevelToggle("AST Level 1&1 (11)", JLS11), //$NON-NLS-1$ new ASTLevelToggle("AST Level 1&2 (12)", JLS12), //$NON-NLS-1$ + new ASTLevelToggle("AST Level 1&3 (13)", JLS13), //$NON-NLS-1$ }; - + fAddToTrayAction= new Action() { @Override public void run() { @@ -1180,7 +1190,7 @@ fAddToTrayAction.setToolTipText("Add Selected Node to Comparison Tray"); //$NON-NLS-1$ fAddToTrayAction.setEnabled(false); ASTViewImages.setImageDescriptors(fAddToTrayAction, ASTViewImages.ADD_TO_TRAY); - + fDeleteAction= new Action() { @Override public void run() { @@ -1190,13 +1200,13 @@ fDeleteAction.setText("&Delete"); //$NON-NLS-1$ fDeleteAction.setToolTipText("Delete Binding from Tray"); //$NON-NLS-1$ fDeleteAction.setEnabled(false); - fDeleteAction.setImageDescriptor(ASTViewPlugin.getDefault().getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); + fDeleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); fDeleteAction.setId(ActionFactory.DELETE.getId()); fDeleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE); - + refreshASTSettingsActions(); } - + private void refreshAST() throws CoreException { ASTNode node= getASTNodeNearSelection((IStructuredSelection) fViewer.getSelection()); @@ -1209,13 +1219,13 @@ internalSetInput(fTypeRoot, offset, length); } - + protected void setASTLevel(int level, boolean doRefresh) { int oldLevel= fCurrentASTLevel; fCurrentASTLevel= level; fDialogSettings.put(SETTINGS_JLS, fCurrentASTLevel); - + if (doRefresh && fTypeRoot != null && oldLevel != fCurrentASTLevel) { try { refreshAST(); @@ -1226,25 +1236,23 @@ } } // update action state - for (int i= 0; i < fASTVersionToggleActions.length; i++) { - ASTLevelToggle curr= fASTVersionToggleActions[i]; - curr.setChecked(curr.getLevel() == fCurrentASTLevel); + for (ASTView.ASTLevelToggle action : fASTVersionToggleActions) { + action.setChecked(action.getLevel() == fCurrentASTLevel); } } - + protected void setASTInputType(int inputKind) { if (inputKind != fCurrentInputKind) { fCurrentInputKind= inputKind; fDialogSettings.put(SETTINGS_INPUT_KIND, inputKind); - for (int i= 0; i < fASTInputKindActions.length; i++) { - ASTInputKindAction curr= fASTInputKindActions[i]; - curr.setChecked(curr.getInputKind() == inputKind); + for (ASTView.ASTInputKindAction action : fASTInputKindActions) { + action.setChecked(action.getInputKind() == inputKind); } refreshASTSettingsActions(); performRefresh(); } } - + private ASTNode getASTNodeNearSelection(IStructuredSelection selection) { Object elem= selection.getFirstElement(); if (elem instanceof ASTAttribute) { @@ -1254,32 +1262,32 @@ } return null; } - + private void installModificationListener() { fCurrentDocument= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput()); fCurrentDocument.addDocumentListener(fSuperListener); } - + private void uninstallModificationListener() { if (fCurrentDocument != null) { fCurrentDocument.removeDocumentListener(fSuperListener); fCurrentDocument= null; } } - + protected void handleDocumentDisposed() { uninstallModificationListener(); } - + protected void handleDocumentChanged() { setASTUptoDate(false); } - + protected void handleSelectionChanged(ISelection selection) { fExpandAction.setEnabled(!selection.isEmpty()); fCollapseAction.setEnabled(!selection.isEmpty()); fCopyAction.setEnabled(!selection.isEmpty()); - + boolean addEnabled= false; IStructuredSelection structuredSelection= (IStructuredSelection) selection; if (structuredSelection.size() == 1 && fViewer.getTree().isFocusControl()) { @@ -1314,17 +1322,17 @@ setContentDescription(e.getStatus().getMessage()); } } - + } else { // fRoot != null && part == fEditor doLinkWithEditor(selection); } } - + private void doLinkWithEditor(ISelection selection) { ITextSelection textSelection= (ITextSelection) selection; int offset= textSelection.getOffset(); int length= textSelection.getLength(); - + ASTNode covering= NodeFinder.perform(fRoot, offset, length); if (covering != null) { fViewer.reveal(covering); @@ -1339,7 +1347,7 @@ protected void performLinkWithEditor() { fDoLinkWithEditor= fLinkWithEditor.isChecked(); fDialogSettings.put(SETTINGS_LINK_WITH_EDITOR, fDoLinkWithEditor); - + if (fDoLinkWithEditor && fEditor != null) { ISelectionProvider selectionProvider= fEditor.getSelectionProvider(); @@ -1354,10 +1362,9 @@ if (selection.isEmpty()) { fViewer.collapseAll(); } else { - Object[] selected= selection.toArray(); fViewer.getTree().setRedraw(false); - for (int i= 0; i < selected.length; i++) { - fViewer.collapseToLevel(selected[i], AbstractTreeViewer.ALL_LEVELS); + for (Object s : selection.toArray()) { + fViewer.collapseToLevel(s, AbstractTreeViewer.ALL_LEVELS); } fViewer.getTree().setRedraw(true); } @@ -1368,10 +1375,9 @@ if (selection.isEmpty()) { fViewer.expandToLevel(3); } else { - Object[] selected= selection.toArray(); fViewer.getTree().setRedraw(false); - for (int i= 0; i < selected.length; i++) { - fViewer.expandToLevel(selected[i], 3); + for (Object s : selection.toArray()) { + fViewer.expandToLevel(s, 3); } fViewer.getTree().setRedraw(true); } @@ -1387,7 +1393,7 @@ } } } - + protected void performRefresh() { if (fTypeRoot != null) { try { @@ -1412,44 +1418,44 @@ ASTViewPlugin.log(message, e); ErrorDialog.openError(getSite().getShell(), "AST View", message, e.getStatus()); //$NON-NLS-1$ } - + private void showAndLogError(String message, Throwable e) { IStatus status= new Status(IStatus.ERROR, ASTViewPlugin.getPluginId(), 0, message, e); ASTViewPlugin.log(status); ErrorDialog.openError(getSite().getShell(), "AST View", null, status); //$NON-NLS-1$ } - + protected void performCreateBindings() { fCreateBindings= fCreateBindingsAction.isChecked(); fDialogSettings.put(SETTINGS_NO_BINDINGS, !fCreateBindings); performRefresh(); } - + protected void performStatementsRecovery() { fStatementsRecovery= fStatementsRecoveryAction.isChecked(); fDialogSettings.put(SETTINGS_NO_STATEMENTS_RECOVERY, !fStatementsRecovery); performRefresh(); } - + protected void performBindingsRecovery() { fBindingsRecovery= fBindingsRecoveryAction.isChecked(); fDialogSettings.put(SETTINGS_NO_BINDINGS_RECOVERY, !fBindingsRecovery); performRefresh(); } - + protected void performIgnoreMethodBodies() { fIgnoreMethodBodies= fIgnoreMethodBodiesAction.isChecked(); fDialogSettings.put(SETTINGS_IGNORE_METHOD_BODIES, fIgnoreMethodBodies); performRefresh(); } - + protected void performFilterNonRelevant() { boolean showNonRelevant= !fFilterNonRelevantAction.isChecked(); fNonRelevantFilter.setShowNonRelevant(showNonRelevant); fDialogSettings.put(SETTINGS_SHOW_NON_RELEVANT, showNonRelevant); fViewer.refresh(); } - + protected void performFindDeclaringNode() { String msg= "Find Declaring Node from Key"; String key= askForKey(msg); @@ -1470,13 +1476,13 @@ InputDialog dialog= new InputDialog(getSite().getShell(), dialogTitle, "Key: (optionally surrounded by and <\">)", "", null); if (dialog.open() != Window.OK) return null; - + String key= dialog.getValue(); if (key.startsWith("KEY: \"") && key.endsWith("\"")) key= key.substring(6, key.length() - 1); return key; } - + protected void performParseBindingFromKey() { String msg= "Parse Binding from Key"; String key= askForKey(msg); @@ -1511,15 +1517,15 @@ fViewer.add(viewerInput, item); fViewer.setSelection(new StructuredSelection(item), true); } - + protected void performParseBindingFromElement() { InputDialog dialog= new InputDialog(getSite().getShell(), "Parse Binding from Java Element", "IJavaElement#getHandleIdentifier():", "", null); if (dialog.open() != Window.OK) return; - + String handleIdentifier= dialog.getValue(); IJavaElement handle= JavaCore.create(handleIdentifier); - + Object viewerInput= fViewer.getInput(); ASTAttribute item; if (handle == null) { @@ -1539,18 +1545,18 @@ fViewer.add(viewerInput, item); fViewer.setSelection(new StructuredSelection(item), true); } - + protected void performDoubleClick() { if (fEditor == null) { return; } - + ISelection selection = fViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); boolean isTripleClick= (obj == fPreviousDouble); fPreviousDouble= isTripleClick ? null : obj; - + if (obj instanceof ExceptionAttribute) { Throwable exception= ((ExceptionAttribute) obj).getException(); if (exception != null) { @@ -1559,11 +1565,11 @@ return; } } - + ASTNode node= null, nodeEnd= null; if (obj instanceof ASTNode) { node= (ASTNode) obj; - + } else if (obj instanceof NodeProperty) { Object val= ((NodeProperty) obj).getNode(); if (val instanceof ASTNode) { @@ -1577,7 +1583,7 @@ fViewer.getTree().getDisplay().beep(); } } - + } else if (obj instanceof Binding) { IBinding binding= ((Binding) obj).getBinding(); ASTNode declaring= fRoot.findDeclaringNode(binding); @@ -1588,12 +1594,12 @@ fViewer.getTree().getDisplay().beep(); } return; - + } else if (obj instanceof ProblemNode) { ProblemNode problemNode= (ProblemNode) obj; EditorUtility.selectInEditor(fEditor, problemNode.getOffset(), problemNode.getLength()); return; - + } else if (obj instanceof JavaElement) { IJavaElement javaElement= ((JavaElement) obj).getJavaElement(); if (javaElement instanceof IPackageFragment) { @@ -1619,7 +1625,7 @@ } return; } - + if (node != null) { int offset= isTripleClick ? fRoot.getExtendedStartPosition(node) : node.getStartPosition(); int length; @@ -1649,7 +1655,7 @@ } setTraySelection(selection); } - + private void setTraySelection(IStructuredSelection selection) { fTray.setSelection(selection, true); TreeItem[] itemSelection= fTray.getTree().getSelection(); @@ -1675,7 +1681,7 @@ fViewer.setSelection(new StructuredSelection(binding), true); } } - + protected void performDelete() { boolean removed= false; IStructuredSelection selection= (IStructuredSelection) fTray.getSelection(); @@ -1685,13 +1691,13 @@ obj= ((DynamicAttributeProperty) obj).getParent(); if (obj instanceof DynamicBindingProperty) obj= ((DynamicBindingProperty) obj).getParent(); - + removed|= fTrayRoots.remove(obj); } if (removed) fTray.setInput(fTrayRoots); } - + @Override public void setFocus() { fViewer.getControl().setFocus(); diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,20 +1,19 @@ /******************************************************************************* * Copyright (c) 2000, 2018 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.astview.views; -import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; @@ -42,21 +41,21 @@ public class ASTViewLabelProvider extends LabelProvider implements IColorProvider, IFontProvider { private int fSelectionStart; private int fSelectionLength; - + private final Color fBlue, fRed, fDarkGray, fDarkGreen, fDarkRed; private final Font fBold; - + //to dispose: private final Font fAllocatedBoldItalic; private final Color fLightRed; private Color fSelectedElemBGColor; - + public ASTViewLabelProvider() { fSelectionStart= -1; fSelectionLength= -1; - + Display display= Display.getCurrent(); - + fRed= display.getSystemColor(SWT.COLOR_RED); fDarkGray= display.getSystemColor(SWT.COLOR_DARK_GRAY); fBlue= display.getSystemColor(SWT.COLOR_DARK_BLUE); @@ -74,15 +73,15 @@ } } fLightRed= new Color(display, 255, 190, 190); - + fBold= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); FontData[] fontData= fBold.getFontData(); - for (int i= 0; i < fontData.length; i++) { - fontData[i].setStyle(fontData[i].getStyle() | SWT.ITALIC); + for (FontData fd : fontData) { + fd.setStyle(fd.getStyle() | SWT.ITALIC); } fAllocatedBoldItalic= new Font(display, fontData); } - + public void setSelectedRange(int start, int length) { fSelectionStart= start; fSelectionLength= length; @@ -98,9 +97,9 @@ } else if (obj instanceof ASTAttribute) { buf.append(((ASTAttribute) obj).getLabel()); } - return buf.toString(); + return buf.toString(); } - + private void getNodeType(ASTNode node, StringBuffer buf) { buf.append(Signature.getSimpleName(node.getClass().getName())); buf.append(" ["); //$NON-NLS-1$ @@ -115,8 +114,8 @@ buf.append(" (recovered)"); //$NON-NLS-1$ } } - - + + @Override public Image getImage(Object obj) { if (obj instanceof ASTNode) { @@ -124,7 +123,7 @@ } else if (obj instanceof ASTAttribute) { return ((ASTAttribute) obj).getImage(); } - + return null; // String imageKey = ISharedImages.IMG_OBJ_ELEMENT; // if (obj instanceof ASTNode) { @@ -139,7 +138,7 @@ return fRed; if ((element instanceof ExceptionAttribute) && ((ExceptionAttribute) element).getException() != null) return fRed; - + if (element instanceof ASTNode) { ASTNode node= (ASTNode) element; if ((node.getFlags() & ASTNode.MALFORMED) != 0) { @@ -178,18 +177,18 @@ } return null; } - + private boolean isNotProperlyNested(Object element) { if (element instanceof ASTNode) { ASTNode node= (ASTNode) element; int start= node.getStartPosition(); int end= start + node.getLength(); - + ASTNode parent= node.getParent(); if (parent != null) { int parentstart= parent.getStartPosition(); int parentend= parentstart + parent.getLength(); - + if (start < parentstart || end > parentend) { return true; } @@ -197,7 +196,7 @@ } return false; } - + private boolean isInsideNode(ASTNode node) { int start= node.getStartPosition(); int end= start + node.getLength(); @@ -206,7 +205,7 @@ } return false; } - + private boolean isInside(Object element) { if (element instanceof ASTNode) { return isInsideNode((ASTNode) element); @@ -216,8 +215,7 @@ if (object instanceof ASTNode) { return isInsideNode((ASTNode) object); } else if (object instanceof List) { - for (Iterator iter= ((List) object).iterator(); iter.hasNext(); ) { - Object child= iter.next(); + for (Object child : (List) object) { if (isInside(child)) { return true; } @@ -238,7 +236,7 @@ } return null; } - + @Override public void dispose() { super.dispose(); @@ -246,5 +244,5 @@ fLightRed.dispose(); fAllocatedBoldItalic.dispose(); } - + } diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -39,28 +39,28 @@ * */ public class Binding extends ASTAttribute { - + private final IBinding fBinding; private final String fLabel; private final Object fParent; private final boolean fIsRelevant; - + public Binding(Object parent, String label, IBinding binding, boolean isRelevant) { fParent= parent; fBinding= binding; fLabel= label; fIsRelevant= isRelevant; } - + @Override public Object getParent() { return fParent; } - + public IBinding getBinding() { return fBinding; } - + public boolean hasBindingProperties() { return fBinding != null; @@ -69,12 +69,12 @@ public boolean isRelevant() { return fIsRelevant; } - - + + private static boolean isType(int typeKinds, int kind) { return (typeKinds & kind) != 0; } - + @Override public Object[] getChildren() { try { @@ -104,25 +104,25 @@ res.add(new Binding(this, "VARIABLE DECLARATION", variableBinding.getVariableDeclaration(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS SYNTHETIC", fBinding.isSynthetic(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS DEPRECATED", fBinding.isDeprecated(), true)); //$NON-NLS-1$ - res.add(new BindingProperty(this, "CONSTANT VALUE", variableBinding.getConstantValue(), true)); //$NON-NLS-1$ //$NON-NLS-2$ + res.add(new BindingProperty(this, "CONSTANT VALUE", variableBinding.getConstantValue(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS EFFECTIVELY FINAL", variableBinding.isEffectivelyFinal(), true)); //$NON-NLS-1$ break; - + case IBinding.PACKAGE: IPackageBinding packageBinding= (IPackageBinding) fBinding; res.add(new BindingProperty(this, "IS UNNAMED", packageBinding.isUnnamed(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS SYNTHETIC", fBinding.isSynthetic(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS DEPRECATED", fBinding.isDeprecated(), true)); //$NON-NLS-1$ break; - + case IBinding.TYPE: ITypeBinding typeBinding= (ITypeBinding) fBinding; res.add(new BindingProperty(this, "QUALIFIED NAME", typeBinding.getQualifiedName(), true)); //$NON-NLS-1$ - + int typeKind= getTypeKind(typeBinding); boolean isRefType= isType(typeKind, REF_TYPE); final boolean isNonPrimitive= ! isType(typeKind, PRIMITIVE_TYPE); - + StringBuffer kinds= new StringBuffer("KIND:"); //$NON-NLS-1$ if (typeBinding.isArray()) kinds.append(" isArray"); //$NON-NLS-1$ if (typeBinding.isCapture()) kinds.append(" isCapture"); //$NON-NLS-1$ @@ -135,8 +135,8 @@ if (typeBinding.isClass()) kinds.append(" isClass"); //$NON-NLS-1$ if (typeBinding.isInterface()) kinds.append(" isInterface"); //$NON-NLS-1$ if (typeBinding.isEnum()) kinds.append(" isEnum"); //$NON-NLS-1$ - res.add(new BindingProperty(this, kinds, true)); //$NON-NLS-1$ - + res.add(new BindingProperty(this, kinds, true)); + StringBuffer generics= new StringBuffer("GENERICS:"); //$NON-NLS-1$ if (typeBinding.isRawType()) generics.append(" isRawType"); //$NON-NLS-1$ if (typeBinding.isGenericType()) generics.append(" isGenericType"); //$NON-NLS-1$ @@ -144,7 +144,7 @@ if (!isType(typeKind, GENERIC | PARAMETRIZED)) { generics.append(" (non-generic, non-parameterized)"); } - res.add(new BindingProperty(this, generics, isRefType)); //$NON-NLS-1$ + res.add(new BindingProperty(this, generics, isRefType)); res.add(new Binding(this, "ELEMENT TYPE", typeBinding.getElementType(), isType(typeKind, ARRAY_TYPE))); //$NON-NLS-1$ res.add(new Binding(this, "COMPONENT TYPE", typeBinding.getComponentType(), isType(typeKind, ARRAY_TYPE))); //$NON-NLS-1$ @@ -162,7 +162,7 @@ res.add(new BindingProperty(this, createArrayTypeLabel, msg, false)); } } - + StringBuffer origin= new StringBuffer("ORIGIN:"); //$NON-NLS-1$ if (typeBinding.isTopLevel()) origin.append(" isTopLevel"); //$NON-NLS-1$ if (typeBinding.isNested()) origin.append(" isNested"); //$NON-NLS-1$ @@ -170,7 +170,7 @@ if (typeBinding.isMember()) origin.append(" isMember"); //$NON-NLS-1$ if (typeBinding.isAnonymous()) origin.append(" isAnonymous"); //$NON-NLS-1$ res.add(new BindingProperty(this, origin, isRefType)); - + res.add(new BindingProperty(this, "IS FROM SOURCE", typeBinding.isFromSource(), isType(typeKind, REF_TYPE | VARIABLE_TYPE | CAPTURE_TYPE))); //$NON-NLS-1$ res.add(new Binding(this, "PACKAGE", typeBinding.getPackage(), isRefType)); //$NON-NLS-1$ @@ -179,7 +179,7 @@ res.add(new Binding(this, "DECLARING MEMBER", typeBinding.getDeclaringMember(), typeBinding.isLocal())); //$NON-NLS-1$ res.add(new BindingProperty(this, "MODIFIERS", getModifiersString(fBinding.getModifiers(), false), isRefType)); //$NON-NLS-1$ res.add(new BindingProperty(this, "BINARY NAME", typeBinding.getBinaryName(), true)); //$NON-NLS-1$ - + String isTypeDeclaration= typeBinding == typeBinding.getTypeDeclaration() ? " ( == this)" : " ( != this)"; res.add(new Binding(this, "TYPE DECLARATION" + isTypeDeclaration, typeBinding.getTypeDeclaration(), true)); //$NON-NLS-1$ String isErasure= typeBinding == typeBinding.getErasure() ? " ( == this)" : " ( != this)"; @@ -203,7 +203,7 @@ res.add(new BindingProperty(this, "IS DEPRECATED", fBinding.isDeprecated(), isRefType)); //$NON-NLS-1$ res.add(new BindingProperty(this, "TYPE ANNOTATIONS", typeBinding.getTypeAnnotations(), true)); //$NON-NLS-1$ break; - + case IBinding.METHOD: IMethodBinding methodBinding= (IMethodBinding) fBinding; res.add(new BindingProperty(this, "IS CONSTRUCTOR", methodBinding.isConstructor(), true)); //$NON-NLS-1$ @@ -215,23 +215,23 @@ res.add(new BindingProperty(this, "PARAMETER TYPES", methodBinding.getParameterTypes(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS VARARGS", methodBinding.isVarargs(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "EXCEPTION TYPES", methodBinding.getExceptionTypes(), true)); //$NON-NLS-1$ - + StringBuffer genericsM= new StringBuffer("GENERICS:"); //$NON-NLS-1$ if (methodBinding.isRawMethod()) genericsM.append(" isRawMethod"); //$NON-NLS-1$ if (methodBinding.isGenericMethod()) genericsM.append(" isGenericMethod"); //$NON-NLS-1$ if (methodBinding.isParameterizedMethod()) genericsM.append(" isParameterizedMethod"); //$NON-NLS-1$ res.add(new BindingProperty(this, genericsM, true)); - + String isMethodDeclaration= methodBinding == methodBinding.getMethodDeclaration() ? " ( == this)" : " ( != this)"; res.add(new Binding(this, "METHOD DECLARATION" + isMethodDeclaration, methodBinding.getMethodDeclaration(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "TYPE PARAMETERS", methodBinding.getTypeParameters(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "TYPE ARGUMENTS", methodBinding.getTypeArguments(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS SYNTHETIC", fBinding.isSynthetic(), true)); //$NON-NLS-1$ res.add(new BindingProperty(this, "IS DEPRECATED", fBinding.isDeprecated(), true)); //$NON-NLS-1$ - + res.add(new BindingProperty(this, "IS ANNOTATION MEMBER", methodBinding.isAnnotationMember(), true)); //$NON-NLS-1$ res.add(Binding.createValueAttribute(this, "DEFAULT VALUE", methodBinding.getDefaultValue())); - + int parameterCount= methodBinding.getParameterTypes().length; BindingProperty[] parametersAnnotations= new BindingProperty[parameterCount]; for (int i= 0; i < parameterCount; i++) { @@ -239,21 +239,21 @@ } res.add(new BindingProperty(this, "PARAMETER ANNOTATIONS", parametersAnnotations, true)); break; - + case IBinding.ANNOTATION: IAnnotationBinding annotationBinding= (IAnnotationBinding) fBinding; res.add(new Binding(this, "ANNOTATION TYPE", annotationBinding.getAnnotationType(), true)); res.add(new BindingProperty(this, "DECLARED MEMBER VALUE PAIRS", annotationBinding.getDeclaredMemberValuePairs(), true)); res.add(new BindingProperty(this, "ALL MEMBER VALUE PAIRS", annotationBinding.getAllMemberValuePairs(), true)); break; - + case IBinding.MEMBER_VALUE_PAIR: IMemberValuePairBinding memberValuePairBinding= (IMemberValuePairBinding) fBinding; res.add(new Binding(this, "METHOD BINDING", memberValuePairBinding.getMethodBinding(), true)); res.add(new BindingProperty(this, "IS DEFAULT", memberValuePairBinding.isDefault(), true)); res.add(Binding.createValueAttribute(this, "VALUE", memberValuePairBinding.getValue())); break; - + case IBinding.MODULE: IModuleBinding moduleBinding= (IModuleBinding) fBinding; res.add(new BindingProperty(this, "REQUIRED MODULES", moduleBinding.getRequiredModules(), true)); @@ -265,7 +265,7 @@ res.add(createPropertiesWithSecondary(moduleBinding.getServices(), "SERVICES", "PROVIDES", "WITH", moduleBinding::getImplementations)); break; - + default: break; } @@ -327,7 +327,7 @@ private final static int GENERIC= 1 << 8; private final static int PARAMETRIZED= 1 << 9; - + private int getTypeKind(ITypeBinding typeBinding) { if (typeBinding.isArray()) return ARRAY_TYPE; if (typeBinding.isCapture()) return CAPTURE_TYPE; @@ -335,10 +335,10 @@ if (typeBinding.isPrimitive()) return PRIMITIVE_TYPE; if (typeBinding.isTypeVariable()) return VARIABLE_TYPE; if (typeBinding.isWildcardType()) return WILDCARD_TYPE; - + if (typeBinding.isGenericType()) return REF_TYPE | GENERIC; if (typeBinding.isParameterizedType() || typeBinding.isRawType()) return REF_TYPE | PARAMETRIZED; - + return REF_TYPE; } @@ -393,7 +393,7 @@ case IBinding.MODULE: buf.append(fBinding.getName()); } - + } else { buf.append("null"); //$NON-NLS-1$ } @@ -403,7 +403,7 @@ public static void appendAnnotatedQualifiedName(StringBuffer buf, ITypeBinding typeBinding) { String debugString= typeBinding.toString(); // XXX: hack, but that's OK for a debugging tool... - if (debugString.indexOf('\n') == -1 || typeBinding.getTypeAnnotations().length != 0) { + if (debugString.indexOf('\n') == -1 || typeBinding.getTypeAnnotations().length != 0) { // one-liner || outermost type has type annotations buf.append(debugString); } else { @@ -420,7 +420,7 @@ public String toString() { return getLabel(); } - + /* * @see java.lang.Object#equals(java.lang.Object) */ @@ -431,7 +431,7 @@ if (obj == null || !obj.getClass().equals(getClass())) { return false; } - + Binding other= (Binding) obj; if (fParent == null) { if (other.fParent != null) @@ -439,24 +439,24 @@ } else if (! fParent.equals(other.fParent)) { return false; } - + if (fBinding == null) { if (other.fBinding != null) return false; } else if (! fBinding.equals(other.fBinding)) { return false; } - + if (fLabel == null) { if (other.fLabel != null) return false; } else if (! fLabel.equals(other.fLabel)) { return false; } - + return true; } - + /* * @see java.lang.Object#hashCode() */ @@ -506,7 +506,7 @@ * Creates an {@link ASTAttribute} for a value from * {@link IMemberValuePairBinding#getValue()} or from * {@link IMethodBinding#getDefaultValue()}. - * + * * @param parent the parent node * @param name the attribute name * @param value the attribute value @@ -517,39 +517,39 @@ if (value instanceof IBinding) { IBinding binding= (IBinding) value; res= new Binding(parent, name + ": " + getBindingLabel(binding), binding, true); - + } else if (value instanceof String) { res= new GeneralAttribute(parent, name, getEscapedStringLiteral((String) value)); - + } else if (value instanceof Object[]) { res= new GeneralAttribute(parent, name, (Object[]) value); - + } else if (value instanceof ASTAttribute) { res= (ASTAttribute) value; - + } else { res= new GeneralAttribute(parent, name, value); } return res; } - + public static String getEscapedStringLiteral(String stringValue) { - StringLiteral stringLiteral= AST.newAST(ASTView.JLS_LATEST).newStringLiteral(); + StringLiteral stringLiteral= AST.newAST(ASTView.JLS_LATEST, false).newStringLiteral(); stringLiteral.setLiteralValue(stringValue); return stringLiteral.getEscapedValue(); } - + public static String getEscapedCharLiteral(char charValue) { - CharacterLiteral charLiteral= AST.newAST(ASTView.JLS_LATEST).newCharacterLiteral(); + CharacterLiteral charLiteral= AST.newAST(ASTView.JLS_LATEST, false).newCharacterLiteral(); charLiteral.setCharValue(charValue); return charLiteral.getEscapedValue(); } - + private static StringBuffer getModifiersString(int flags, boolean isMethod) { StringBuffer sb = new StringBuffer().append("0x").append(Integer.toHexString(flags)).append(" ("); int prologLen= sb.length(); int rest= flags; - + rest&= ~ appendFlag(sb, flags, Modifier.PUBLIC, "public "); rest&= ~ appendFlag(sb, flags, Modifier.PRIVATE, "private "); rest&= ~ appendFlag(sb, flags, Modifier.PROTECTED, "protected "); @@ -565,7 +565,7 @@ rest&= ~ appendFlag(sb, flags, Modifier.NATIVE, "native "); rest&= ~ appendFlag(sb, flags, Modifier.ABSTRACT, "abstract "); rest&= ~ appendFlag(sb, flags, Modifier.STRICTFP, "strictfp "); - + if (rest != 0) sb.append("unknown:0x").append(Integer.toHexString(rest)).append(" "); int len = sb.length(); @@ -574,7 +574,7 @@ sb.append(")"); return sb; } - + private static int appendFlag(StringBuffer sb, int flags, int flag, String name) { if ((flags & flag) != 0) { sb.append(name); diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/BindingProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/BindingProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/BindingProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/BindingProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2017 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -44,21 +44,21 @@ fValues= null; fIsRelevant= isRelevant; } - + public BindingProperty(Binding parent, String name, boolean value, boolean isRelevant) { fParent= parent; fName= name + ": " + String.valueOf(value); //$NON-NLS-1$ fValues= null; fIsRelevant= isRelevant; } - + public BindingProperty(Binding parent, String name, int value, boolean isRelevant) { fParent= parent; fName= name + ": " + String.valueOf(value); //$NON-NLS-1$ fValues= null; fIsRelevant= isRelevant; } - + public BindingProperty(Binding parent, String name, IBinding[] bindings, boolean isRelevant) { fParent= parent; if (bindings == null) { @@ -70,7 +70,7 @@ } fIsRelevant= isRelevant; } - + public BindingProperty(Binding parent, String name, ASTAttribute[] children, boolean isRelevant) { fParent= parent; if (children == null) { @@ -80,14 +80,14 @@ fName= name + " (" + fValues.length + ')'; //$NON-NLS-1$ fIsRelevant= isRelevant; } - + public BindingProperty(Binding parent, StringBuffer label, boolean isRelevant) { fParent= parent; fName= label.toString(); fValues= null; fIsRelevant= isRelevant; } - + private Binding[] createBindings(IBinding[] bindings, boolean isRelevant) { Binding[] res= new Binding[bindings.length]; for (int i= 0; i < res.length; i++) { @@ -100,7 +100,7 @@ public Object getParent() { return fParent; } - + @Override public Object[] getChildren() { if (fValues != null) { @@ -108,7 +108,7 @@ } return EMPTY; } - + @Override public String getLabel() { return fName; @@ -118,12 +118,12 @@ public Image getImage() { return null; } - + @Override public String toString() { return getLabel(); } - + public boolean isRelevant() { return fIsRelevant; } @@ -138,7 +138,7 @@ if (obj == null || !obj.getClass().equals(getClass())) { return false; } - + BindingProperty other= (BindingProperty) obj; if (fParent == null) { if (other.fParent != null) @@ -146,17 +146,17 @@ } else if (! fParent.equals(other.fParent)) { return false; } - + if (fName == null) { if (other.fName != null) return false; } else if (! fName.equals(other.fName)) { return false; } - + return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/CommentsProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/CommentsProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/CommentsProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/CommentsProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -24,7 +24,7 @@ * */ public class CommentsProperty extends ASTAttribute { - + private final CompilationUnit fRoot; public CommentsProperty(CompilationUnit root) { @@ -65,7 +65,7 @@ } return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicAttributeProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicAttributeProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicAttributeProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicAttributeProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -24,10 +24,10 @@ protected static final String N_A= "N/A"; //$NON-NLS-1$ private final Object fParent; private final String fName; - + private Object fViewerElement; private String fLabel= ""; - + public DynamicAttributeProperty(Object parentAttribute, String name) { fParent= parentAttribute; fName= name; @@ -42,15 +42,15 @@ public Object[] getChildren() { return EMPTY; } - + public void setViewerElement(Object viewerAttribute) { if (fViewerElement == viewerAttribute) return; - + fViewerElement= viewerAttribute; fException= null; Object trayObject= ASTView.unwrapAttribute(fParent); - StringBuffer buf= new StringBuffer(fName); + StringBuilder buf= new StringBuilder(fName); if (viewerAttribute != null) { Object viewerObject= ASTView.unwrapAttribute(viewerAttribute); try { @@ -84,8 +84,8 @@ /** * Executes this dynamic attribute property's query in a protected environment. * A {@link RuntimeException} thrown by this method is made available via - * {@link #getException()}. - * + * {@link #getException()}. + * * @param viewerObject the object of the element selected in the AST viewer, or null iff none * @param trayObject the object of the element selected in the comparison tray, or null iff none * @return this property's result diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicBindingProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicBindingProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicBindingProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/DynamicBindingProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -23,10 +23,10 @@ protected static final String N_A= "N/A"; //$NON-NLS-1$ private final Binding fParent; - + private Binding fViewerElement; private String fLabel= ""; - + public DynamicBindingProperty(Binding parent) { fParent= parent; } @@ -40,15 +40,15 @@ public Object[] getChildren() { return EMPTY; } - + public void setViewerElement(Binding viewerElement) { if (fViewerElement == viewerElement) return; - + fViewerElement= viewerElement; fException= null; IBinding trayBinding= fParent.getBinding(); - StringBuffer buf= new StringBuffer(getName()); + StringBuilder buf= new StringBuilder(getName()); if (viewerElement != null) { IBinding viewerBinding= viewerElement.getBinding(); try { @@ -70,12 +70,12 @@ } fLabel= buf.toString(); } - + /** * Executes this dynamic binding property's query in a protected environment. * A {@link RuntimeException} thrown by this method is made available via - * {@link #getException()}. - * + * {@link #getException()}. + * * @param viewerBinding the binding of the element selected in the AST viewer, or null iff none * @param trayBinding the binding of the element selected in the comparison tray, or null iff none * @return this property's result diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Error.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Error.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Error.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Error.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -18,10 +18,10 @@ public class Error extends ExceptionAttribute { - + private final Object fParent; private final String fLabel; - + public Error(Object parent, String label, Throwable thrownException) { fParent= parent; fLabel= label; @@ -47,7 +47,7 @@ public Object getParent() { return fParent; } - + /* * @see java.lang.Object#equals(java.lang.Object) */ @@ -58,7 +58,7 @@ if (obj == null || !obj.getClass().equals(getClass())) { return false; } - + Error other= (Error) obj; if (fParent == null) { if (other.fParent != null) @@ -66,17 +66,17 @@ } else if (! fParent.equals(other.fParent)) { return false; } - + if (fLabel == null) { if (other.fLabel != null) return false; } else if (! fLabel.equals(other.fLabel)) { return false; } - + return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ExceptionAttribute.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ExceptionAttribute.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ExceptionAttribute.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ExceptionAttribute.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/GeneralAttribute.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/GeneralAttribute.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/GeneralAttribute.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/GeneralAttribute.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -18,23 +18,23 @@ public class GeneralAttribute extends ASTAttribute { - + private final Object fParent; private final String fLabel; private final Object[] fChildren; - + public GeneralAttribute(Object parent, String name, Object value) { fParent= parent; fLabel= name + ": " + String.valueOf(value); fChildren= EMPTY; } - + public GeneralAttribute(Object parent, String label) { fParent= parent; fLabel= label; fChildren= EMPTY; } - + public GeneralAttribute(Object parent, String name, Object[] children) { fParent= parent; if (children == null) { @@ -48,7 +48,7 @@ fLabel= name + " (" + String.valueOf(fChildren.length) + ')'; } } - + private Object[] createChildren(Object[] children) { ASTAttribute[] res= new ASTAttribute[children.length]; for (int i= 0; i < res.length; i++) { @@ -73,12 +73,12 @@ public String getLabel() { return fLabel; } - + @Override public Image getImage() { return null; } - + /* * @see java.lang.Object#equals(java.lang.Object) */ @@ -89,7 +89,7 @@ if (obj == null || !obj.getClass().equals(getClass())) { return false; } - + GeneralAttribute other= (GeneralAttribute) obj; if (fParent == null) { if (other.fParent != null) @@ -97,17 +97,17 @@ } else if (! fParent.equals(other.fParent)) { return false; } - + if (fLabel == null) { if (other.fLabel != null) return false; } else if (! fLabel.equals(other.fLabel)) { return false; } - + return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/JavaElement.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/JavaElement.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/JavaElement.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/JavaElement.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -25,10 +25,10 @@ public class JavaElement extends ASTAttribute { private static final long LABEL_OPTIONS= - JavaElementLabels.F_APP_TYPE_SIGNATURE | JavaElementLabels.M_PARAMETER_TYPES | + JavaElementLabels.F_APP_TYPE_SIGNATURE | JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_APP_RETURNTYPE | JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.T_TYPE_PARAMETERS |JavaElementLabels.USE_RESOLVED; - + private final IJavaElement fJavaElement; private final Object fParent; @@ -36,11 +36,11 @@ fParent= parent; fJavaElement= javaElement; } - + public IJavaElement getJavaElement() { return fJavaElement; } - + @Override public Object getParent() { return fParent; @@ -62,7 +62,7 @@ + (fJavaElement.exists() ? "" : " (does not exist)"); //$NON-NLS-1$//$NON-NLS-2$ } } - + @Override public Image getImage() { return null; @@ -80,7 +80,7 @@ if (obj == null || !obj.getClass().equals(getClass())) { return false; } - + JavaElement other= (JavaElement) obj; if (fParent == null) { if (other.fParent != null) @@ -88,17 +88,17 @@ } else if (! fParent.equals(other.fParent)) { return false; } - + if (fJavaElement == null) { if (other.fJavaElement != null) return false; } else if (! fJavaElement.equals(other.fJavaElement)) { return false; } - + return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NodeProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NodeProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NodeProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NodeProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -21,20 +21,20 @@ import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; public class NodeProperty extends ASTAttribute { - + private ASTNode fParent; private StructuralPropertyDescriptor fProperty; - + public NodeProperty(ASTNode parent, StructuralPropertyDescriptor property) { fParent= parent; fProperty= property; } - + @Override public Object getParent() { return fParent; } - + @Override public Object[] getChildren() { Object child= getNode(); @@ -48,9 +48,9 @@ @Override public String getLabel() { - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); buf.append(getPropertyName()); - + if (fProperty.isSimpleProperty()) { buf.append(": "); //$NON-NLS-1$ Object node= getNode(); @@ -76,17 +76,17 @@ public Image getImage() { return null; } - + public Object getNode() { return fParent.getStructuralProperty(fProperty); } - + public String getPropertyName() { return toConstantName(fProperty.getId()); } - + private static String toConstantName(String string) { - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); for (int i= 0; i < string.length(); i++) { char ch= string.charAt(i); if (i != 0 && Character.isUpperCase(ch)) { @@ -96,7 +96,7 @@ } return buf.toString(); } - + @Override public boolean equals(Object o) { if (this == o) { @@ -113,7 +113,7 @@ public int hashCode() { return fParent.hashCode() * 31 + fProperty.hashCode(); } - + @Override public String toString() { return getLabel(); diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NonRelevantFilter.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NonRelevantFilter.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NonRelevantFilter.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/NonRelevantFilter.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -18,13 +18,13 @@ import org.eclipse.jface.viewers.ViewerFilter; public class NonRelevantFilter extends ViewerFilter { - + private boolean fShowNonRelevant; - + public boolean isShowNonRelevant() { return fShowNonRelevant; } - + public void setShowNonRelevant(boolean showNonRelevant) { fShowNonRelevant= showNonRelevant; } @@ -33,7 +33,7 @@ public boolean select(Viewer viewer, Object parentElement, Object element) { if (fShowNonRelevant) return true; - + if (element instanceof Binding) { return ((Binding) element).isRelevant(); } @@ -42,6 +42,6 @@ } return true; } - + } diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -34,7 +34,7 @@ fParent= parent; fProblem= problem; } - + @Override public Object getParent() { return fParent; @@ -44,7 +44,7 @@ public Object[] getChildren() { String[] arguments= fProblem.getArguments(); ArrayList children= new ArrayList<>(); - + children.add(new GeneralAttribute(this, "CONSTANT NAME", getConstantName())); children.add(new GeneralAttribute(this, "ID", getErrorLabel())); children.add(new GeneralAttribute(this, "OPTION FOR CONFIGURABLE SEVERITY", JavaCore.getOptionForConfigurableSeverity(fProblem.getID()))); @@ -60,10 +60,10 @@ @Override public String getLabel() { - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); int offset= fProblem.getSourceStart(); int length= fProblem.getSourceEnd() + 1 - offset; - + if (fProblem.isError()) buf.append("E"); if (fProblem.isWarning()) @@ -72,14 +72,14 @@ buf.append("I"); buf.append('[').append(offset).append(", ").append(length).append(']').append(' '); buf.append(fProblem.getMessage()); - + return buf.toString(); } - + private String getErrorLabel() { int id= fProblem.getID(); - StringBuffer buf= new StringBuffer(); - + StringBuilder buf= new StringBuilder(); + if ((id & IProblem.TypeRelated) != 0) { buf.append("TypeRelated + "); //$NON-NLS-1$ } @@ -105,17 +105,15 @@ buf.append("Javadoc + "); //$NON-NLS-1$ } buf.append(id & IProblem.IgnoreCategoriesMask); - + buf.append(" = 0x").append(Integer.toHexString(id)).append(" = ").append(id); - + return buf.toString(); } - + private String getConstantName() { int id= fProblem.getID(); - Field[] fields= IProblem.class.getFields(); - for (int i= 0; i < fields.length; i++) { - Field f= fields[i]; + for (Field f : IProblem.class.getFields()) { try { if (f.getType() == int.class && f.getInt(f) == id) { return "IProblem." + f.getName(); @@ -126,17 +124,17 @@ } return ""; } - + private String getCategoryCode() { CategorizedProblem categorized= (CategorizedProblem) fProblem; int categoryID= categorized.getCategoryID(); - StringBuffer buf= new StringBuffer(); - + StringBuilder buf= new StringBuilder(); + switch (categoryID) { case CategorizedProblem.CAT_UNSPECIFIED: buf.append("Unspecified"); break; - + case CategorizedProblem.CAT_BUILDPATH: buf.append("Buildpath"); break; @@ -189,12 +187,12 @@ buf.append(""); break; } - + buf.append(" = ").append(categoryID); return buf.toString(); } - + @Override public Image getImage() { return null; @@ -206,7 +204,7 @@ public int getOffset() { return fProblem.getSourceStart(); } - + /** * @return Returns the length of the problem */ @@ -224,7 +222,7 @@ if (obj == null || !obj.getClass().equals(getClass())) { return false; } - + ProblemNode other= (ProblemNode) obj; if (fParent == null) { if (other.fParent != null) @@ -232,17 +230,17 @@ } else if (! fParent.equals(other.fParent)) { return false; } - + if (fProblem== null) { if (other.fProblem != null) return false; } else if (! fProblem.equals(other.fProblem)) { return false; } - + return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemsProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemsProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemsProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemsProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -23,7 +23,7 @@ * */ public class ProblemsProperty extends ASTAttribute { - + private final CompilationUnit fRoot; public ProblemsProperty(CompilationUnit root) { @@ -67,7 +67,7 @@ } return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/SettingsProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/SettingsProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/SettingsProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/SettingsProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; public class SettingsProperty extends ASTAttribute { - + private final CompilationUnit fRoot; public SettingsProperty(CompilationUnit root) { @@ -65,7 +65,7 @@ } return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayContentProvider.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayContentProvider.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayContentProvider.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayContentProvider.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -25,12 +25,12 @@ public class TrayContentProvider implements ITreeContentProvider { - + public static final int DEFAULT_CHILDREN_COUNT= 7; - + protected static final String N_A= "N/A"; //$NON-NLS-1$ protected static final Object[] EMPTY= new Object[0]; - + /* * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ @@ -39,25 +39,25 @@ ArrayList result= new ArrayList<>(); if (parentElement instanceof ExceptionAttribute) return EMPTY; - + addObjectComparisons(result, parentElement); - + if (parentElement instanceof Binding) { Binding trayElement= (Binding) parentElement; IBinding trayBinding= trayElement.getBinding(); - + addBindingComparisons(result, trayElement); if (trayBinding instanceof ITypeBinding) addTypeBindingComparions(result, trayElement); if (trayBinding instanceof IMethodBinding) addMethodBindingComparions(result, trayElement); - + } else { } - + return result.toArray(); } - + private void addObjectComparisons(ArrayList result, Object trayElement) { class IdentityProperty extends DynamicAttributeProperty { public IdentityProperty(Object parent) { @@ -67,9 +67,9 @@ protected String executeQuery(Object viewerObject, Object trayObject) { return Boolean.toString(viewerObject == trayObject); } - } + } result.add(new IdentityProperty(trayElement)); - + class EqualsProperty extends DynamicAttributeProperty { public EqualsProperty(Object parent) { super(parent, "*.equals(this): "); @@ -81,7 +81,7 @@ else return "* is null"; } - } + } result.add(new EqualsProperty(trayElement)); } @@ -101,9 +101,9 @@ else return "* is null"; //$NON-NLS-1$ } - } + } result.add(new IsEqualToProperty(trayElement)); - + class KeysEqualProperty extends DynamicBindingProperty { public KeysEqualProperty(Binding parent) { super(parent); @@ -123,7 +123,7 @@ else return Boolean.toString(viewerBinding.getKey().equals(trayBinding.getKey())); } - } + } result.add(new KeysEqualProperty(trayElement)); } @@ -146,9 +146,9 @@ return "* not an ITypeBinding"; //$NON-NLS-1$ } } - } + } result.add(new IsSubTypeCompatibleProperty(trayElement)); - + class IsCastCompatibleProperty extends DynamicBindingProperty { public IsCastCompatibleProperty(Binding parent) { super(parent); @@ -167,9 +167,9 @@ return "* not an ITypeBinding"; //$NON-NLS-1$ } } - } + } result.add(new IsCastCompatibleProperty(trayElement)); - + class IsAssignmentCompatibleProperty extends DynamicBindingProperty { public IsAssignmentCompatibleProperty(Binding parent) { super(parent); @@ -188,7 +188,7 @@ return "* not an ITypeBinding"; //$NON-NLS-1$ } } - } + } result.add(new IsAssignmentCompatibleProperty(trayElement)); } @@ -211,9 +211,9 @@ return "* not an IMethodBinding"; //$NON-NLS-1$ } } - } + } result.add(new OverridesProperty(trayElement)); - + class IsSubsignatureProperty extends DynamicBindingProperty { public IsSubsignatureProperty(Binding parent) { super(parent); @@ -232,7 +232,7 @@ return "* not an IMethodBinding"; //$NON-NLS-1$ } } - } + } result.add(new IsSubsignatureProperty(trayElement)); } @@ -247,7 +247,7 @@ return null; } } - + /* * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) */ @@ -255,7 +255,7 @@ public boolean hasChildren(Object element) { return ! (element instanceof DynamicAttributeProperty || element instanceof DynamicBindingProperty); } - + /* * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ @@ -265,7 +265,7 @@ return ((ArrayList) inputElement).toArray(); return EMPTY; } - + /* * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ @@ -273,7 +273,7 @@ public void dispose() { // do nothing } - + /* * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayLabelProvider.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayLabelProvider.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayLabelProvider.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TrayLabelProvider.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -27,27 +27,27 @@ import org.eclipse.jdt.core.dom.ASTNode; public class TrayLabelProvider extends LabelProvider implements IColorProvider { - + private Color fBlue, fRed; private Color fWidgetForeground; - + private Object fViewerElement; - + public TrayLabelProvider() { Display display= Display.getCurrent(); - + fRed= display.getSystemColor(SWT.COLOR_RED); fBlue= display.getSystemColor(SWT.COLOR_DARK_BLUE); fWidgetForeground= display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); } - + public void setViewerElement(Object viewerElement) { if (fViewerElement != viewerElement) { fViewerElement= viewerElement; fireLabelProviderChanged(new LabelProviderChangedEvent(this)); } } - + @Override public String getText(Object obj) { if (obj instanceof DynamicBindingProperty) { @@ -66,7 +66,7 @@ return ""; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126017 } } - + @Override public Image getImage(Object obj) { if (obj instanceof DynamicBindingProperty) { @@ -83,7 +83,7 @@ return null; } } - + /* * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() */ @@ -92,31 +92,31 @@ super.dispose(); fViewerElement= null; } - + @Override public Color getForeground(Object element) { if (element instanceof Binding) { return fBlue; - + } else if (element instanceof ExceptionAttribute) { if (element instanceof DynamicBindingProperty) { ((DynamicBindingProperty) element).setViewerElement(fViewerElement instanceof Binding ? (Binding) fViewerElement : null); } else if (element instanceof DynamicAttributeProperty) { ((DynamicAttributeProperty) element).setViewerElement(fViewerElement); } - + if (((ExceptionAttribute) element).getException() == null) // return null; //Bug 75022: Does not work when label is updated (retains old color, doesn't get default) //TODO remove hackaround when bug 75022 is fixed return fWidgetForeground; else return fRed; - + } else { return null; // normal color } } - + /* * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) */ @@ -124,5 +124,5 @@ public Color getBackground(Object element) { return null; } - + } diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TreeCopyAction.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TreeCopyAction.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TreeCopyAction.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/TreeCopyAction.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -15,11 +15,8 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import org.eclipse.jdt.astview.ASTViewPlugin; - import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; @@ -30,6 +27,7 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchCommandConstants; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; @@ -61,7 +59,7 @@ } @Override public String toString() { - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); if (fSelected) buf.append("* "); //$NON-NLS-1$ buf.append(trim(fTreeItem.getText())).append(" ["); //$NON-NLS-1$ @@ -80,15 +78,15 @@ return string; } } - + private final Tree[] fTrees; - + public TreeCopyAction(Tree[] trees) { fTrees= trees; setText("&Copy"); //$NON-NLS-1$ setToolTipText("Copy to Clipboard"); //$NON-NLS-1$ setEnabled(false); - setImageDescriptor(ASTViewPlugin.getDefault().getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); + setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); setId(ActionFactory.COPY.getId()); setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); } @@ -96,19 +94,19 @@ @Override public void run() { Tree tree= null; - for (int i= 0; i < fTrees.length; i++) { - if (fTrees[i].isFocusControl()) { - tree= fTrees[i]; + for (Tree t : fTrees) { + if (t.isFocusControl()) { + tree= t; break; } } if (tree == null) return; - + TreeItem[] selection= tree.getSelection(); if (selection.length == 0) return; - + Clipboard clipboard= null; try { clipboard= new Clipboard(tree.getDisplay()); @@ -127,9 +125,8 @@ HashMap elementToTreeObj= new HashMap<>(); List roots= new ArrayList<>(); int indent= Integer.MIN_VALUE; - - for (int i= 0; i < selection.length; i++) { - TreeItem item= selection[i]; + + for (TreeItem item : selection) { TreeObject treeObj= elementToTreeObj.get(item); if (treeObj == null) { treeObj= new TreeObject(item, true); @@ -169,8 +166,7 @@ } private void appendSelectionObjects(StringBuffer buffer, int indent, List selObjs) { - for (Iterator iter= selObjs.iterator(); iter.hasNext();) { - TreeObject selObj= iter.next(); + for (TreeObject selObj : selObjs) { if (selObj.isSelected()) { buffer.append('\n'); for (int d= 0; d < indent; d++) diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/WellKnownTypesProperty.java eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/WellKnownTypesProperty.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/WellKnownTypesProperty.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/WellKnownTypesProperty.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; public class WellKnownTypesProperty extends ASTAttribute { - + public static final String[] WELL_KNOWN_TYPES = { "boolean", "byte", @@ -52,7 +52,7 @@ "_.$UnknownType$" }; - + private final CompilationUnit fRoot; public WellKnownTypesProperty(CompilationUnit root) { @@ -67,7 +67,7 @@ @Override public Object[] getChildren() { AST ast= fRoot.getAST(); - + Binding[] res= new Binding[WELL_KNOWN_TYPES.length]; for (int i= 0; i < WELL_KNOWN_TYPES.length; i++) { String type= WELL_KNOWN_TYPES[i]; @@ -98,7 +98,7 @@ } return true; } - + /* * @see java.lang.Object#hashCode() */ diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview.feature/feature.xml eclipse-jdt-ui-4.15/org.eclipse.jdt.astview.feature/feature.xml --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview.feature/feature.xml 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview.feature/feature.xml 2020-02-26 15:31:57.000000000 +0000 @@ -2,13 +2,13 @@ - AST View for Eclipse 4.4 (Luna) and later (jdt.core 3.10) + AST View for Eclipse 2019-12 and later (jdt.core 3.20) diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.astview.feature/pom.xml eclipse-jdt-ui-4.15/org.eclipse.jdt.astview.feature/pom.xml --- eclipse-jdt-ui-4.12/org.eclipse.jdt.astview.feature/pom.xml 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.astview.feature/pom.xml 2020-02-26 15:31:57.000000000 +0000 @@ -14,10 +14,10 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.12.0-SNAPSHOT + 4.15.0-SNAPSHOT org.eclipse.jdt.feature org.eclipse.jdt.astview.feature - 1.1.10-SNAPSHOT + 1.1.11-SNAPSHOT eclipse-feature diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ChangeCorrectionProposalCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ChangeCorrectionProposalCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ChangeCorrectionProposalCore.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ChangeCorrectionProposalCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2018 IBM Corporation and others. - * + * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -105,7 +105,7 @@ @SuppressWarnings("unused") public Object getAdditionalProposalInfo(IProgressMonitor monitor) { - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); buf.append("

"); //$NON-NLS-1$ try { Change change= getChange(); diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpContextCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpContextCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpContextCore.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpContextCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2008, 2019 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc. - refactored to jdt.core.manipultion + *******************************************************************************/ +package org.eclipse.jdt.core.manipulation; + +import org.eclipse.core.runtime.Assert; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.dom.CompilationUnit; + + +/** + * The context that contains all information required by a clean up to create a fix. + * + * @since 1.12 + */ +public class CleanUpContextCore { + + private final ICompilationUnit fUnit; + + private final CompilationUnit fAst; + + /** + * Creates a new clean up context. + * + * @param unit the compilation unit + * @param ast the AST, can be null if {@link CleanUpRequirementsCore#requiresAST()} + * returns false. The AST is guaranteed to contain changes made by + * previous clean ups only if {@link CleanUpRequirementsCore#requiresFreshAST()} returns + * true. + */ + public CleanUpContextCore(ICompilationUnit unit, CompilationUnit ast) { + Assert.isLegal(unit != null); + fUnit= unit; + fAst= ast; + } + + /** + * The compilation unit to clean up. + * + * @return the compilation unit to clean up + */ + public ICompilationUnit getCompilationUnit() { + return fUnit; + } + + /** + * An AST built from the compilation unit to fix. + *

+ * Can be null if {@link CleanUpRequirementsCore#requiresAST()} returns + * false. The AST is guaranteed to contain changes made by previous clean ups only + * if {@link CleanUpRequirementsCore#requiresFreshAST()} returns true. + *

+ *

Clients should check the AST API level and do nothing if they are given an AST + * they can't handle (see {@link org.eclipse.jdt.core.dom.AST#apiLevel()}). + * + * @return an AST or null if none required + */ + public CompilationUnit getAST() { + return fAst; + } +} \ No newline at end of file diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpOptionsCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpOptionsCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpOptionsCore.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpOptionsCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2008, 2019 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc. - refactored to jdt.core.manipulation + *******************************************************************************/ +package org.eclipse.jdt.core.manipulation; + +import java.util.Collections; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.Assert; + +import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; + + +/** + * Allows to set and retrieve clean up settings for given options keys. + * + * @since 1.12 + * This class is not intended to be subclassed by clients. + */ +public class CleanUpOptionsCore { + + private final Map fOptions; + + /** + * True value + */ + public static final String TRUE= "true"; //$NON-NLS-1$ + + /** + * False value + */ + public static final String FALSE= "false"; //$NON-NLS-1$ + + /** + * Creates a new CleanUpOptions instance with the given options. + * + * @param options map that maps clean ups keys (String) to a non-null + * string value + */ + public CleanUpOptionsCore(Map options) { + fOptions= options; + } + + /** + * Creates a new instance. + */ + public CleanUpOptionsCore() { + fOptions= new Hashtable<>(); + } + + /** + * Tells whether the option with the given key is enabled. + * + * @param key the name of the option + * @return true if enabled, false if not enabled or unknown key + * @throws IllegalArgumentException if the key is null + * @see CleanUpConstants + */ + public boolean isEnabled(String key) { + Assert.isLegal(key != null); + Object value= fOptions.get(key); + return CleanUpOptionsCore.TRUE == value || CleanUpOptionsCore.TRUE.equals(value); + } + + /** + * Returns the value for the given key. + * + * @param key the key of the value + * @return the value associated with the key + * @throws IllegalArgumentException if the key is null or unknown + */ + public String getValue(String key) { + Assert.isLegal(key != null); + String value= fOptions.get(key); + Assert.isLegal(value != null); + return value; + } + + /** + * Sets the option for the given key to the given value. + * + * @param key the name of the option to set + * @param value the value of the option + * @throws IllegalArgumentException if the key is null + * @see CleanUpOptionsCore#TRUE + * @see CleanUpOptionsCore#FALSE + */ + public void setOption(String key, String value) { + Assert.isLegal(key != null); + Assert.isLegal(value != null); + fOptions.put(key, value); + } + + /** + * Returns an unmodifiable set of all known keys. + * + * @return an unmodifiable set of all keys + */ + public Set getKeys() { + return Collections.unmodifiableSet(fOptions.keySet()); + } +} diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpRequirementsCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpRequirementsCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpRequirementsCore.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CleanUpRequirementsCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2008, 2019 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc. - refactored to jdt.core.manipulation + *******************************************************************************/ +package org.eclipse.jdt.core.manipulation; + +import java.util.Map; + +import org.eclipse.core.runtime.Assert; + +import org.eclipse.jdt.core.JavaCore; + + +/** + * Specifies the requirements of a clean up. + * + * @since 1.12 + */ +final public class CleanUpRequirementsCore { + + protected final boolean fRequiresAST; + + protected final Map fCompilerOptions; + + protected final boolean fRequiresFreshAST; + + protected final boolean fRequiresChangedRegions; + + + /** + * Create a new instance + * + * @param requiresAST true if an AST is required + * @param requiresFreshAST true if a fresh AST is required + * @param requiresChangedRegions true if changed regions are required + * @param compilerOptions map of compiler options or null if no requirements + */ + public CleanUpRequirementsCore(boolean requiresAST, boolean requiresFreshAST, boolean requiresChangedRegions, Map compilerOptions) { + Assert.isLegal(!requiresFreshAST || requiresAST, "Must not request fresh AST if no AST is required"); //$NON-NLS-1$ + Assert.isLegal(compilerOptions == null || requiresAST, "Must not provide options if no AST is required"); //$NON-NLS-1$ + fRequiresAST= requiresAST; + fRequiresFreshAST= requiresFreshAST; + fRequiresChangedRegions= requiresChangedRegions; + + fCompilerOptions= compilerOptions; + // Make sure that compile warnings are not suppressed since some clean ups work on reported warnings + if (fCompilerOptions != null) + fCompilerOptions.put(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, JavaCore.DISABLED); + } + + /** + * Tells whether the clean up requires an AST. + *

+ * Note: This should return false whenever possible because + * creating an AST is expensive. + *

+ * + * @return true if the CleanUpContext context must provide an AST + */ + public boolean requiresAST() { + return fRequiresAST; + } + + /** + * Tells whether a fresh AST, containing all the changes from previous clean ups, will be + * needed. + * + * @return true if the caller needs an up to date AST + */ + public boolean requiresFreshAST() { + return fRequiresFreshAST; + } + + /** + * Required compiler options. + * + * @return the compiler options map or null if none + * @see JavaCore + */ + public Map getCompilerOptions() { + return fCompilerOptions; + } + + /** + * Tells whether this clean up requires to be informed about changed regions. The changed regions are the + * regions which have been changed between the last save state of the compilation unit and its + * current state. + *

+ * Has only an effect if the clean up is used as save action. + *

+ *

+ * Note:: This should return false whenever possible because + * calculating the changed regions is expensive. + *

+ * + * @return true if the CleanUpContext context must provide changed + * regions + */ + public boolean requiresChangedRegions() { + return fRequiresChangedRegions; + } + +} \ No newline at end of file diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CodeGeneration.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CodeGeneration.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CodeGeneration.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CodeGeneration.java 2020-02-26 15:31:57.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,6 +18,7 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.IModuleDescription; import org.eclipse.jdt.core.dom.IMethodBinding; import org.eclipse.jdt.core.dom.MethodDeclaration; @@ -306,6 +307,36 @@ } /** + * Returns the comment for a module based on code templates + * + * @param cu The compilation unit for the module + * @param moduleName The name of the module + * @param providesNames Names of provided services + * @param usesNames Names of used modules + * @param lineDelimiter The line delimiter to use + * @return Module comment + * @throws CoreException Thrown when the evaluation of the code template fails + * @since 1.12 + */ + public static String getModuleComment(ICompilationUnit cu, String moduleName, String[] providesNames, String[] usesNames, String lineDelimiter) throws CoreException { + return StubUtility.getModuleComment(cu, moduleName, providesNames, usesNames, lineDelimiter); + } + + /** + * Returns the comment for a module based on code templates + * + * @param cu The compilation unit for the module + * @param desc The module description + * @param lineDelimiter The line delimiter to use + * @return Module comment + * @throws CoreException Thrown when the evaluation of the code template fails + * @since 1.12 + */ + public static String getModuleComment(ICompilationUnit cu, IModuleDescription desc, String lineDelimiter) throws CoreException { + return StubUtility.getModuleComment(cu, desc.getElementName(), desc.getProvidedServiceNames(), desc.getUsedServiceNames(), lineDelimiter); + } + + /** * Returns the content of the body for a method or constructor using the method body templates. * null is returned if the template is empty. *

The returned string is unformatted and not indented. diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CUCorrectionProposalCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CUCorrectionProposalCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CUCorrectionProposalCore.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/CUCorrectionProposalCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -47,7 +47,7 @@ *

* The proposal takes care of the preview of the changes as proposal information. *

- * + * * @since 1.11 */ public class CUCorrectionProposalCore extends ChangeCorrectionProposalCore implements ICUCorrectionProposal { @@ -57,7 +57,7 @@ /** * Constructs a correction proposal working on a compilation unit with a given text change. - * + * * @param proposal ICUCorrectionProposal to use * @param name the name that is displayed in the proposal selection dialog * @param cu the compilation unit to which the change can be applied @@ -77,7 +77,7 @@ /** * Constructs a correction proposal working on a compilation unit with a given text change. - * + * * @param name the name that is displayed in the proposal selection dialog * @param cu the compilation unit to which the change can be applied * @param change the change that is executed when the proposal is applied or null @@ -100,7 +100,7 @@ * Users have to override {@link #addEdits(IDocument, TextEdit)} to provide the text edits or * {@link #createTextChange()} to provide a text change. *

- * + * * @param name the name that is displayed in the proposal selection dialog * @param cu the compilation unit on that the change works * @param relevance the relevance of this proposal @@ -116,7 +116,7 @@ *

* The default implementation does not add any edits *

- * + * * @param document content of the underlying compilation unit. To be accessed read only. * @param editRoot The root edit to add all edits to * @throws CoreException can be thrown if adding the edits is failing. @@ -141,7 +141,7 @@ } return buf.toString(); } - + @Override public void apply() throws CoreException { performChange(); @@ -219,7 +219,7 @@ * * @return the preview of the changed compilation unit * @throws CoreException if the creation of the change failed - * + * * @noreference This method is not intended to be referenced by clients. */ public String getPreviewContent() throws CoreException { diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICleanUpFixCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICleanUpFixCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICleanUpFixCore.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICleanUpFixCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2018, 2019 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc. - copied and renamed in jdt.core.manipulation + *******************************************************************************/ +package org.eclipse.jdt.core.manipulation; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.jdt.core.refactoring.CompilationUnitChange; + + +/** + * A clean up fix calculates a {@link CompilationUnitChange} which can be applied on a document to + * fix one or more problems in a compilation unit. + * + * @since 1.12 + */ +public interface ICleanUpFixCore { + + /** + * Calculates and returns a {@link CompilationUnitChange} which can be applied on a document to + * fix one or more problems in a compilation unit. + * + * @param progressMonitor the progress monitor or null if none + * @return a compilation unit change change which should not be empty + * @throws CoreException if something went wrong while calculating the change + */ + public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException; + +} diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICUCorrectionProposal.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICUCorrectionProposal.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICUCorrectionProposal.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ICUCorrectionProposal.java 2020-02-26 15:31:57.000000000 +0000 @@ -22,7 +22,7 @@ * @since 1.11 */ public interface ICUCorrectionProposal { - + /** * Returns the text change that is invoked when the change is applied. * diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java 2020-02-26 15:31:57.000000000 +0000 @@ -23,7 +23,6 @@ import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.AnnotatableType; -import org.eclipse.jdt.core.dom.BreakStatement; import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.ContinueStatement; @@ -62,6 +61,7 @@ import org.eclipse.jdt.core.dom.TypeDeclaration; import org.eclipse.jdt.core.dom.TypeMethodReference; import org.eclipse.jdt.core.dom.UsesDirective; +import org.eclipse.jdt.core.dom.YieldStatement; import org.eclipse.jdt.internal.corext.dom.GenericVisitor; import org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer; @@ -291,7 +291,7 @@ doVisitChildren(node.annotations()); return false; } - + @Override public boolean visit(LabeledStatement node) { doVisitNode(node.getBody()); @@ -302,16 +302,15 @@ public boolean visit(ContinueStatement node) { return false; } - + @Override - public boolean visit(BreakStatement node) { - int apiLevel= node.getAST().apiLevel(); - if (apiLevel >= AST.JLS12) { - evalQualifyingExpression(node.getExpression(), null); + public boolean visit(YieldStatement node) { + if (node.getAST().isPreviewEnabled()) { + evalQualifyingExpression(node.getExpression(), null); } return false; } - + /* * @see ASTVisitor#visit(ThisExpression) */ @@ -320,7 +319,7 @@ typeRefFound(node.getQualifier()); return false; } - + @Override public boolean visit(SuperFieldAccess node) { typeRefFound(node.getQualifier()); @@ -373,7 +372,7 @@ doVisitChildren(node.typeArguments()); return false; } - + @Override public boolean visit(ExpressionMethodReference node) { evalQualifyingExpression(node.getExpression(), node.getName()); @@ -387,7 +386,7 @@ doVisitChildren(node.typeArguments()); return false; } - + @Override public boolean visit(TypeMethodReference node) { doVisitNode(node.getType()); @@ -409,7 +408,7 @@ } return false; } - + /* * @see ASTVisitor#visit(SuperConstructorInvocation) */ @@ -492,7 +491,7 @@ doVisitNode(node.getReturnType2()); } // name not visited - + int apiLevel= node.getAST().apiLevel(); if (apiLevel >= AST.JLS8) { doVisitNode(node.getReceiverType()); @@ -569,7 +568,7 @@ } return false; } - + @Override public boolean visit(MethodRefParameter node) { doVisitNode(node.getType()); diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java 2020-02-26 15:31:57.000000000 +0000 @@ -373,7 +373,7 @@ } for (Entry entry : fUnresolvedTypes.entrySet()) { - if (entry.getValue().foundInfos.size() == 0) { // No result found in search + if (entry.getValue().foundInfos.isEmpty()) { // No result found in search Set matchingUnresolvableImports= fUnresolvableImportMatcher.matchTypeImports(entry.getKey()); if (!matchingUnresolvableImports.isEmpty()) { // If there are matching unresolvable import(s), rely on them to provide the type. @@ -560,7 +560,7 @@ CompilationUnit astRoot= fASTRoot; if (astRoot == null) { astRoot= CoreASTProvider.getInstance().getAST(fCompilationUnit, CoreASTProvider.WAIT_YES, subMonitor.split(2)); - } + } subMonitor.setWorkRemaining(7); ImportRewrite importsRewrite= CodeStyleConfiguration.createImportRewrite(astRoot, false); diff -Nru eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java --- eclipse-jdt-ui-4.12/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java 2019-06-01 21:39:59.000000000 +0000 +++ eclipse-jdt-ui-4.15/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java 2020-02-26 15:31:57.000000000 +0000 @@ -20,7 +20,6 @@ import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; -import org.eclipse.jdt.core.manipulation.CoreASTProvider; /** @@ -33,7 +32,7 @@ *

Clients can make the following assumptions about the AST:

*