Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 238395 Details for
Bug 424172
[1.8][organize imports] Unused static import for Character::isUpperCase added
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch + Test
Fixed-bug-424172-1.8-organize-imports-Unused-static-import.patch (text/plain), 8.89 KB, created by
Noopur Gupta
on 2013-12-17 05:38:01 EST
(
hide
)
Description:
Patch + Test
Filename:
MIME Type:
Creator:
Noopur Gupta
Created:
2013-12-17 05:38:01 EST
Size:
8.89 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java >index ac1f98d..d07928f 100644 >--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java >+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >@@ -76,7 +80,7 @@ > JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); > } > >- private IChooseImportQuery createQuery(final String name, final String[] choices, final int[] nEntries) { >+ static IChooseImportQuery createQuery(final String name, final String[] choices, final int[] nEntries) { > return new IChooseImportQuery() { > public TypeNameMatch[] chooseImports(TypeNameMatch[][] openChoices, ISourceRange[] ranges) { > assertTrue(name + "-query-nchoices1", choices.length == openChoices.length); >@@ -3209,12 +3213,12 @@ > } > > >- private OrganizeImportsOperation createOperation(ICompilationUnit cu, String[] order, int threshold, boolean ignoreLowerCaseNames, boolean save, boolean allowSyntaxErrors, IChooseImportQuery chooseImportQuery) { >+ static OrganizeImportsOperation createOperation(ICompilationUnit cu, String[] order, int threshold, boolean ignoreLowerCaseNames, boolean save, boolean allowSyntaxErrors, IChooseImportQuery chooseImportQuery) { > setOrganizeImportSettings(order, threshold, threshold, cu.getJavaProject()); > return new OrganizeImportsOperation(cu, null, ignoreLowerCaseNames, save, allowSyntaxErrors, chooseImportQuery); > } > >- private void setOrganizeImportSettings(String[] order, int threshold, int staticThreshold, IJavaProject project) { >+ static void setOrganizeImportSettings(String[] order, int threshold, int staticThreshold, IJavaProject project) { > IEclipsePreferences scope= new ProjectScope(project.getProject()).getNode(JavaUI.ID_PLUGIN); > if (order == null) { > scope.remove(PreferenceConstants.ORGIMPORTS_IMPORTORDER); >diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest18.java >new file mode 100644 >index 0000000..6a53f56 >--- /dev/null >+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest18.java >@@ -0,0 +1,108 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2013 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 >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.ui.tests.core; >+ >+import java.util.Hashtable; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+import org.eclipse.jdt.testplugin.JavaProjectHelper; >+import org.eclipse.jdt.testplugin.TestOptions; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.IPackageFragmentRoot; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; >+ >+import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation; >+import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation.IChooseImportQuery; >+ >+ >+public class ImportOrganizeTest18 extends CoreTests { >+ >+ private static final Class THIS= ImportOrganizeTest18.class; >+ >+ private IJavaProject fJProject1; >+ >+ public ImportOrganizeTest18(String name) { >+ super(name); >+ } >+ >+ public static Test setUpTest(Test test) { >+ return new Java18ProjectTestSetup(test); >+ } >+ >+ public static Test suite() { >+ return setUpTest(new TestSuite(THIS)); >+ } >+ >+ >+ protected void setUp() throws Exception { >+ fJProject1= Java18ProjectTestSetup.getProject(); >+ >+ Hashtable options= TestOptions.getDefaultOptions(); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99)); >+ JavaCore.setOptions(options); >+ } >+ >+ >+ protected void tearDown() throws Exception { >+ ImportOrganizeTest.setOrganizeImportSettings(null, 99, 99, fJProject1); >+ JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath()); >+ } >+ >+ public void testStaticMethodReferenceImports_bug424172() throws Exception { >+ IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); >+ >+ IPackageFragment pack0= sourceFolder.createPackageFragment("p", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package p;\n"); >+ buf.append("\n"); >+ buf.append("import java.util.function.IntPredicate;\n"); >+ buf.append("\n"); >+ buf.append("class UnusedStaticImport {\n"); >+ buf.append(" boolean value = match(Character::isUpperCase, 'A');\n"); >+ buf.append("\n"); >+ buf.append(" public static boolean match(IntPredicate matcher, int codePoint) {\n"); >+ buf.append(" return matcher.test(codePoint);\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack0.createCompilationUnit("UnusedStaticImport.java", buf.toString(), false, null); >+ >+ String[] order= new String[] {}; >+ IChooseImportQuery query= ImportOrganizeTest.createQuery("StaticMethodReferenceImports_bug424172", new String[] {}, new int[] {}); >+ >+ OrganizeImportsOperation op= ImportOrganizeTest.createOperation(cu, order, 99, false, true, true, query); >+ op.run(null); >+ >+ buf= new StringBuffer(); >+ buf.append("package p;\n"); >+ buf.append("\n"); >+ buf.append("import java.util.function.IntPredicate;\n"); >+ buf.append("\n"); >+ buf.append("class UnusedStaticImport {\n"); >+ buf.append(" boolean value = match(Character::isUpperCase, 'A');\n"); >+ buf.append("\n"); >+ buf.append(" public static boolean match(IntPredicate matcher, int codePoint) {\n"); >+ buf.append(" return matcher.test(codePoint);\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(cu.getSource(), buf.toString()); >+ } >+ >+} >diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportReferencesCollector.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportReferencesCollector.java >index f2e78fc..9bb2455 100644 >--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportReferencesCollector.java >+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportReferencesCollector.java >@@ -24,6 +24,7 @@ > import org.eclipse.jdt.core.dom.ClassInstanceCreation; > import org.eclipse.jdt.core.dom.CompilationUnit; > import org.eclipse.jdt.core.dom.Expression; >+import org.eclipse.jdt.core.dom.ExpressionMethodReference; > import org.eclipse.jdt.core.dom.FieldAccess; > import org.eclipse.jdt.core.dom.IBinding; > import org.eclipse.jdt.core.dom.IMethodBinding; >@@ -46,10 +47,12 @@ > import org.eclipse.jdt.core.dom.SimpleName; > import org.eclipse.jdt.core.dom.SimpleType; > import org.eclipse.jdt.core.dom.SingleMemberAnnotation; >+import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; > import org.eclipse.jdt.core.dom.SuperConstructorInvocation; > import org.eclipse.jdt.core.dom.TagElement; > import org.eclipse.jdt.core.dom.ThisExpression; > import org.eclipse.jdt.core.dom.TypeDeclaration; >+import org.eclipse.jdt.core.dom.TypeMethodReference; > > import org.eclipse.jdt.internal.corext.dom.GenericVisitor; > import org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer; >@@ -162,6 +165,10 @@ > } > } > } else if (binding instanceof IMethodBinding) { >+ StructuralPropertyDescriptor locationInParent= simpleName.getLocationInParent(); >+ if (locationInParent == ExpressionMethodReference.NAME_PROPERTY || locationInParent == TypeMethodReference.NAME_PROPERTY) { >+ return; >+ } > IMethodBinding methodBinding= ((IMethodBinding) binding).getMethodDeclaration(); > ITypeBinding declaringClass= methodBinding.getDeclaringClass(); > if (declaringClass != null && !declaringClass.isLocal()) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 424172
:
238392
|
238395
|
238849