Search in sources :

Example 16 with Preferences

use of org.eclipse.jdt.ls.core.internal.preferences.Preferences in project eclipse.jdt.ls by eclipse.

the class JDTLanguageServer method didChangeConfiguration.

/* (non-Javadoc)
	 * @see org.eclipse.lsp4j.services.WorkspaceService#didChangeConfiguration(org.eclipse.lsp4j.DidChangeConfigurationParams)
	 */
@Override
public void didChangeConfiguration(DidChangeConfigurationParams params) {
    logInfo(">> workspace/didChangeConfiguration");
    Object settings = JSONUtility.toModel(params.getSettings(), Map.class);
    if (settings instanceof Map) {
        @SuppressWarnings("unchecked") Preferences prefs = Preferences.createFrom((Map<String, Object>) settings);
        preferenceManager.update(prefs);
    }
    syncCapabilitiesToSettings();
    boolean jvmChanged = false;
    try {
        jvmChanged = configureVM();
    } catch (Exception e) {
        JavaLanguageServerPlugin.logException(e.getMessage(), e);
    }
    try {
        boolean autoBuildChanged = pm.setAutoBuilding(preferenceManager.getPreferences().isAutobuildEnabled());
        if (jvmChanged) {
            buildWorkspace(true);
        } else if (autoBuildChanged) {
            buildWorkspace(false);
        }
    } catch (CoreException e) {
        JavaLanguageServerPlugin.logException(e.getMessage(), e);
    }
    pm.registerWatchers();
    logInfo(">>New configuration: " + settings);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) Map(java.util.Map) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) JavaLanguageServerPlugin.logException(org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logException)

Example 17 with Preferences

use of org.eclipse.jdt.ls.core.internal.preferences.Preferences in project eclipse.jdt.ls by eclipse.

the class ImportOrganizeTest method setOrganizeImportSettings.

protected void setOrganizeImportSettings(String[] order) {
    Preferences prefs = JavaLanguageServerPlugin.getPreferencesManager().getPreferences();
    List<String> importOrder = new ArrayList<>();
    if (order != null) {
        importOrder.addAll(Arrays.asList(order));
    }
    prefs.setImportOrder(importOrder);
}
Also used : ArrayList(java.util.ArrayList) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences)

Aggregations

Preferences (org.eclipse.jdt.ls.core.internal.preferences.Preferences)17 Before (org.junit.Before)8 PreferenceManager (org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager)7 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)5 Test (org.junit.Test)5 CodeLens (org.eclipse.lsp4j.CodeLens)4 CodeLensParams (org.eclipse.lsp4j.CodeLensParams)4 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 ClientPreferences (org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)2 URI (java.net.URI)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IBuffer (org.eclipse.jdt.core.IBuffer)1