Search in sources :

Example 1 with PreferenceManager

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

the class JavaLanguageServerPlugin method start.

/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
@Override
public void start(BundleContext bundleContext) throws BackingStoreException {
    try {
        Platform.getBundle(ResourcesPlugin.PI_RESOURCES).start(Bundle.START_TRANSIENT);
    } catch (BundleException e) {
        logException(e.getMessage(), e);
    }
    try {
        redirectStandardStreams();
    } catch (FileNotFoundException e) {
        logException(e.getMessage(), e);
    }
    JavaLanguageServerPlugin.context = bundleContext;
    JavaLanguageServerPlugin.pluginInstance = this;
    // Set the ID to use for preference lookups
    JavaManipulation.setPreferenceNodeId(PLUGIN_ID);
    preferenceManager = new PreferenceManager();
    initializeJDTOptions();
    projectsManager = new ProjectsManager(preferenceManager);
    try {
        ResourcesPlugin.getWorkspace().addSaveParticipant(PLUGIN_ID, projectsManager);
    } catch (CoreException e) {
        logException(e.getMessage(), e);
    }
    contentProviderManager = new ContentProviderManager(preferenceManager);
    logInfo(getClass() + " is started");
    configureProxy();
}
Also used : ContentProviderManager(org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager) CoreException(org.eclipse.core.runtime.CoreException) FileNotFoundException(java.io.FileNotFoundException) BundleException(org.osgi.framework.BundleException) ProjectsManager(org.eclipse.jdt.ls.core.internal.managers.ProjectsManager) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager)

Example 2 with PreferenceManager

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

the class GradleProjectImporter method applies.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.ls.core.internal.managers.IProjectImporter#applies(org.eclipse.core.runtime.IProgressMonitor)
	 */
@Override
public boolean applies(IProgressMonitor monitor) throws CoreException {
    if (rootFolder == null) {
        return false;
    }
    PreferenceManager preferencesManager = JavaLanguageServerPlugin.getPreferencesManager();
    if (preferencesManager != null && !preferencesManager.getPreferences().isImportGradleEnabled()) {
        return false;
    }
    if (directories == null) {
        BasicFileDetector gradleDetector = new BasicFileDetector(rootFolder.toPath(), BUILD_GRADLE_DESCRIPTOR).includeNested(false).addExclusions(// default gradle build dir
        "**/build");
        directories = gradleDetector.scan(monitor);
    }
    return !directories.isEmpty();
}
Also used : PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager)

Example 3 with PreferenceManager

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

the class SaveActionHandlerTest method setup.

@Override
@Before
public void setup() throws Exception {
    importProjects("eclipse/hello");
    project = WorkspaceHelper.getProject("hello");
    preferenceManager = mock(PreferenceManager.class);
    Preferences preferences = mock(Preferences.class);
    when(preferences.isJavaSaveActionsOrganizeImportsEnabled()).thenReturn(Boolean.TRUE);
    when(preferenceManager.getPreferences()).thenReturn(preferences);
    monitor = mock(IProgressMonitor.class);
    when(monitor.isCanceled()).thenReturn(false);
    handler = new SaveActionHandler(preferenceManager);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) Before(org.junit.Before)

Example 4 with PreferenceManager

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

the class HoverHandlerTest method setup.

@Before
public void setup() throws Exception {
    importProjects("eclipse/hello");
    project = WorkspaceHelper.getProject("hello");
    IJavaProject javaProject = JavaCore.create(project);
    sourceFolder = javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder("src"));
    preferenceManager = mock(PreferenceManager.class);
    when(preferenceManager.getPreferences()).thenReturn(new Preferences());
    handler = new HoverHandler(preferenceManager);
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) Before(org.junit.Before)

Example 5 with PreferenceManager

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

the class NavigateToDefinitionHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    preferenceManager = mock(PreferenceManager.class);
    when(preferenceManager.getPreferences()).thenReturn(new Preferences());
    handler = new NavigateToDefinitionHandler(preferenceManager);
    importProjects("maven/salut");
    project = WorkspaceHelper.getProject("salut");
}
Also used : Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) Before(org.junit.Before)

Aggregations

PreferenceManager (org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager)10 Preferences (org.eclipse.jdt.ls.core.internal.preferences.Preferences)7 Before (org.junit.Before)7 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ContentProviderManager (org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager)1 ProjectsManager (org.eclipse.jdt.ls.core.internal.managers.ProjectsManager)1 MavenProjectInfo (org.eclipse.m2e.core.project.MavenProjectInfo)1 BundleException (org.osgi.framework.BundleException)1