Search in sources :

Example 1 with ProgressReporterManager

use of org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager in project eclipse.jdt.ls by eclipse.

the class AbstractProjectsManagerBasedTest method initProjectManager.

@Before
public void initProjectManager() throws CoreException {
    clientRequests.clear();
    logListener = new SimpleLogListener();
    Platform.addLogListener(logListener);
    preferences = new Preferences();
    if (preferenceManager != null) {
        when(preferenceManager.getPreferences()).thenReturn(preferences);
        ClientPreferences clientPreferences = mock(ClientPreferences.class);
        when(clientPreferences.isProgressReportSupported()).thenReturn(true);
        when(preferenceManager.getClientPreferences()).thenReturn(clientPreferences);
    }
    projectsManager = new ProjectsManager(preferenceManager);
    ProgressReporterManager progressManager = new ProgressReporterManager(this.client, preferenceManager);
    // disable throttling to ensure we capture all events
    progressManager.setReportThrottle(0);
    Job.getJobManager().setProgressProvider(progressManager);
    monitor = progressManager.getDefaultMonitor();
    WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {

        @Override
        public IBuffer createBuffer(ICompilationUnit workingCopy) {
            ICompilationUnit original = workingCopy.getPrimary();
            IResource resource = original.getResource();
            if (resource instanceof IFile) {
                return new DocumentAdapter(workingCopy, (IFile) resource);
            }
            return DocumentAdapter.Null;
        }
    });
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) SimpleLogListener(org.eclipse.jdt.ls.core.internal.SimpleLogListener) ClientPreferences(org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences) IFile(org.eclipse.core.resources.IFile) WorkingCopyOwner(org.eclipse.jdt.core.WorkingCopyOwner) ProgressReporterManager(org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager) DocumentAdapter(org.eclipse.jdt.ls.core.internal.DocumentAdapter) ClientPreferences(org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) IBuffer(org.eclipse.jdt.core.IBuffer) IResource(org.eclipse.core.resources.IResource) Before(org.junit.Before)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IBuffer (org.eclipse.jdt.core.IBuffer)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 WorkingCopyOwner (org.eclipse.jdt.core.WorkingCopyOwner)1 DocumentAdapter (org.eclipse.jdt.ls.core.internal.DocumentAdapter)1 SimpleLogListener (org.eclipse.jdt.ls.core.internal.SimpleLogListener)1 ProgressReporterManager (org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager)1 ClientPreferences (org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)1 Preferences (org.eclipse.jdt.ls.core.internal.preferences.Preferences)1 Before (org.junit.Before)1