Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add threshold for organizing imports with the asterisk (*) wildcard character #1407

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

snjeza
Copy link
Contributor

@snjeza snjeza commented Apr 9, 2020

@fbricon
Copy link
Contributor

fbricon commented Apr 14, 2020

Tested on vscode-java, setting

"java.import.ondemandthreshold": 2,
"java.import.staticondemandthreshold": 2,

No star imports are added with:

package test1;

import static java.lang.Math.abs;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class E {
    
    List<String> list = new ArrayList<>();
    Map<String, String> map = new HashMap<String, String>();
    public static void main(String[] args) {
        double d1 = sqrt(4);
        double d2 = pow(d1, abs(2));
        System.err.println(d2);
    }
}

Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefs names need to be changed, but more importantly, feature should work. It just doesn't right now.

@fbricon
Copy link
Contributor

fbricon commented Apr 14, 2020

Also https://github.com/eclipse/eclipse.jdt.ls/blob/1cc049e2d19bba5e31f94032c4851fd0a5840bea/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/TypeProposalUtils.java#L166-L169

needs to be replaced with:

Preferences preferences = JavaLanguageServerPlugin.getPreferencesManager() == null ? new Preferences() : JavaLanguageServerPlugin.getPreferencesManager().getPreferences();
rewrite.setImportOrder(preferences.getImportOrder());
rewrite.setOnDemandImportThreshold(preferences.getImportOnDemandThreshold());
rewrite.setStaticOnDemandImportThreshold(preferences.getStaticImportOnDemandThreshold());

(IMPORTS_THRESHOLD can be removed)

Which will need new tests for checking completion generates star imports.

@fbricon
Copy link
Contributor

fbricon commented Apr 14, 2020

test this please

@snjeza
Copy link
Contributor Author

snjeza commented Apr 14, 2020

@fbricon I have updated the PR.

@snjeza
Copy link
Contributor Author

snjeza commented Apr 14, 2020

test this please

1 similar comment
@snjeza
Copy link
Contributor Author

snjeza commented Apr 14, 2020

test this please

@snjeza
Copy link
Contributor Author

snjeza commented Apr 14, 2020

@fbricon I have updated the PR.

@fbricon fbricon merged commit a60afc0 into eclipse-jdtls:master Apr 15, 2020
@fbricon
Copy link
Contributor

fbricon commented Apr 15, 2020

Thanks @snjeza!

@fbricon fbricon changed the title organize imports with the asterisk (*) wildcard character add threshold for organizing imports with the asterisk (*) wildcard character Apr 15, 2020
@fbricon fbricon added this to the Mid April 2020 milestone Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants