Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java149
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java23
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java236
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/BodyDeclarationRewrite.java (renamed from org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/BodyDeclarationRewrite.java)46
-rw-r--r--org.eclipse.jdt.text.tests/about_files/cpl-v10.html125
-rw-r--r--org.eclipse.jdt.ui.examples.projects/cpl-v10.html125
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/cpl-v10.html125
-rw-r--r--org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java34
-rw-r--r--org.eclipse.jdt.ui.tests/cpl-v10.html125
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java554
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/SortMembersOperation.java33
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/AccessorClassCreator.java11
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/AbstractConfigurationBlock.java19
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java127
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java184
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementComparator.java19
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java7
20 files changed, 1173 insertions, 784 deletions
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java
index 6f3750ab3b..f8a538a073 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.java
@@ -24,9 +24,8 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -542,109 +541,89 @@ public class OrganizeImportsOperation implements IWorkspaceRunnable {
*/
@Override
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
- try {
- monitor.beginTask(Messages.format(JavaManipulationMessages.OrganizeImportsOperation_description, BasicElementLabels.getFileName(fCompilationUnit)), 10);
-
- TextEdit edit= createTextEdit(new SubProgressMonitor(monitor, 9));
- if (edit == null)
- return;
+ SubMonitor subMonitor= SubMonitor.convert(monitor,Messages.format(JavaManipulationMessages.OrganizeImportsOperation_description,BasicElementLabels.getFileName(fCompilationUnit)), 10 );
+ TextEdit edit= createTextEdit(subMonitor.split(9));
+ if (edit == null)
+ return;
- JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, new SubProgressMonitor(monitor, 1));
- } finally {
- monitor.done();
- }
+ JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, subMonitor.split(1));
}
- public TextEdit createTextEdit(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
- try {
- fNumberOfImportsAdded= 0;
- fNumberOfImportsRemoved= 0;
-
- monitor.beginTask(Messages.format(JavaManipulationMessages.OrganizeImportsOperation_description, BasicElementLabels.getFileName(fCompilationUnit)), 9);
+ public TextEdit createTextEdit(IProgressMonitor m) throws CoreException, OperationCanceledException {
+ SubMonitor subMonitor= SubMonitor.convert(m, Messages.format(JavaManipulationMessages.OrganizeImportsOperation_description, BasicElementLabels.getFileName(fCompilationUnit)), 9);
+ fNumberOfImportsAdded= 0;
+ fNumberOfImportsRemoved= 0;
- CompilationUnit astRoot= fASTRoot;
- if (astRoot == null) {
- astRoot= CoreASTProvider.getInstance().getAST(fCompilationUnit, CoreASTProvider.WAIT_YES, new SubProgressMonitor(monitor, 2));
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- } else {
- monitor.worked(2);
- }
+ 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);
- if (astRoot.getAST().hasResolvedBindings()) {
- importsRewrite.setUseContextToFilterImplicitImports(true);
- }
+ ImportRewrite importsRewrite= CodeStyleConfiguration.createImportRewrite(astRoot, false);
+ if (astRoot.getAST().hasResolvedBindings()) {
+ importsRewrite.setUseContextToFilterImplicitImports(true);
+ }
- Set<String> oldSingleImports= new HashSet<>();
- Set<String> oldDemandImports= new HashSet<>();
- List<SimpleName> typeReferences= new ArrayList<>();
- List<SimpleName> staticReferences= new ArrayList<>();
+ Set<String> oldSingleImports= new HashSet<>();
+ Set<String> oldDemandImports= new HashSet<>();
+ List<SimpleName> typeReferences= new ArrayList<>();
+ List<SimpleName> staticReferences= new ArrayList<>();
- if (!collectReferences(astRoot, typeReferences, staticReferences, oldSingleImports, oldDemandImports))
- return null;
+ if (!collectReferences(astRoot, typeReferences, staticReferences, oldSingleImports, oldDemandImports))
+ return null;
- monitor.worked(1);
+ subMonitor.split(1);
- UnresolvableImportMatcher unresolvableImportMatcher =
- UnresolvableImportMatcher.forCompilationUnit(astRoot);
+ UnresolvableImportMatcher unresolvableImportMatcher= UnresolvableImportMatcher.forCompilationUnit(astRoot);
- TypeReferenceProcessor processor= new TypeReferenceProcessor(
- oldSingleImports,
- oldDemandImports,
- astRoot,
- importsRewrite,
- fIgnoreLowerCaseNames,
- unresolvableImportMatcher);
+ TypeReferenceProcessor processor= new TypeReferenceProcessor(
+ oldSingleImports,
+ oldDemandImports,
+ astRoot,
+ importsRewrite,
+ fIgnoreLowerCaseNames,
+ unresolvableImportMatcher);
- Iterator<SimpleName> refIterator= typeReferences.iterator();
- while (refIterator.hasNext()) {
- SimpleName typeRef= refIterator.next();
- processor.add(typeRef);
- }
+ Iterator<SimpleName> refIterator= typeReferences.iterator();
+ while (refIterator.hasNext()) {
+ SimpleName typeRef= refIterator.next();
+ processor.add(typeRef);
+ }
- boolean hasOpenChoices= processor.process(new SubProgressMonitor(monitor, 3));
- addStaticImports(staticReferences, importsRewrite, unresolvableImportMatcher);
+ boolean hasOpenChoices= processor.process(subMonitor.split(3));
+ addStaticImports(staticReferences, importsRewrite, unresolvableImportMatcher);
- if (hasOpenChoices && fChooseImportQuery != null) {
- TypeNameMatch[][] choices= processor.getChoices();
- ISourceRange[] ranges= processor.getChoicesSourceRanges();
- TypeNameMatch[] chosen= fChooseImportQuery.chooseImports(choices, ranges);
- if (chosen == null) {
- // cancel pressed by the user
- throw new OperationCanceledException();
- }
- for (int i= 0; i < chosen.length; i++) {
- TypeNameMatch typeInfo= chosen[i];
- if (typeInfo != null) {
- importsRewrite.addImport(typeInfo.getFullyQualifiedName());
- } else { // Skipped by user
- String typeName= choices[i][0].getSimpleTypeName();
- Set<String> matchingUnresolvableImports= unresolvableImportMatcher.matchTypeImports(typeName);
- if (!matchingUnresolvableImports.isEmpty()) {
- // If there are matching unresolvable import(s), rely on them to provide the type.
- for (String string : matchingUnresolvableImports) {
- importsRewrite.addImport(string, UNRESOLVABLE_IMPORT_CONTEXT);
- }
+ if (hasOpenChoices && fChooseImportQuery != null) {
+ TypeNameMatch[][] choices= processor.getChoices();
+ ISourceRange[] ranges= processor.getChoicesSourceRanges();
+ TypeNameMatch[] chosen= fChooseImportQuery.chooseImports(choices, ranges);
+ if (chosen == null) {
+ // cancel pressed by the user
+ throw new OperationCanceledException();
+ }
+ for (int i= 0; i < chosen.length; i++) {
+ TypeNameMatch typeInfo= chosen[i];
+ if (typeInfo != null) {
+ importsRewrite.addImport(typeInfo.getFullyQualifiedName());
+ } else { // Skipped by user
+ String typeName= choices[i][0].getSimpleTypeName();
+ Set<String> matchingUnresolvableImports= unresolvableImportMatcher.matchTypeImports(typeName);
+ if (!matchingUnresolvableImports.isEmpty()) {
+ // If there are matching unresolvable import(s), rely on them to provide the type.
+ for (String string : matchingUnresolvableImports) {
+ importsRewrite.addImport(string, UNRESOLVABLE_IMPORT_CONTEXT);
}
}
}
}
+ }
- TextEdit result= importsRewrite.rewriteImports(new SubProgressMonitor(monitor, 3));
+ TextEdit result= importsRewrite.rewriteImports(subMonitor.split(3));
- determineImportDifferences(importsRewrite, oldSingleImports, oldDemandImports);
+ determineImportDifferences(importsRewrite, oldSingleImports, oldDemandImports);
- return result;
- } finally {
- monitor.done();
- }
+ return result;
}
private void determineImportDifferences(ImportRewrite importsStructure, Set<String> oldSingleImports, Set<String> oldDemandImports) {
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java
index cf6ecaa54f..84ea3eeadf 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java
@@ -32,6 +32,8 @@ public class JavaManipulationPlugin extends Plugin implements DebugOptionsListen
//The shared instance.
private static JavaManipulationPlugin fgDefault;
+ private MembersOrderPreferenceCacheCommon fMembersOrderPreferenceCacheCommon;
+
/**
* The constructor.
*/
@@ -59,6 +61,27 @@ public class JavaManipulationPlugin extends Plugin implements DebugOptionsListen
return fgDefault;
}
+ /**
+ * Returns the shared Members Order Preference Common Cache
+ *
+ * @return the shared cache
+ */
+ public MembersOrderPreferenceCacheCommon getMembersOrderPreferenceCacheCommon() {
+ if (fMembersOrderPreferenceCacheCommon == null) {
+ fMembersOrderPreferenceCacheCommon= new MembersOrderPreferenceCacheCommon();
+ }
+ return fMembersOrderPreferenceCacheCommon;
+ }
+
+ /**
+ * Set the default Members Order Preference Cache Common
+ *
+ * @param mpcc - MembersOrderPreferenceCacheCommon default
+ */
+ public void setMembersOrderPreferenceCacheCommon(MembersOrderPreferenceCacheCommon mpcc) {
+ fMembersOrderPreferenceCacheCommon= mpcc;
+ }
+
public static String getPluginId() {
return JavaManipulation.ID_PLUGIN;
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java
new file mode 100644
index 0000000000..25902b188b
--- /dev/null
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * Copyright (c) 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat Inc. - created by splitting MembersOrderPreferenceCache in JDT UI
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.manipulation;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.manipulation.JavaManipulation;
+
+/**
+ * @since 1.10
+ */
+public class MembersOrderPreferenceCacheCommon {
+
+ /**
+ * A named preference that defines how member elements are ordered by the
+ * Java views using the <code>JavaElementSorter</code>.
+ * <p>
+ * Value is of type <code>String</code>: A comma separated list of the
+ * following entries. Each entry must be in the list, no duplication. List
+ * order defines the sort order.
+ * <ul>
+ * <li><b>T</b>: Types</li>
+ * <li><b>C</b>: Constructors</li>
+ * <li><b>I</b>: Initializers</li>
+ * <li><b>M</b>: Methods</li>
+ * <li><b>F</b>: Fields</li>
+ * <li><b>SI</b>: Static Initializers</li>
+ * <li><b>SM</b>: Static Methods</li>
+ * <li><b>SF</b>: Static Fields</li>
+ * </ul>
+ * </p>
+ */
+ public static final String APPEARANCE_MEMBER_SORT_ORDER= "outlinesortoption"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines how member elements are ordered by visibility in the
+ * Java views using the <code>JavaElementSorter</code>.
+ * <p>
+ * Value is of type <code>String</code>: A comma separated list of the
+ * following entries. Each entry must be in the list, no duplication. List
+ * order defines the sort order.
+ * <ul>
+ * <li><b>B</b>: Public</li>
+ * <li><b>V</b>: Private</li>
+ * <li><b>R</b>: Protected</li>
+ * <li><b>D</b>: Default</li>
+ * </ul>
+ * </p>
+ */
+ public static final String APPEARANCE_VISIBILITY_SORT_ORDER= "org.eclipse.jdt.ui.visibility.order"; //$NON-NLS-1$
+
+ /**
+ * A named preferences that controls if Java elements are also sorted by
+ * visibility.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER= "org.eclipse.jdt.ui.enable.visibility.order"; //$NON-NLS-1$
+
+
+ public static final int TYPE_INDEX= 0;
+ public static final int CONSTRUCTORS_INDEX= 1;
+ public static final int METHOD_INDEX= 2;
+ public static final int FIELDS_INDEX= 3;
+ public static final int INIT_INDEX= 4;
+ public static final int STATIC_FIELDS_INDEX= 5;
+ public static final int STATIC_INIT_INDEX= 6;
+ public static final int STATIC_METHODS_INDEX= 7;
+ public static final int ENUM_CONSTANTS_INDEX= 8;
+ public static final int N_CATEGORIES= ENUM_CONSTANTS_INDEX + 1;
+
+ protected static final int PUBLIC_INDEX= 0;
+ protected static final int PRIVATE_INDEX= 1;
+ protected static final int PROTECTED_INDEX= 2;
+ protected static final int DEFAULT_INDEX= 3;
+ protected static final int N_VISIBILITIES= DEFAULT_INDEX + 1;
+
+ protected int[] fCategoryOffsets= null;
+
+ protected boolean fSortByVisibility;
+ protected int[] fVisibilityOffsets= null;
+
+ private IEclipsePreferences fPreferences;
+ private IEclipsePreferences fDefaultPreferenceStore;
+
+ public MembersOrderPreferenceCacheCommon() {
+ fPreferences= null;
+ fDefaultPreferenceStore= null;
+ fCategoryOffsets= null;
+ }
+
+ public void install() {
+ fPreferences= InstanceScope.INSTANCE.getNode(JavaManipulation.getPreferenceNodeId());
+ fDefaultPreferenceStore= DefaultScope.INSTANCE.getNode(JavaManipulation.getPreferenceNodeId());
+ fVisibilityOffsets= null;
+ boolean defaultValue= fDefaultPreferenceStore.getBoolean(APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER, false);
+ fSortByVisibility= fPreferences.getBoolean(APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER, defaultValue);
+ JavaManipulationPlugin.getDefault().setMembersOrderPreferenceCacheCommon(this);
+ }
+
+ public void dispose() {
+ fPreferences= null;
+ fDefaultPreferenceStore= null;
+ }
+
+ public static boolean isMemberOrderProperty(String property) {
+ return APPEARANCE_MEMBER_SORT_ORDER.equals(property)
+ || APPEARANCE_VISIBILITY_SORT_ORDER.equals(property)
+ || APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER.equals(property);
+ }
+
+ public void propertyChange(String property) {
+ if (APPEARANCE_MEMBER_SORT_ORDER.equals(property)) {
+ fCategoryOffsets= null;
+ } else if (APPEARANCE_VISIBILITY_SORT_ORDER.equals(property)) {
+ fVisibilityOffsets= null;
+ } else if (APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER.equals(property)) {
+ String key= APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER;
+ boolean defaultValue= fDefaultPreferenceStore.getBoolean(key, false);
+ fSortByVisibility= fPreferences.getBoolean(key, defaultValue);
+ }
+ }
+
+ public int getCategoryIndex(int kind) {
+ if (fCategoryOffsets == null) {
+ fCategoryOffsets= getCategoryOffsets();
+ }
+ return fCategoryOffsets[kind];
+ }
+
+ protected int[] getCategoryOffsets() {
+ int[] offsets= new int[N_CATEGORIES];
+ String key= APPEARANCE_MEMBER_SORT_ORDER;
+ boolean success= fillCategoryOffsetsFromPreferenceString(fPreferences.get(key, ""), offsets); //$NON-NLS-1$
+ if (!success) {
+ String defaultValue= fDefaultPreferenceStore.get(key, ""); //$NON-NLS-1$
+ fPreferences.put(key, defaultValue);
+ fillCategoryOffsetsFromPreferenceString(defaultValue, offsets);
+ }
+ return offsets;
+ }
+
+ protected boolean fillCategoryOffsetsFromPreferenceString(String str, int[] offsets) {
+ StringTokenizer tokenizer= new StringTokenizer(str, ","); //$NON-NLS-1$
+ int i= 0;
+ offsets[ENUM_CONSTANTS_INDEX]= i++; // enum constants always on top
+
+ while (tokenizer.hasMoreTokens()) {
+ String token= tokenizer.nextToken().trim();
+ if ("T".equals(token)) { //$NON-NLS-1$
+ offsets[TYPE_INDEX]= i++;
+ } else if ("M".equals(token)) { //$NON-NLS-1$
+ offsets[METHOD_INDEX]= i++;
+ } else if ("F".equals(token)) { //$NON-NLS-1$
+ offsets[FIELDS_INDEX]= i++;
+ } else if ("I".equals(token)) { //$NON-NLS-1$
+ offsets[INIT_INDEX]= i++;
+ } else if ("SF".equals(token)) { //$NON-NLS-1$
+ offsets[STATIC_FIELDS_INDEX]= i++;
+ } else if ("SI".equals(token)) { //$NON-NLS-1$
+ offsets[STATIC_INIT_INDEX]= i++;
+ } else if ("SM".equals(token)) { //$NON-NLS-1$
+ offsets[STATIC_METHODS_INDEX]= i++;
+ } else if ("C".equals(token)) { //$NON-NLS-1$
+ offsets[CONSTRUCTORS_INDEX]= i++;
+ }
+ }
+ return i == N_CATEGORIES;
+ }
+
+ public boolean isSortByVisibility() {
+ return fSortByVisibility;
+ }
+
+ public int getVisibilityIndex(int modifierFlags) {
+ if (fVisibilityOffsets == null) {
+ fVisibilityOffsets= getVisibilityOffsets();
+ }
+ int kind= DEFAULT_INDEX;
+ if (Flags.isPublic(modifierFlags)) {
+ kind= PUBLIC_INDEX;
+ } else if (Flags.isProtected(modifierFlags)) {
+ kind= PROTECTED_INDEX;
+ } else if (Flags.isPrivate(modifierFlags)) {
+ kind= PRIVATE_INDEX;
+ }
+
+ return fVisibilityOffsets[kind];
+ }
+
+ protected int[] getVisibilityOffsets() {
+ int[] offsets= new int[N_VISIBILITIES];
+ String key= APPEARANCE_VISIBILITY_SORT_ORDER;
+ boolean success= fillVisibilityOffsetsFromPreferenceString(fPreferences.get(key, ""), offsets); //$NON-NLS-1$
+ if (!success) {
+ String defaultValue= fDefaultPreferenceStore.get(key, ""); //$NON-NLS-1$
+ fPreferences.put(key, defaultValue);
+ fillVisibilityOffsetsFromPreferenceString(defaultValue, offsets);
+ }
+ return offsets;
+ }
+
+ protected boolean fillVisibilityOffsetsFromPreferenceString(String str, int[] offsets) {
+ StringTokenizer tokenizer= new StringTokenizer(str, ","); //$NON-NLS-1$
+ int i= 0;
+ while (tokenizer.hasMoreTokens()) {
+ String token= tokenizer.nextToken().trim();
+ if ("B".equals(token)) { //$NON-NLS-1$
+ offsets[PUBLIC_INDEX]= i++;
+ } else if ("V".equals(token)) { //$NON-NLS-1$
+ offsets[PRIVATE_INDEX]= i++;
+ } else if ("R".equals(token)) { //$NON-NLS-1$
+ offsets[PROTECTED_INDEX]= i++;
+ } else if ("D".equals(token)) { //$NON-NLS-1$
+ offsets[DEFAULT_INDEX]= i++;
+ }
+ }
+ return i == N_VISIBILITIES;
+ }
+
+}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/BodyDeclarationRewrite.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/BodyDeclarationRewrite.java
index c7a63058f7..6546c9751b 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/BodyDeclarationRewrite.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/BodyDeclarationRewrite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Red Hat Inc. - moved to jdt.core.manipulation
*******************************************************************************/
package org.eclipse.jdt.internal.corext.dom;
@@ -22,16 +23,15 @@ import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
-import org.eclipse.jdt.internal.corext.util.JDTUIHelperClasses;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache;
+import org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin;
+import org.eclipse.jdt.internal.core.manipulation.MembersOrderPreferenceCacheCommon;
/**
* Rewrite helper for body declarations.
*
* @see ASTNodes#getBodyDeclarationsProperty(ASTNode)
- * @see JDTUIHelperClasses
+ *
+ * @since 1.10
*/
public class BodyDeclarationRewrite {
@@ -63,14 +63,16 @@ public class BodyDeclarationRewrite {
*/
public static int getInsertionIndex(BodyDeclaration member, List<? extends BodyDeclaration> container) {
int containerSize= container.size();
-
- MembersOrderPreferenceCache orderStore= JavaPlugin.getDefault().getMemberOrderPreferenceCache();
-
+
+ // use MembersOrderPreferenceCacheCommon which has no UI dependencies and
+ // will get Preferences from the node specified by JavaManipulation.getPreferenceNodeId
+ MembersOrderPreferenceCacheCommon orderStore= JavaManipulationPlugin.getDefault().getMembersOrderPreferenceCacheCommon();
+
int orderIndex= getOrderPreference(member, orderStore);
-
+
int insertPos= containerSize;
int insertPosOrderIndex= -1;
-
+
for (int i= containerSize - 1; i >= 0; i--) {
int currOrderIndex= getOrderPreference(container.get(i), orderStore);
if (orderIndex == currOrderIndex) {
@@ -93,39 +95,39 @@ public class BodyDeclarationRewrite {
return insertPos;
}
- private static int getOrderPreference(BodyDeclaration member, MembersOrderPreferenceCache store) {
+ private static int getOrderPreference(BodyDeclaration member, MembersOrderPreferenceCacheCommon store) {
int memberType= member.getNodeType();
int modifiers= member.getModifiers();
-
+
switch (memberType) {
case ASTNode.TYPE_DECLARATION:
case ASTNode.ENUM_DECLARATION :
case ASTNode.ANNOTATION_TYPE_DECLARATION :
- return store.getCategoryIndex(MembersOrderPreferenceCache.TYPE_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.TYPE_INDEX) * 2;
case ASTNode.FIELD_DECLARATION:
if (Modifier.isStatic(modifiers)) {
- int index= store.getCategoryIndex(MembersOrderPreferenceCache.STATIC_FIELDS_INDEX) * 2;
+ int index= store.getCategoryIndex(MembersOrderPreferenceCacheCommon.STATIC_FIELDS_INDEX) * 2;
if (Modifier.isFinal(modifiers)) {
return index; // first final static, then static
}
return index + 1;
}
- return store.getCategoryIndex(MembersOrderPreferenceCache.FIELDS_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.FIELDS_INDEX) * 2;
case ASTNode.INITIALIZER:
if (Modifier.isStatic(modifiers)) {
- return store.getCategoryIndex(MembersOrderPreferenceCache.STATIC_INIT_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.STATIC_INIT_INDEX) * 2;
}
- return store.getCategoryIndex(MembersOrderPreferenceCache.INIT_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.INIT_INDEX) * 2;
case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- return store.getCategoryIndex(MembersOrderPreferenceCache.METHOD_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.METHOD_INDEX) * 2;
case ASTNode.METHOD_DECLARATION:
if (Modifier.isStatic(modifiers)) {
- return store.getCategoryIndex(MembersOrderPreferenceCache.STATIC_METHODS_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.STATIC_METHODS_INDEX) * 2;
}
if (((MethodDeclaration) member).isConstructor()) {
- return store.getCategoryIndex(MembersOrderPreferenceCache.CONSTRUCTORS_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.CONSTRUCTORS_INDEX) * 2;
}
- return store.getCategoryIndex(MembersOrderPreferenceCache.METHOD_INDEX) * 2;
+ return store.getCategoryIndex(MembersOrderPreferenceCacheCommon.METHOD_INDEX) * 2;
default:
return 100;
}
diff --git a/org.eclipse.jdt.text.tests/about_files/cpl-v10.html b/org.eclipse.jdt.text.tests/about_files/cpl-v10.html
deleted file mode 100644
index 455e7b0674..0000000000
--- a/org.eclipse.jdt.text.tests/about_files/cpl-v10.html
+++ /dev/null
@@ -1,125 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-<HEAD>
-<TITLE>Common Public License - v 1.0</TITLE>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</HEAD>
-
-<BODY BGCOLOR="#FFFFFF" VLINK="#800000">
-
-
-<P ALIGN="CENTER"><B>Common Public License - v 1.0</B>
-<P><B></B><FONT SIZE="3"></FONT>
-<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
-<P><FONT SIZE="2">"Contribution" means:</FONT>
-
-<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and<BR CLEAR="LEFT">
-b) in the case of each subsequent Contributor:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
-
-
-<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Contributor" means any person or entity that distributes the Program.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. </FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this Agreement.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.</FONT>
-<P><FONT SIZE="2"><B></B></FONT>
-<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
-<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:</FONT>
-
-<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
-
-
-<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
-
-
-<UL><FONT SIZE="2" COLOR="#FF0000"></FONT><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2">When the Program is made available in source code form:</FONT>
-
-<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
-
-
-<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any copyright notices contained within the Program. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
-<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
-<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not expressly granted under this Agreement are reserved.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-
-</BODY>
-
-</HTML> \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.examples.projects/cpl-v10.html b/org.eclipse.jdt.ui.examples.projects/cpl-v10.html
deleted file mode 100644
index 455e7b0674..0000000000
--- a/org.eclipse.jdt.ui.examples.projects/cpl-v10.html
+++ /dev/null
@@ -1,125 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-<HEAD>
-<TITLE>Common Public License - v 1.0</TITLE>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</HEAD>
-
-<BODY BGCOLOR="#FFFFFF" VLINK="#800000">
-
-
-<P ALIGN="CENTER"><B>Common Public License - v 1.0</B>
-<P><B></B><FONT SIZE="3"></FONT>
-<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
-<P><FONT SIZE="2">"Contribution" means:</FONT>
-
-<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and<BR CLEAR="LEFT">
-b) in the case of each subsequent Contributor:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
-
-
-<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Contributor" means any person or entity that distributes the Program.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. </FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this Agreement.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.</FONT>
-<P><FONT SIZE="2"><B></B></FONT>
-<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
-<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:</FONT>
-
-<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
-
-
-<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
-
-
-<UL><FONT SIZE="2" COLOR="#FF0000"></FONT><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2">When the Program is made available in source code form:</FONT>
-
-<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
-
-
-<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any copyright notices contained within the Program. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
-<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
-<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not expressly granted under this Agreement are reserved.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-
-</BODY>
-
-</HTML> \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/cpl-v10.html b/org.eclipse.jdt.ui.tests.refactoring/cpl-v10.html
deleted file mode 100644
index 455e7b0674..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/cpl-v10.html
+++ /dev/null
@@ -1,125 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-<HEAD>
-<TITLE>Common Public License - v 1.0</TITLE>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</HEAD>
-
-<BODY BGCOLOR="#FFFFFF" VLINK="#800000">
-
-
-<P ALIGN="CENTER"><B>Common Public License - v 1.0</B>
-<P><B></B><FONT SIZE="3"></FONT>
-<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
-<P><FONT SIZE="2">"Contribution" means:</FONT>
-
-<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and<BR CLEAR="LEFT">
-b) in the case of each subsequent Contributor:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
-
-
-<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Contributor" means any person or entity that distributes the Program.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. </FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this Agreement.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.</FONT>
-<P><FONT SIZE="2"><B></B></FONT>
-<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
-<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:</FONT>
-
-<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
-
-
-<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
-
-
-<UL><FONT SIZE="2" COLOR="#FF0000"></FONT><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2">When the Program is made available in source code form:</FONT>
-
-<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
-
-
-<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any copyright notices contained within the Program. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
-<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
-<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not expressly granted under this Agreement are reserved.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-
-</BODY>
-
-</HTML> \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java b/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java
index 84b36e736a..805c6c2a71 100644
--- a/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java
+++ b/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -106,23 +106,25 @@ public class HTMLTidyTest extends TestCase {
private StringMatcher[] getIgnores() throws IOException {
ArrayList<StringMatcher> matchers= new ArrayList<>();
InputStream is= getClass().getResourceAsStream("ignoreFiles.txt");
- BufferedReader reader= new BufferedReader(new InputStreamReader(is));
- while (reader.ready()) {
- String line= reader.readLine();
- if (line.length() > 0) {
- char first= line.charAt(0);
- if (line.endsWith("/*"))
- line= line.substring(0, line.length() - 2); // stops at directory during tree traversal
- if (first != '/' && first != '*') { // relative matches
- // emulate CHKPII specification:
- // matchers.add(new StringMatcher(fWorkspacePath + "/" + line, true, false));
-
- // emulate actual CHKPII implementation:
- matchers.add(new StringMatcher("*/" + line, true, false));
+ try (BufferedReader reader= new BufferedReader(new InputStreamReader(is)))
+ {
+ while (reader.ready()) {
+ String line= reader.readLine();
+ if (line.length() > 0) {
+ char first= line.charAt(0);
+ if (line.endsWith("/*"))
+ line= line.substring(0, line.length() - 2); // stops at directory during tree traversal
+ if (first != '/' && first != '*') { // relative matches
+ // emulate CHKPII specification:
+ // matchers.add(new StringMatcher(fWorkspacePath + "/" + line, true, false));
+
+ // emulate actual CHKPII implementation:
+ matchers.add(new StringMatcher("*/" + line, true, false));
+ }
+ matchers.add(new StringMatcher(line, true, false));
}
- matchers.add(new StringMatcher(line, true, false));
}
- }
+ };
return matchers.toArray(new StringMatcher[matchers.size()]);
}
diff --git a/org.eclipse.jdt.ui.tests/cpl-v10.html b/org.eclipse.jdt.ui.tests/cpl-v10.html
deleted file mode 100644
index 455e7b0674..0000000000
--- a/org.eclipse.jdt.ui.tests/cpl-v10.html
+++ /dev/null
@@ -1,125 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-<HEAD>
-<TITLE>Common Public License - v 1.0</TITLE>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</HEAD>
-
-<BODY BGCOLOR="#FFFFFF" VLINK="#800000">
-
-
-<P ALIGN="CENTER"><B>Common Public License - v 1.0</B>
-<P><B></B><FONT SIZE="3"></FONT>
-<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
-<P><FONT SIZE="2">"Contribution" means:</FONT>
-
-<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and<BR CLEAR="LEFT">
-b) in the case of each subsequent Contributor:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
-
-
-<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Contributor" means any person or entity that distributes the Program.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. </FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this Agreement.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.</FONT>
-<P><FONT SIZE="2"><B></B></FONT>
-<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.</FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-
-<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
-
-
-<UL><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
-<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:</FONT>
-
-<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
-
-
-<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
-
-
-<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
-
-
-<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and</FONT></UL>
-
-
-<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
-
-
-<UL><FONT SIZE="2" COLOR="#FF0000"></FONT><FONT SIZE="2"></FONT></UL>
-
-<P><FONT SIZE="2">When the Program is made available in source code form:</FONT>
-
-<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
-
-
-<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
-
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any copyright notices contained within the Program. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
-<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"></FONT>
-<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
-<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not expressly granted under this Agreement are reserved.</FONT>
-<P><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
-<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
-<P><FONT SIZE="2"></FONT>
-
-</BODY>
-
-</HTML> \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
index 3f62956fe3..caa9ba1f36 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
@@ -11,6 +11,7 @@
* Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
* Lukas Hanke <hanke@yatta.de> - Bug 430818 [1.8][quick fix] Quick fix for "for loop" is not shown for bare local variable/argument/field - https://bugs.eclipse.org/bugs/show_bug.cgi?id=430818
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
+ * Jens Reimann <jens.reimann@ibh-systems.com>, Fabian Pfaff <fabian.pfaff@vogella.com> - Bug 197850: [quick assist] Add import static field/method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=197850
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix;
@@ -10031,4 +10032,557 @@ public class AssistQuickFixTest extends QuickFixTest {
fJProject1.setOptions(saveOptions);
}
}
+
+ public void testConvertQualifiedNameToStaticImport() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" static String str;\n");
+ buf.append(" static <V> void doIt(V o) {};\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class S {\n");
+ buf.append(" {\n");
+ buf.append(" System.out.println(T.str);\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu = pack1.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "str";
+ int offset= buf.toString().indexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test1;\n");
+ expectation.append("\n");
+ expectation.append("import static test1.T.str;\n");
+ expectation.append("\n");
+ expectation.append("public class S {\n");
+ expectation.append(" {\n");
+ expectation.append(" System.out.println(str);\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+
+ selection= "ystem";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testConvertMethodInvocationWithTypeToStaticImport() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" static String str;\n");
+ buf.append(" static <V> void doIt(V o) {};\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class S {\n");
+ buf.append(" {\n");
+ buf.append(" T.<String>doIt(\"\");\n");
+ buf.append(" T.doIt(\"\");\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu = pack1.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "It";
+ int offset= buf.toString().indexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test1;\n");
+ expectation.append("\n");
+ expectation.append("import static test1.T.doIt;\n");
+ expectation.append("\n");
+ expectation.append("public class S {\n");
+ expectation.append(" {\n");
+ expectation.append(" doIt(\"\");\n");
+ expectation.append(" T.doIt(\"\");\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test1;\n");
+ expectation.append("\n");
+ expectation.append("import static test1.T.doIt;\n");
+ expectation.append("\n");
+ expectation.append("public class S {\n");
+ expectation.append(" {\n");
+ expectation.append(" doIt(\"\");\n");
+ expectation.append(" doIt(\"\");\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testConvertConstantToStaticImport() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" public static final String FOO = \"BAR\";\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class S {\n");
+ buf.append(" {\n");
+ buf.append(" public String foo = T.FOO;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu = pack1.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "FOO";
+ int offset= buf.toString().indexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test1;\n");
+ expectation.append("\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("\n");
+ expectation.append("public class S {\n");
+ expectation.append(" {\n");
+ expectation.append(" public String foo = FOO;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testConvertToStaticImportDoesNotAddImportWhenInScope() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" static String str;\n");
+ buf.append(" String str2 = T.str;\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ String selection= "str";
+ int offset= buf.toString().lastIndexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test1;\n");
+ expectation.append("public class T {\n");
+ expectation.append(" static String str;\n");
+ expectation.append(" String str2 = str;\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().lastIndexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testConvertToStaticImportDoesRemoveUnusedImport() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" public static final String FOO = \"BAR\";\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
+ buf= new StringBuffer();
+ buf.append("package test2;\n");
+ buf.append("import test1.T\n");
+ buf.append("public class S {\n");
+ buf.append(" {\n");
+ buf.append(" public String foo = T.FOO;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack2.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "FOO";
+ int offset= buf.toString().indexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("public class S {\n");
+ expectation.append(" {\n");
+ expectation.append(" public String foo = FOO;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("public class S {\n");
+ expectation.append(" {\n");
+ expectation.append(" public String foo = FOO;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testConvertToStaticImportDoesntRemoveImportWhenReferencedByDifferentReferenceType() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" public static final String FOO = \"BAR\";\n");
+ buf.append(" public static void bar() {};\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
+ buf= new StringBuffer();
+ buf.append("package test2;\n");
+ buf.append("import test1.T\n");
+ buf.append("public class S {\n");
+ buf.append(" public S() {\n");
+ buf.append(" String foo = T.FOO;\n");
+ buf.append(" T.bar();\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack2.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "FOO";
+ int offset= buf.toString().indexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo = FOO;\n");
+ expectation.append(" T.bar();\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo = FOO;\n");
+ expectation.append(" T.bar();\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "bar";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.bar;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo = T.FOO;\n");
+ expectation.append(" bar();\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.bar;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo = T.FOO;\n");
+ expectation.append(" bar();\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testConvertToStaticImportDoesntRemoveImportWhenReferencedBySameReferenceType() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" public static final String FOO = \"BAR\";\n");
+ buf.append(" public static final String ZIP = \"ZAP\";\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
+ buf= new StringBuffer();
+ buf.append("package test2;\n");
+ buf.append("import test1.T\n");
+ buf.append("public class S {\n");
+ buf.append(" public S() {\n");
+ buf.append(" String foo = T.FOO;\n");
+ buf.append(" String zip = T.ZIP;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack2.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "FOO";
+ int offset= buf.toString().indexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ ArrayList<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo = FOO;\n");
+ expectation.append(" String zip = T.ZIP;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo = FOO;\n");
+ expectation.append(" String zip = T.ZIP;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+
+ IPackageFragment pack3= fSourceFolder.createPackageFragment("test3", false, null);
+ buf= new StringBuffer();
+ buf.append("package test3;\n");
+ buf.append("import test1.T\n");
+ buf.append("public class G {\n");
+ buf.append(" public G() {\n");
+ buf.append(" String foo = T.FOO;\n");
+ buf.append(" String zip = T.FOO;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ cu= pack3.createCompilationUnit("G.java", buf.toString(), false, null);
+
+ selection= "FOO";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test3;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class G {\n");
+ expectation.append(" public G() {\n");
+ expectation.append(" String foo = FOO;\n");
+ expectation.append(" String zip = T.FOO;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test3;\n");
+ expectation.append("import static test1.T.FOO;\n");
+ expectation.append("public class G {\n");
+ expectation.append(" public G() {\n");
+ expectation.append(" String foo = FOO;\n");
+ expectation.append(" String zip = FOO;\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
+ public void testCanConvertToStaticImportWhenClassContainsMethodInvocationWithoutExpression() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class T {\n");
+ buf.append(" public static String bar() { return \"\"; };\n");
+ buf.append("}\n");
+ pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
+ IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
+ buf= new StringBuffer();
+ buf.append("package test2;\n");
+ buf.append("import static test1.T.bar;\n");
+ buf.append("\n");
+ buf.append("import test1.T\n");
+ buf.append("public class S {\n");
+ buf.append(" public S() {\n");
+ buf.append(" String foo1 = T.bar();\n");
+ buf.append(" String foo2 = bar();\n");
+ buf.append(" String foo3 = T.bar();\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack2.createCompilationUnit("S.java", buf.toString(), false, null);
+
+ String selection= "bar";
+ int offset= buf.toString().lastIndexOf(selection);
+ AssistContext context= getCorrectionContext(cu, offset, selection.length());
+ ArrayList<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ StringBuffer expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.bar;\n");
+ expectation.append("\n");
+ expectation.append("import test1.T\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo1 = T.bar();\n");
+ expectation.append(" String foo2 = bar();\n");
+ expectation.append(" String foo3 = bar();\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import", proposals);
+
+ expectation= new StringBuffer();
+ expectation.append("package test2;\n");
+ expectation.append("import static test1.T.bar;\n");
+ expectation.append("public class S {\n");
+ expectation.append(" public S() {\n");
+ expectation.append(" String foo1 = bar();\n");
+ expectation.append(" String foo2 = bar();\n");
+ expectation.append(" String foo3 = bar();\n");
+ expectation.append(" }\n");
+ expectation.append("}\n");
+ assertProposalPreviewEquals(expectation.toString(), "Convert to static import (replace all occurrences)", proposals);
+
+ selection= "T";
+ offset= buf.toString().indexOf(selection);
+ context= getCorrectionContext(cu, offset, selection.length());
+ proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 0);
+ assertProposalDoesNotExist(proposals, "Convert to static import");
+ assertProposalDoesNotExist(proposals, "Convert to static import (replace all occurrences)");
+ }
+
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/SortMembersOperation.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/SortMembersOperation.java
index 5fb4bbb764..d0e739ce4b 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/SortMembersOperation.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/SortMembersOperation.java
@@ -37,6 +37,7 @@ import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.util.CompilationUnitSorter;
+import org.eclipse.jdt.internal.core.manipulation.MembersOrderPreferenceCacheCommon;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
@@ -71,37 +72,37 @@ public class SortMembersOperation implements IWorkspaceRunnable {
{
MethodDeclaration method= (MethodDeclaration) bodyDeclaration;
if (method.isConstructor()) {
- return MembersOrderPreferenceCache.CONSTRUCTORS_INDEX;
+ return MembersOrderPreferenceCacheCommon.CONSTRUCTORS_INDEX;
}
int flags= method.getModifiers();
if (Modifier.isStatic(flags))
- return MembersOrderPreferenceCache.STATIC_METHODS_INDEX;
+ return MembersOrderPreferenceCacheCommon.STATIC_METHODS_INDEX;
else
- return MembersOrderPreferenceCache.METHOD_INDEX;
+ return MembersOrderPreferenceCacheCommon.METHOD_INDEX;
}
case ASTNode.FIELD_DECLARATION :
{
if (JdtFlags.isStatic(bodyDeclaration))
- return MembersOrderPreferenceCache.STATIC_FIELDS_INDEX;
+ return MembersOrderPreferenceCacheCommon.STATIC_FIELDS_INDEX;
else
- return MembersOrderPreferenceCache.FIELDS_INDEX;
+ return MembersOrderPreferenceCacheCommon.FIELDS_INDEX;
}
case ASTNode.INITIALIZER :
{
int flags= ((Initializer) bodyDeclaration).getModifiers();
if (Modifier.isStatic(flags))
- return MembersOrderPreferenceCache.STATIC_INIT_INDEX;
+ return MembersOrderPreferenceCacheCommon.STATIC_INIT_INDEX;
else
- return MembersOrderPreferenceCache.INIT_INDEX;
+ return MembersOrderPreferenceCacheCommon.INIT_INDEX;
}
case ASTNode.TYPE_DECLARATION :
case ASTNode.ENUM_DECLARATION :
case ASTNode.ANNOTATION_TYPE_DECLARATION :
- return MembersOrderPreferenceCache.TYPE_INDEX;
+ return MembersOrderPreferenceCacheCommon.TYPE_INDEX;
case ASTNode.ENUM_CONSTANT_DECLARATION :
- return MembersOrderPreferenceCache.ENUM_CONSTANTS_INDEX;
+ return MembersOrderPreferenceCacheCommon.ENUM_CONSTANTS_INDEX;
case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- return MembersOrderPreferenceCache.METHOD_INDEX; // reusing the method index
+ return MembersOrderPreferenceCacheCommon.METHOD_INDEX; // reusing the method index
}
return 0; // should never happen
@@ -249,12 +250,12 @@ public class SortMembersOperation implements IWorkspaceRunnable {
private static int sortPreservedCategory(int category) {
switch (category) {
- case MembersOrderPreferenceCache.STATIC_FIELDS_INDEX:
- case MembersOrderPreferenceCache.STATIC_INIT_INDEX:
- return MembersOrderPreferenceCache.STATIC_FIELDS_INDEX;
- case MembersOrderPreferenceCache.FIELDS_INDEX:
- case MembersOrderPreferenceCache.INIT_INDEX:
- return MembersOrderPreferenceCache.FIELDS_INDEX;
+ case MembersOrderPreferenceCacheCommon.STATIC_FIELDS_INDEX:
+ case MembersOrderPreferenceCacheCommon.STATIC_INIT_INDEX:
+ return MembersOrderPreferenceCacheCommon.STATIC_FIELDS_INDEX;
+ case MembersOrderPreferenceCacheCommon.FIELDS_INDEX:
+ case MembersOrderPreferenceCacheCommon.INIT_INDEX:
+ return MembersOrderPreferenceCacheCommon.FIELDS_INDEX;
default:
return category;
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/AccessorClassCreator.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/AccessorClassCreator.java
index 1e401a50cf..e81f502c13 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/AccessorClassCreator.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/AccessorClassCreator.java
@@ -42,6 +42,7 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
import org.eclipse.jdt.core.formatter.CodeFormatter;
+import org.eclipse.jdt.internal.core.manipulation.MembersOrderPreferenceCacheCommon;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.refactoring.nls.changes.CreateTextFileChange;
import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil;
@@ -149,9 +150,9 @@ public class AccessorClassCreator {
private String createClass(String lineDelim) throws CoreException {
if (fIsEclipseNLS) {
MembersOrderPreferenceCache sortOrder= JavaPlugin.getDefault().getMemberOrderPreferenceCache();
- int constructorIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.CONSTRUCTORS_INDEX);
- int fieldIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.STATIC_FIELDS_INDEX);
- int initIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.STATIC_INIT_INDEX);
+ int constructorIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.CONSTRUCTORS_INDEX);
+ int fieldIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.STATIC_FIELDS_INDEX);
+ int initIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.STATIC_INIT_INDEX);
String constructor= createConstructor(lineDelim) + lineDelim;
String initializer= createStaticInitializer(lineDelim) + lineDelim;
@@ -189,8 +190,8 @@ public class AccessorClassCreator {
return result.toString();
} else {
MembersOrderPreferenceCache sortOrder= JavaPlugin.getDefault().getMemberOrderPreferenceCache();
- int constructorIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.CONSTRUCTORS_INDEX);
- int methodIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.METHOD_INDEX);
+ int constructorIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.CONSTRUCTORS_INDEX);
+ int methodIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.METHOD_INDEX);
String constructor= lineDelim + createConstructor(lineDelim);
String method= lineDelim + createGetStringMethod(lineDelim);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java
index 1b4023150c..ef344ddf75 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java
@@ -395,6 +395,10 @@ public class JavaPlugin extends AbstractUIPlugin implements DebugOptionsListener
}
});
+ // set the Preferences node id to get preferences from which is needed
+ // by the MembersOrderPreferenceCache common logic
+ JavaManipulation.setPreferenceNodeId(getPluginId());
+
IPreferenceStore store= getPreferenceStore();
// must add here to guarantee that it is the first in the listener list
@@ -402,7 +406,7 @@ public class JavaPlugin extends AbstractUIPlugin implements DebugOptionsListener
fMembersOrderPreferenceCache.install(store);
FormatterProfileStore.checkCurrentOptionsVersion();
-
+
// make sure org.eclipse.jdt.core.manipulation is loaded too
// can be removed if JavaElementPropertyTester is moved down to jdt.core (bug 127085)
JavaManipulation.class.toString();
@@ -426,7 +430,6 @@ public class JavaPlugin extends AbstractUIPlugin implements DebugOptionsListener
new InitializeAfterLoadJob().schedule(); // last call in start, see bug 191193
}
- JavaManipulation.setPreferenceNodeId(getPluginId());
}
private void createOrUpdateWorkingSet(String name, String label, final String id) {
@@ -1020,7 +1023,7 @@ public class JavaPlugin extends AbstractUIPlugin implements DebugOptionsListener
return JavaUIMessages.JavaPlugin_additionalInfo_affordance;
}
-
+
/**
* Returns the bundles for a given bundle name and version range,
* regardless whether the bundle is resolved or not.
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/AbstractConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/AbstractConfigurationBlock.java
index 5f42457636..a45e99a077 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/AbstractConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/AbstractConfigurationBlock.java
@@ -15,6 +15,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.swt.SWT;
@@ -387,18 +388,16 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
private void initializeFields() {
- Iterator<Button> iter= fCheckBoxes.keySet().iterator();
- while (iter.hasNext()) {
- Button b= iter.next();
- String key= fCheckBoxes.get(b);
- b.setSelection(fStore.getBoolean(key));
+ for (Entry<Button, String> entry : fCheckBoxes.entrySet()) {
+ Button b= entry.getKey();
+ String keyForStore= entry.getValue();
+ b.setSelection(fStore.getBoolean(keyForStore));
}
- Iterator<Text> iter2= fTextFields.keySet().iterator();
- while (iter2.hasNext()) {
- Text t= iter2.next();
- String key= fTextFields.get(t);
- t.setText(fStore.getString(key));
+ for (Entry<Text, String> entry : fTextFields.entrySet()) {
+ Text t= entry.getKey();
+ String keyForStore= entry.getValue();
+ t.setText(fStore.getString(keyForStore));
}
// Update slaves
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java
index 57c56b21f4..bc64183d2f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,71 +7,42 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Red Hat Inc. - split out non-UI logic to MemebersOrderPreferenceCacheCommon
*******************************************************************************/
package org.eclipse.jdt.internal.ui.preferences;
-import java.util.StringTokenizer;
-
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.internal.core.manipulation.MembersOrderPreferenceCacheCommon;
import org.eclipse.jdt.ui.PreferenceConstants;
/**
- */
-public class MembersOrderPreferenceCache implements IPropertyChangeListener {
-
- public static final int TYPE_INDEX= 0;
- public static final int CONSTRUCTORS_INDEX= 1;
- public static final int METHOD_INDEX= 2;
- public static final int FIELDS_INDEX= 3;
- public static final int INIT_INDEX= 4;
- public static final int STATIC_FIELDS_INDEX= 5;
- public static final int STATIC_INIT_INDEX= 6;
- public static final int STATIC_METHODS_INDEX= 7;
- public static final int ENUM_CONSTANTS_INDEX= 8;
- public static final int N_CATEGORIES= ENUM_CONSTANTS_INDEX + 1;
-
- private static final int PUBLIC_INDEX= 0;
- private static final int PRIVATE_INDEX= 1;
- private static final int PROTECTED_INDEX= 2;
- private static final int DEFAULT_INDEX= 3;
- private static final int N_VISIBILITIES= DEFAULT_INDEX + 1;
-
- private int[] fCategoryOffsets= null;
-
- private boolean fSortByVisibility;
- private int[] fVisibilityOffsets= null;
+ */
+public class MembersOrderPreferenceCache extends MembersOrderPreferenceCacheCommon implements IPropertyChangeListener {
private IPreferenceStore fPreferenceStore;
public MembersOrderPreferenceCache() {
fPreferenceStore= null;
- fCategoryOffsets= null;
- fSortByVisibility= false;
- fVisibilityOffsets= null;
}
public void install(IPreferenceStore store) {
fPreferenceStore= store;
- store.addPropertyChangeListener(this);
+ store.addPropertyChangeListener(this);
+ super.install();
fSortByVisibility= store.getBoolean(PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER);
}
+ @Override
public void dispose() {
+ super.dispose();
fPreferenceStore.removePropertyChangeListener(this);
fPreferenceStore= null;
}
- public static boolean isMemberOrderProperty(String property) {
- return PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER.equals(property)
- || PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER.equals(property)
- || PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER.equals(property);
- }
-
@Override
public void propertyChange(PropertyChangeEvent event) {
String property= event.getProperty();
@@ -85,14 +56,8 @@ public class MembersOrderPreferenceCache implements IPropertyChangeListener {
}
}
- public int getCategoryIndex(int kind) {
- if (fCategoryOffsets == null) {
- fCategoryOffsets= getCategoryOffsets();
- }
- return fCategoryOffsets[kind];
- }
-
- private int[] getCategoryOffsets() {
+ @Override
+ protected int[] getCategoryOffsets() {
int[] offsets= new int[N_CATEGORIES];
IPreferenceStore store= fPreferenceStore;
String key= PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER;
@@ -104,55 +69,8 @@ public class MembersOrderPreferenceCache implements IPropertyChangeListener {
return offsets;
}
- private boolean fillCategoryOffsetsFromPreferenceString(String str, int[] offsets) {
- StringTokenizer tokenizer= new StringTokenizer(str, ","); //$NON-NLS-1$
- int i= 0;
- offsets[ENUM_CONSTANTS_INDEX]= i++; // enum constants always on top
-
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
- if ("T".equals(token)) { //$NON-NLS-1$
- offsets[TYPE_INDEX]= i++;
- } else if ("M".equals(token)) { //$NON-NLS-1$
- offsets[METHOD_INDEX]= i++;
- } else if ("F".equals(token)) { //$NON-NLS-1$
- offsets[FIELDS_INDEX]= i++;
- } else if ("I".equals(token)) { //$NON-NLS-1$
- offsets[INIT_INDEX]= i++;
- } else if ("SF".equals(token)) { //$NON-NLS-1$
- offsets[STATIC_FIELDS_INDEX]= i++;
- } else if ("SI".equals(token)) { //$NON-NLS-1$
- offsets[STATIC_INIT_INDEX]= i++;
- } else if ("SM".equals(token)) { //$NON-NLS-1$
- offsets[STATIC_METHODS_INDEX]= i++;
- } else if ("C".equals(token)) { //$NON-NLS-1$
- offsets[CONSTRUCTORS_INDEX]= i++;
- }
- }
- return i == N_CATEGORIES;
- }
-
- public boolean isSortByVisibility() {
- return fSortByVisibility;
- }
-
- public int getVisibilityIndex(int modifierFlags) {
- if (fVisibilityOffsets == null) {
- fVisibilityOffsets= getVisibilityOffsets();
- }
- int kind= DEFAULT_INDEX;
- if (Flags.isPublic(modifierFlags)) {
- kind= PUBLIC_INDEX;
- } else if (Flags.isProtected(modifierFlags)) {
- kind= PROTECTED_INDEX;
- } else if (Flags.isPrivate(modifierFlags)) {
- kind= PRIVATE_INDEX;
- }
-
- return fVisibilityOffsets[kind];
- }
-
- private int[] getVisibilityOffsets() {
+ @Override
+ protected int[] getVisibilityOffsets() {
int[] offsets= new int[N_VISIBILITIES];
IPreferenceStore store= fPreferenceStore;
String key= PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER;
@@ -164,23 +82,4 @@ public class MembersOrderPreferenceCache implements IPropertyChangeListener {
return offsets;
}
- private boolean fillVisibilityOffsetsFromPreferenceString(String str, int[] offsets) {
- StringTokenizer tokenizer= new StringTokenizer(str, ","); //$NON-NLS-1$
- int i= 0;
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
- if ("B".equals(token)) { //$NON-NLS-1$
- offsets[PUBLIC_INDEX]= i++;
- } else if ("V".equals(token)) { //$NON-NLS-1$
- offsets[PRIVATE_INDEX]= i++;
- } else if ("R".equals(token)) { //$NON-NLS-1$
- offsets[PROTECTED_INDEX]= i++;
- } else if ("D".equals(token)) { //$NON-NLS-1$
- offsets[DEFAULT_INDEX]= i++;
- }
- }
- return i == N_VISIBILITIES;
- }
-
-
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
index b895efe158..94c9d79890 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
@@ -12,6 +12,7 @@
* Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
* Sandra Lions <sandra.lions-piron@oracle.com> - [quick fix] for qualified enum constants in switch-case labels - https://bugs.eclipse.org/bugs/90140
* Jeremie Bresson <dev@jmini.fr> - Bug 439912: [1.8][quick assist] Add quick assists to add and remove parentheses around single lambda parameter - https://bugs.eclipse.org/439912
+ * Jens Reimann <jens.reimann@ibh-systems.com>, Fabian Pfaff <fabian.pfaff@vogella.com> - Bug 197850: [quick assist] Add import static field/method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=197850
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
@@ -60,6 +61,8 @@ public final class CorrectionMessages extends NLS {
public static String QuickAssistProcessor_convert_to_string_buffer_description;
public static String QuickAssistProcessor_exceptiontothrows_description;
public static String QuickAssistProcessor_extract_to_constant_description;
+ public static String QuickAssistProcessor_convert_to_static_import;
+ public static String QuickAssistProcessor_convert_to_static_import_replace_all;
public static String QuickAssistProcessor_inline_local_description;
public static String QuickAssistProcessor_name_extension_from_class;
public static String QuickAssistProcessor_name_extension_from_interface;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
index c87d962f6f..c00ab77dd0 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
@@ -12,6 +12,7 @@
# Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
# Sandra Lions <sandra.lions-piron@oracle.com> - [quick fix] for qualified enum constants in switch-case labels - https://bugs.eclipse.org/bugs/90140
# Jeremie Bresson <dev@jmini.fr> - Bug 439912: [1.8][quick assist] Add quick assists to add and remove parentheses around single lambda parameter - https://bugs.eclipse.org/439912
+# Jens Reimann <jens.reimann@ibh-systems.com>, Fabian Pfaff <fabian.pfaff@vogella.com> - Bug 197850: [quick assist] Add import static field/method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=197850
###############################################################################
# ------ SerialVersionProposal
@@ -360,6 +361,8 @@ QuickAssistProcessor_replacebodywithblock_description=Change body statement to b
QuickAssistProcessor_invertequals_description=Invert equals
QuickAssistProcessor_inline_local_description=Inline local variable
+QuickAssistProcessor_convert_to_static_import=Convert to static import
+QuickAssistProcessor_convert_to_static_import_replace_all=Convert to static import (replace all occurrences)
QuickAssistProcessor_convert_anonym_to_nested=Convert anonymous to nested class
QuickAssistProcessor_name_extension_from_class={0}Implementation
QuickAssistProcessor_typetoarrayInitializer_description=Add type to initializer
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
index a30982cde9..19fe0faaad 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
@@ -14,6 +14,7 @@
* Eugene Lucash <e.lucash@gmail.com> - [quick assist] Add key binding for Extract method Quick Assist - https://bugs.eclipse.org/424166
* Lukas Hanke <hanke@yatta.de> - Bug 430818 [1.8][quick fix] Quick fix for "for loop" is not shown for bare local variable/argument/field - https://bugs.eclipse.org/bugs/show_bug.cgi?id=430818
* Jeremie Bresson <dev@jmini.fr> - Bug 439912: [1.8][quick assist] Add quick assists to add and remove parentheses around single lambda parameter - https://bugs.eclipse.org/439912
+ * Jens Reimann <jens.reimann@ibh-systems.com>, Fabian Pfaff <fabian.pfaff@vogella.com> - Bug 197850: [quick assist] Add import static field/method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=197850
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
@@ -51,6 +52,8 @@ import org.eclipse.jdt.core.NamingConventions;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.ArrayAccess;
import org.eclipse.jdt.core.dom.ArrayCreation;
@@ -260,7 +263,8 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
|| getMakeVariableDeclarationFinalProposals(context, null)
|| getMissingCaseStatementProposals(context, coveringNode, null)
|| getConvertStringConcatenationProposals(context, null)
- || getInferDiamondArgumentsProposal(context, coveringNode, null, null);
+ || getInferDiamondArgumentsProposal(context, coveringNode, null, null)
+ || getAddStaticImportProposals(context, coveringNode, null);
}
return false;
}
@@ -319,6 +323,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
getMissingCaseStatementProposals(context, coveringNode, resultingCollections);
getConvertVarTypeToResolvedTypeProposal(context, coveringNode, resultingCollections);
getConvertResolvedTypeToVarTypeProposal(context, coveringNode, resultingCollections);
+ getAddStaticImportProposals(context, coveringNode, resultingCollections);
}
return resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
}
@@ -3838,4 +3843,181 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
}
return true;
}
+
+ /**
+ * Create static import proposal
+ * @param context the invocation context
+ * @param node the node to work on
+ * @param proposals the receiver of proposals, may be {@code null}
+ * @return {@code true} if the operation could or has been performed, {@code false otherwise}
+ */
+ private static boolean getAddStaticImportProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> proposals) {
+ if (!(node instanceof SimpleName)) {
+ return false;
+ }
+
+ final SimpleName name= (SimpleName) node;
+ final IBinding binding;
+ final ITypeBinding declaringClass;
+
+ // get bindings for method invocation or variable access
+
+ if (name.getParent() instanceof MethodInvocation) {
+ MethodInvocation mi= (MethodInvocation) name.getParent();
+
+ if (mi.getExpression() != null && mi.getExpression().equals(name)) {
+ return false;
+ }
+
+ binding= mi.resolveMethodBinding();
+ if (binding == null) {
+ return false;
+ }
+
+ declaringClass= ((IMethodBinding) binding).getDeclaringClass();
+ } else if (name.getParent() instanceof QualifiedName) {
+ QualifiedName qn= (QualifiedName) name.getParent();
+
+ if (name.equals(qn.getQualifier())) {
+ return false;
+ }
+
+ binding= qn.resolveBinding();
+ if (!(binding instanceof IVariableBinding)) {
+ return false;
+ }
+ declaringClass= ((IVariableBinding) binding).getDeclaringClass();
+ } else {
+ return false;
+ }
+
+ // at this point binding cannot be null
+
+ if (!Modifier.isStatic(binding.getModifiers())) {
+ // only work with static bindings
+ return false;
+ }
+
+ boolean needImport= false;
+ if (!isDirectlyAccessible(name, declaringClass)) {
+ if (Modifier.isPrivate(declaringClass.getModifiers())) {
+ return false;
+ }
+ needImport= true;
+ }
+
+ if (proposals == null) {
+ return true; // return early, just testing if we could do it
+ }
+
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+
+ try {
+ ImportRewrite importRewrite= StubUtility.createImportRewrite(context.getCompilationUnit(), true);
+ ImportRewrite importRewriteReplaceAllOccurences= StubUtility.createImportRewrite(context.getCompilationUnit(), true);
+ ASTRewrite astRewrite= ASTRewrite.create(node.getAST());
+ ASTRewrite astRewriteReplaceAllOccurrences= ASTRewrite.create(node.getAST());
+
+ int[] allReferencesToDeclaringClass= new int[1];
+ allReferencesToDeclaringClass[0]= 0;
+ int[] referencesFromOtherOccurences= new int[1];
+ referencesFromOtherOccurences[0]= 0;
+ MethodInvocation mi= null;
+ QualifiedName qn= null;
+ if (name.getParent() instanceof MethodInvocation) {
+ mi= (MethodInvocation) name.getParent();
+ // convert the method invocation
+ astRewrite.remove(mi.getExpression(), null);
+ mi.typeArguments().forEach(type -> astRewrite.remove((Type) type, null));
+ } else if (name.getParent() instanceof QualifiedName) {
+ qn= (QualifiedName) name.getParent();
+ // convert the field access
+ astRewrite.replace(qn, ASTNodeFactory.newName(node.getAST(), name.getFullyQualifiedName()), null);
+ } else {
+ return false;
+ }
+
+ MethodInvocation miFinal= mi;
+ name.getRoot().accept(new ASTVisitor() {
+ @Override
+ public boolean visit(MethodInvocation methodInvocation) {
+ if (methodInvocation.getExpression() == null) {
+ return super.visit(methodInvocation);
+ }
+
+ if (miFinal != null &&
+ miFinal.getExpression().toString().equals(methodInvocation.getExpression().toString()) && miFinal.getName().toString().equals(methodInvocation.getName().toString())) {
+ methodInvocation.typeArguments().forEach(type -> astRewriteReplaceAllOccurrences.remove((Type) type, null));
+ astRewriteReplaceAllOccurrences.remove(methodInvocation.getExpression(), null);
+ allReferencesToDeclaringClass[0]++;
+ } else if (declaringClass.getName().equals(methodInvocation.getExpression().toString())) {
+ allReferencesToDeclaringClass[0]++;
+ referencesFromOtherOccurences[0]++;
+ }
+ return super.visit(methodInvocation);
+ }
+ });
+ QualifiedName qnFinal= qn;
+ name.getRoot().accept(new ASTVisitor() {
+ @Override
+ public boolean visit(QualifiedName qualifiedName) {
+ if (qnFinal != null &&
+ qualifiedName.getFullyQualifiedName().equals(qnFinal.getFullyQualifiedName())) {
+ astRewriteReplaceAllOccurrences.replace(qualifiedName, ASTNodeFactory.newName(node.getAST(), name.getFullyQualifiedName()), null);
+ allReferencesToDeclaringClass[0]++;
+ } else if (declaringClass.getName().equals(qualifiedName.getQualifier().getFullyQualifiedName())) {
+ allReferencesToDeclaringClass[0]++;
+ referencesFromOtherOccurences[0]++;
+ }
+ return super.visit(qualifiedName);
+ }
+ });
+
+ // add the static import
+ if (needImport) {
+ importRewrite.addStaticImport(binding);
+ if (allReferencesToDeclaringClass[0] == 1) { // If there are exactly 1 visits, the import can be removed
+ importRewrite.removeImport(declaringClass.getQualifiedName());
+ }
+ importRewriteReplaceAllOccurences.addStaticImport(binding);
+ if (referencesFromOtherOccurences[0] == 0) {
+ importRewriteReplaceAllOccurences.removeImport(declaringClass.getQualifiedName());
+ }
+ }
+
+ ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(CorrectionMessages.QuickAssistProcessor_convert_to_static_import, context.getCompilationUnit(), astRewrite,
+ IProposalRelevance.ADD_STATIC_IMPORT, image);
+ proposal.setImportRewrite(importRewrite);
+ proposals.add(proposal);
+ ASTRewriteCorrectionProposal proposalReplaceAllOccurrences= new ASTRewriteCorrectionProposal(CorrectionMessages.QuickAssistProcessor_convert_to_static_import_replace_all, context.getCompilationUnit(), astRewriteReplaceAllOccurrences,
+ IProposalRelevance.ADD_STATIC_IMPORT, image);
+ proposalReplaceAllOccurrences.setImportRewrite(importRewriteReplaceAllOccurences);
+ proposals.add(proposalReplaceAllOccurrences);
+ } catch (JavaModelException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private static boolean isDirectlyAccessible(ASTNode nameNode, ITypeBinding declaringClass) {
+ ASTNode node= nameNode.getParent();
+ while (node != null) {
+
+ if (node instanceof AbstractTypeDeclaration) {
+ ITypeBinding binding= ((AbstractTypeDeclaration) node).resolveBinding();
+ if (binding != null && binding.isSubTypeCompatible(declaringClass)) {
+ return true;
+ }
+ } else if (node instanceof AnonymousClassDeclaration) {
+ ITypeBinding binding= ((AnonymousClassDeclaration) node).resolveBinding();
+ if (binding != null && binding.isSubTypeCompatible(declaringClass)) {
+ return true;
+ }
+ }
+
+ node= node.getParent();
+ }
+ return false;
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementComparator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementComparator.java
index cfd36cbef5..72cd7972f0 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementComparator.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementComparator.java
@@ -42,6 +42,7 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.internal.core.manipulation.MembersOrderPreferenceCacheCommon;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
@@ -120,35 +121,35 @@ public class JavaElementComparator extends ViewerComparator {
{
IMethod method= (IMethod) je;
if (method.isConstructor()) {
- return getMemberCategory(MembersOrderPreferenceCache.CONSTRUCTORS_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.CONSTRUCTORS_INDEX);
}
int flags= method.getFlags();
if (Flags.isStatic(flags))
- return getMemberCategory(MembersOrderPreferenceCache.STATIC_METHODS_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.STATIC_METHODS_INDEX);
else
- return getMemberCategory(MembersOrderPreferenceCache.METHOD_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.METHOD_INDEX);
}
case IJavaElement.FIELD :
{
int flags= ((IField) je).getFlags();
if (Flags.isEnum(flags)) {
- return getMemberCategory(MembersOrderPreferenceCache.ENUM_CONSTANTS_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.ENUM_CONSTANTS_INDEX);
}
if (Flags.isStatic(flags))
- return getMemberCategory(MembersOrderPreferenceCache.STATIC_FIELDS_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.STATIC_FIELDS_INDEX);
else
- return getMemberCategory(MembersOrderPreferenceCache.FIELDS_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.FIELDS_INDEX);
}
case IJavaElement.INITIALIZER :
{
int flags= ((IInitializer) je).getFlags();
if (Flags.isStatic(flags))
- return getMemberCategory(MembersOrderPreferenceCache.STATIC_INIT_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.STATIC_INIT_INDEX);
else
- return getMemberCategory(MembersOrderPreferenceCache.INIT_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.INIT_INDEX);
}
case IJavaElement.TYPE :
- return getMemberCategory(MembersOrderPreferenceCache.TYPE_INDEX);
+ return getMemberCategory(MembersOrderPreferenceCacheCommon.TYPE_INDEX);
case IJavaElement.PACKAGE_DECLARATION :
return PACKAGE_DECL;
case IJavaElement.IMPORT_CONTAINER :
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java
index 8909d93ac0..0cce93abf1 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java
@@ -38,6 +38,7 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.manipulation.CodeStyleConfiguration;
import org.eclipse.jdt.core.manipulation.JavaManipulation;
+import org.eclipse.jdt.internal.core.manipulation.MembersOrderPreferenceCacheCommon;
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
import org.eclipse.jdt.ui.text.IJavaColorConstants;
@@ -199,7 +200,7 @@ public class PreferenceConstants {
* </p>
* @since 2.1
*/
- public static final String APPEARANCE_MEMBER_SORT_ORDER= "outlinesortoption"; //$NON-NLS-1$
+ public static final String APPEARANCE_MEMBER_SORT_ORDER= MembersOrderPreferenceCacheCommon.APPEARANCE_MEMBER_SORT_ORDER;
/**
* A named preference that defines how member elements are ordered by visibility in the
@@ -217,7 +218,7 @@ public class PreferenceConstants {
* </p>
* @since 3.0
*/
- public static final String APPEARANCE_VISIBILITY_SORT_ORDER= "org.eclipse.jdt.ui.visibility.order"; //$NON-NLS-1$
+ public static final String APPEARANCE_VISIBILITY_SORT_ORDER= MembersOrderPreferenceCacheCommon.APPEARANCE_VISIBILITY_SORT_ORDER;
/**
* A named preferences that controls if Java elements are also sorted by
@@ -227,7 +228,7 @@ public class PreferenceConstants {
* </p>
* @since 3.0
*/
- public static final String APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER= "org.eclipse.jdt.ui.enable.visibility.order"; //$NON-NLS-1$
+ public static final String APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER= MembersOrderPreferenceCacheCommon.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER;
/**
* A named preference that controls category rendering of Java elements in the UI.

Back to the top