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();
}
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;
}
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);
}
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;
}
Aggregations