Search in sources :

Example 6 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-xtend by eclipse.

the class XtendQuickfixProvider method getResolutions.

@Override
public List<IssueResolution> getResolutions(Issue issue) {
    StopWatch stopWatch = new StopWatch(logger);
    try {
        if (LINKING_ISSUE_CODES.contains(issue.getCode())) {
            List<IssueResolution> result = new ArrayList<IssueResolution>();
            result.addAll(getResolutionsForLinkingIssue(issue));
            if (!result.isEmpty())
                return result;
        }
        return super.getResolutions(issue);
    } finally {
        stopWatch.resetAndLog("#getResolutions");
    }
}
Also used : IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) ArrayList(java.util.ArrayList) StopWatch(org.eclipse.xtext.util.StopWatch)

Example 7 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class ProfilerAbstractBuilderTest method testFullBuildBigProjectWithRefeernceToJar.

@Test
public void testFullBuildBigProjectWithRefeernceToJar() throws Exception {
    IJavaProject project = workspace.createJavaProject("foo");
    workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IFolder folder = project.getProject().getFolder("src");
    IFile jarFile = project.getProject().getFile("my.jar");
    jarFile.create(jarInputStream(new TextFile("my/element" + F_EXT, "object ReferenceMe")), true, workspace.monitor());
    workspace.addJarToClasspath(project, jarFile);
    int NUM_FILES = 2000;
    IFile[] files = new IFile[NUM_FILES];
    StopWatch timer = new StopWatch();
    for (int i = 0; i < NUM_FILES; i++) {
        IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
        files[i] = file;
        String contents = "object Foo" + i + " references ReferenceMe";
        file.create(new StringInputStream(contents), true, workspace.monitor());
    }
    logAndReset("Creating files", timer);
    workspace.build();
    logAndReset("Auto build", timer);
    IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
    for (IMarker iMarker : iMarkers) {
        System.out.println(iMarker.getAttribute(IMarker.MESSAGE));
    }
    assertEquals(0, iMarkers.length);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) IMarker(org.eclipse.core.resources.IMarker) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 8 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class ProfilerAbstractBuilderTest method testFullBuildBigProjectWithLinkingErrors.

@Test
public void testFullBuildBigProjectWithLinkingErrors() throws Exception {
    IJavaProject project = workspace.createJavaProject("foo");
    workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IFolder folder = project.getProject().getFolder("src");
    int NUM_FILES = 200;
    IFile[] files = new IFile[NUM_FILES];
    StopWatch timer = new StopWatch();
    for (int i = 0; i < NUM_FILES; i++) {
        IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
        files[i] = file;
        String contents = "object Foo" + i + " references Foo" + (i * 1000);
        if (i == NUM_FILES)
            contents = "object Foo" + i;
        file.create(new StringInputStream(contents), true, workspace.monitor());
    }
    logAndReset("Creating files", timer);
    workspace.build();
    logAndReset("Auto build", timer);
    IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
    assertEquals(NUM_FILES - 1, iMarkers.length);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IMarker(org.eclipse.core.resources.IMarker) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 9 with StopWatch

use of org.eclipse.xtext.util.StopWatch in project xtext-eclipse by eclipse.

the class DefaultQuickfixProvider method getResolutions.

@Override
public List<IssueResolution> getResolutions(Issue issue) {
    StopWatch stopWatch = new StopWatch(logger);
    try {
        if (Diagnostic.LINKING_DIAGNOSTIC.equals(issue.getCode())) {
            List<IssueResolution> result = new ArrayList<IssueResolution>();
            result.addAll(getResolutionsForLinkingIssue(issue));
            result.addAll(super.getResolutions(issue));
            return result;
        } else
            return super.getResolutions(issue);
    } finally {
        stopWatch.resetAndLog("#getResolutions");
    }
}
Also used : ArrayList(java.util.ArrayList) StopWatch(org.eclipse.xtext.util.StopWatch)

Aggregations

StopWatch (org.eclipse.xtext.util.StopWatch)9 StringInputStream (org.eclipse.xtext.util.StringInputStream)7 Test (org.junit.Test)7 IFile (org.eclipse.core.resources.IFile)6 IFolder (org.eclipse.core.resources.IFolder)6 IJavaProject (org.eclipse.jdt.core.IJavaProject)6 IMarker (org.eclipse.core.resources.IMarker)3 ArrayList (java.util.ArrayList)2 Injector (com.google.inject.Injector)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IndexTestLanguageStandaloneSetup (org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 Manager (org.eclipse.xtext.resource.IResourceDescription.Manager)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 IssueResolution (org.eclipse.xtext.ui.editor.quickfix.IssueResolution)1 TextFile (org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile)1