Search in sources :

Example 1 with DaemonCodeAnalyzerEx

use of com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx in project Perl5-IDEA by Camelcade.

the class PerlUXPerformanceTest method testHighlighting.

public void testHighlighting() {
    initWithPerlTidy();
    final PsiFile file = getFile();
    final Editor editor = getEditor();
    final Project project = getProject();
    CodeInsightTestFixtureImpl.ensureIndexesUpToDate(project);
    final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project);
    final TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
    DaemonCodeAnalyzerEx codeAnalyzerEx = DaemonCodeAnalyzerEx.getInstanceEx(project);
    final int iterations = 30;
    for (int i = 0; i < iterations; i++) {
        codeAnalyzer.restart();
        ((PsiModificationTrackerImpl) getPsiManager().getModificationTracker()).incCounter();
        codeAnalyzer.runPasses(file, editor.getDocument(), Collections.singletonList(textEditor), ArrayUtil.EMPTY_INT_ARRAY, false, null);
        codeAnalyzerEx.getFileLevelHighlights(project, file);
    }
    final int time = 1100;
    PlatformTestUtil.startPerformanceTest("PerlTidy highlighting", iterations * time, () -> {
        long start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            codeAnalyzer.restart();
            ((PsiModificationTrackerImpl) getPsiManager().getModificationTracker()).incCounter();
            codeAnalyzer.runPasses(file, editor.getDocument(), Collections.singletonList(textEditor), ArrayUtil.EMPTY_INT_ARRAY, false, null);
            DaemonCodeAnalyzerEx.getInstanceEx(project).getFileLevelHighlights(project, file);
        }
        long length = System.currentTimeMillis() - start;
        System.err.println("Highlighting done in " + length / iterations + " ms per iteration of " + time);
    }).assertTiming();
}
Also used : Project(com.intellij.openapi.project.Project) TextEditor(com.intellij.openapi.fileEditor.TextEditor) PsiModificationTrackerImpl(com.intellij.psi.impl.PsiModificationTrackerImpl) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl) PsiFile(com.intellij.psi.PsiFile) DaemonCodeAnalyzerEx(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx) Editor(com.intellij.openapi.editor.Editor) TextEditor(com.intellij.openapi.fileEditor.TextEditor)

Example 2 with DaemonCodeAnalyzerEx

use of com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx in project intellij-community by JetBrains.

the class FileFixture method isOpenAndSelected.

private boolean isOpenAndSelected() {
    FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
    FileEditor selectedEditor = editorManager.getSelectedEditor(myVirtualFile);
    if (selectedEditor != null) {
        JComponent component = selectedEditor.getComponent();
        if (component.isVisible() && component.isShowing()) {
            Document document = FileDocumentManager.getInstance().getDocument(myVirtualFile);
            if (document != null) {
                PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
                if (psiFile != null) {
                    DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
                    //noinspection ConstantConditions
                    boolean isRunning = method("isRunning").withReturnType(boolean.class).in(codeAnalyzer).invoke();
                    return !isRunning;
                }
            }
        }
    }
    return false;
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) PsiFile(com.intellij.psi.PsiFile) DaemonCodeAnalyzerEx(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx) Document(com.intellij.openapi.editor.Document)

Example 3 with DaemonCodeAnalyzerEx

use of com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx in project intellij-community by JetBrains.

the class QuickFixFactoryImpl method timeToOptimizeImports.

private static boolean timeToOptimizeImports(@NotNull PsiFile file) {
    if (!CodeInsightWorkspaceSettings.getInstance(file.getProject()).optimizeImportsOnTheFly)
        return false;
    DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(file.getProject());
    // dont optimize out imports in JSP since it can be included in other JSP
    if (!codeAnalyzer.isHighlightingAvailable(file) || !(file instanceof PsiJavaFile) || file instanceof ServerPageFile)
        return false;
    if (!codeAnalyzer.isErrorAnalyzingFinished(file))
        return false;
    boolean errors = containsErrorsPreventingOptimize(file);
    return !errors && DaemonListeners.canChangeFileSilently(file);
}
Also used : DaemonCodeAnalyzerEx(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx)

Example 4 with DaemonCodeAnalyzerEx

use of com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx in project intellij-community by JetBrains.

the class DaemonAnalyzerTestCase method doHighlighting.

@NotNull
protected List<HighlightInfo> doHighlighting() {
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    TIntArrayList toIgnore = new TIntArrayList();
    if (!doTestLineMarkers()) {
        toIgnore.add(Pass.LINE_MARKERS);
    }
    if (!doExternalValidation()) {
        toIgnore.add(Pass.EXTERNAL_TOOLS);
    }
    if (forceExternalValidation()) {
        toIgnore.add(Pass.LINE_MARKERS);
        toIgnore.add(Pass.LOCAL_INSPECTIONS);
        toIgnore.add(Pass.WHOLE_FILE_LOCAL_INSPECTIONS);
        toIgnore.add(Pass.POPUP_HINTS);
        toIgnore.add(Pass.UPDATE_ALL);
    }
    boolean canChange = canChangeDocumentDuringHighlighting();
    List<HighlightInfo> infos = CodeInsightTestFixtureImpl.instantiateAndRun(getFile(), getEditor(), toIgnore.toNativeArray(), canChange);
    if (!canChange) {
        Document document = getDocument(getFile());
        DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
        daemonCodeAnalyzer.getFileStatusMap().assertAllDirtyScopesAreNull(document);
    }
    return infos;
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) DaemonCodeAnalyzerEx(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx) Document(com.intellij.openapi.editor.Document) TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DaemonCodeAnalyzerEx (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx)4 Document (com.intellij.openapi.editor.Document)2 PsiFile (com.intellij.psi.PsiFile)2 DaemonCodeAnalyzerImpl (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)1 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 Editor (com.intellij.openapi.editor.Editor)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 Project (com.intellij.openapi.project.Project)1 PsiModificationTrackerImpl (com.intellij.psi.impl.PsiModificationTrackerImpl)1 TIntArrayList (gnu.trove.TIntArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1