本文整理汇总了Java中com.intellij.codeInsight.daemon.DaemonCodeAnalyzer类的典型用法代码示例。如果您正苦于以下问题:Java DaemonCodeAnalyzer类的具体用法?Java DaemonCodeAnalyzer怎么用?Java DaemonCodeAnalyzer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DaemonCodeAnalyzer类属于com.intellij.codeInsight.daemon包,在下文中一共展示了DaemonCodeAnalyzer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureAnnotations
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@Override
public void configureAnnotations() {
final List<String> list = new ArrayList<String>(ADDITIONAL_ANNOTATIONS);
final JPanel listPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(list, "Do not check if annotated by", true);
new DialogWrapper(myProject) {
{
init();
setTitle("Configure Annotations");
}
@Override
protected JComponent createCenterPanel() {
return listPanel;
}
@Override
protected void doOKAction() {
ADDITIONAL_ANNOTATIONS.clear();
ADDITIONAL_ANNOTATIONS.addAll(list);
DaemonCodeAnalyzer.getInstance(myProject).restart();
super.doOKAction();
}
}.show();
}
示例2: getPasses
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@NotNull
List<TextEditorHighlightingPass> getPasses(@NotNull int[] passesToIgnore) {
if (myProject.isDisposed()) return Collections.emptyList();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
renewFile();
if (myFile == null) return Collections.emptyList();
if (myCompiled) {
passesToIgnore = EXCEPT_OVERRIDDEN;
}
else if (!DaemonCodeAnalyzer.getInstance(myProject).isHighlightingAvailable(myFile)) {
return Collections.emptyList();
}
TextEditorHighlightingPassRegistrarEx passRegistrar = TextEditorHighlightingPassRegistrarEx.getInstanceEx(myProject);
return passRegistrar.instantiatePasses(myFile, myEditor, passesToIgnore);
}
示例3: cancelAndRestartDaemonLater
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
private static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress,
@NotNull final Project project) throws ProcessCanceledException {
progress.cancel();
JobScheduler.getScheduler().schedule(new Runnable() {
@Override
public void run() {
Application application = ApplicationManager.getApplication();
if (!project.isDisposed() && !application.isDisposed() && !application.isUnitTestMode()) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
DaemonCodeAnalyzer.getInstance(project).restart();
}
}, project.getDisposed());
}
}
}, RESTART_DAEMON_RANDOM.nextInt(100), TimeUnit.MILLISECONDS);
throw new ProcessCanceledException();
}
示例4: instantiateAndRun
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@NotNull
public static List<HighlightInfo> instantiateAndRun(@NotNull PsiFile file,
@NotNull Editor editor,
@NotNull int[] toIgnore,
boolean canChangeDocument) {
Project project = file.getProject();
ensureIndexesUpToDate(project);
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
ProcessCanceledException exception = null;
for (int i = 0; i < 1000; i++) {
try {
List<HighlightInfo> infos = codeAnalyzer.runPasses(file, editor.getDocument(), textEditor, toIgnore, canChangeDocument, null);
infos.addAll(DaemonCodeAnalyzerEx.getInstanceEx(project).getFileLevelHighlights(project, file));
return infos;
}
catch (ProcessCanceledException e) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
UIUtil.dispatchAllInvocationEvents();
exception = e;
}
}
// unable to highlight after 100 retries
throw exception;
}
示例5: setUp
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
TestRunnerUtil.replaceIdeEventQueueSafely();
EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
@Override
public void run() throws Throwable {
myProjectFixture.setUp();
myTempDirFixture.setUp();
VirtualFile tempDir = myTempDirFixture.getFile("");
PlatformTestCase.synchronizeTempDirVfs(tempDir);
myPsiManager = (PsiManagerImpl)PsiManager.getInstance(getProject());
configureInspections(LocalInspectionTool.EMPTY_ARRAY, getProject(), Collections.<String>emptyList(), getTestRootDisposable());
DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
daemonCodeAnalyzer.prepareForTest();
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
ensureIndexesUpToDate(getProject());
((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runPostStartupActivities();
}
});
}
示例6: doGetReferenceOrReferencedElement
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@Nullable
private PsiElement doGetReferenceOrReferencedElement(PsiFile file, Editor editor, int flags, int offset) {
PsiReference ref = findReference(editor, offset);
if (ref == null) return null;
final Language language = ref.getElement().getLanguage();
TargetElementEvaluator evaluator = targetElementEvaluator.forLanguage(language);
if (evaluator != null) {
final PsiElement element = evaluator.getElementByReference(ref, flags);
if (element != null) return element;
}
PsiManager manager = file.getManager();
PsiElement refElement = ref.resolve();
if (refElement == null) {
if (ApplicationManager.getApplication().isDispatchThread()) {
DaemonCodeAnalyzer.getInstance(manager.getProject()).updateVisibleHighlighters(editor);
}
return null;
}
else {
return refElement;
}
}
示例7: doApplyInformationToEditor
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@Override
public void doApplyInformationToEditor() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getContentComponent().hasFocus()) return;
// do not show intentions if caret is outside visible area
LogicalPosition caretPos = myEditor.getCaretModel().getLogicalPosition();
Rectangle visibleArea = myEditor.getScrollingModel().getVisibleArea();
Point xy = myEditor.logicalPositionToXY(caretPos);
if (!visibleArea.contains(xy)) return;
TemplateState state = TemplateManagerImpl.getTemplateState(myEditor);
if (myShowBulb && (state == null || state.isFinished()) && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(false)) {
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
codeAnalyzer.setLastIntentionHint(myProject, myFile, myEditor, myIntentionsInfo, myHasToRecreate);
}
}
示例8: setOrRefreshErrorStripeRenderer
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
static void setOrRefreshErrorStripeRenderer(@NotNull EditorMarkupModel editorMarkupModel,
@NotNull Project project,
@NotNull Document document,
PsiFile file) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!editorMarkupModel.isErrorStripeVisible() || !DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file)) {
return;
}
ErrorStripeRenderer renderer = editorMarkupModel.getErrorStripeRenderer();
if (renderer instanceof TrafficLightRenderer) {
TrafficLightRenderer tlr = (TrafficLightRenderer)renderer;
tlr.refresh();
((EditorMarkupModelImpl)editorMarkupModel).repaintVerticalScrollBar();
if (tlr.myFile == null || tlr.myFile.isValid()) return;
Disposer.dispose(tlr);
}
EditorImpl editor = (EditorImpl)editorMarkupModel.getEditor();
if (!editor.isDisposed()) {
renderer = new TrafficLightRenderer(project, document, file);
Disposer.register(editor.getDisposable(), (Disposable)renderer);
editorMarkupModel.setErrorStripeRenderer(renderer);
}
}
示例9: StatusBarUpdater
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
public StatusBarUpdater(Project project) {
myProject = project;
project.getMessageBus().connect(this).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@Override
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
updateLater();
}
});
project.getMessageBus().connect(this).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() {
@Override
public void daemonFinished() {
updateLater();
}
});
}
示例10: updateStatus
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
private void updateStatus() {
Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
if (editor == null || !editor.getContentComponent().hasFocus()){
return;
}
final Document document = editor.getDocument();
if (document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) return;
int offset = editor.getCaretModel().getOffset();
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
HighlightInfo info = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(document, offset, false, HighlightSeverity.WARNING);
String text = info != null && info.getDescription() != null ? info.getDescription() : "";
StatusBar statusBar = WindowManager.getInstance().getStatusBar(editor.getContentComponent(), myProject);
if (statusBar != null && !text.equals(statusBar.getInfo())) {
statusBar.setInfo(text, "updater");
}
}
示例11: apply
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
public void apply() {
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
codeInsightSettings.COMPLETION_CASE_SENSITIVE = getCaseSensitiveValue();
codeInsightSettings.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = myCbSelectByChars.isSelected();
codeInsightSettings.AUTOCOMPLETE_ON_CODE_COMPLETION = myCbOnCodeCompletion.isSelected();
codeInsightSettings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = myCbOnSmartTypeCompletion.isSelected();
codeInsightSettings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = myCbShowFullParameterSignatures.isSelected();
codeInsightSettings.AUTO_POPUP_PARAMETER_INFO = myCbParameterInfoPopup.isSelected();
codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP = myCbAutocompletion.isSelected();
codeInsightSettings.AUTO_POPUP_JAVADOC_INFO = myCbAutopopupJavaDoc.isSelected();
codeInsightSettings.PARAMETER_INFO_DELAY = getIntegerValue(myParameterInfoDelayField.getText(), 0);
codeInsightSettings.JAVADOC_INFO_DELAY = getIntegerValue(myAutopopupJavaDocField.getText(), 0);
UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = myCbSorting.isSelected();
final Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
if (project != null){
DaemonCodeAnalyzer.getInstance(project).settingsChanged();
}
}
示例12: getClickConsumer
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
@Override
public Consumer<MouseEvent> getClickConsumer() {
return new Consumer<MouseEvent>() {
@Override
public void consume(final MouseEvent e) {
Point point = new Point(0, 0);
final PsiFile file = getCurrentFile();
if (file != null) {
if (!DaemonCodeAnalyzer.getInstance(file.getProject()).isHighlightingAvailable(file)) return;
final HectorComponent component = new HectorComponent(file);
final Dimension dimension = component.getPreferredSize();
point = new Point(point.x - dimension.width, point.y - dimension.height);
component.showComponent(new RelativePoint(e.getComponent(), point));
}
}
};
}
示例13: reparseFiles
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
public void reparseFiles(final List<String> extensions) {
final List<VirtualFile> filesToReparse = Lists.newArrayList();
ProjectRootManager.getInstance(myProject).getFileIndex().iterateContent(new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
if (!fileOrDir.isDirectory() && extensions.contains(fileOrDir.getExtension())) {
filesToReparse.add(fileOrDir);
}
return true;
}
});
FileContentUtilCore.reparseFiles(filesToReparse);
PyUtil.rehighlightOpenEditors(myProject);
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
示例14: createUIComponents
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
private void createUIComponents() {
final EditorTextField editorTextField = new LanguageTextField(PlainTextLanguage.INSTANCE, myProject, "") {
@Override
protected EditorEx createEditor() {
final EditorEx editor = super.createEditor();
final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
if (file != null) {
DaemonCodeAnalyzer.getInstance(myProject).setHighlightingEnabled(file, false);
}
editor.putUserData(ACTIVITY_CLASS_TEXT_FIELD_KEY, ApplicationRunParameters.this);
return editor;
}
};
myActivityField = new ComponentWithBrowseButton<EditorTextField>(editorTextField, null);
}
示例15: timeToOptimizeImports
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入依赖的package包/类
private boolean timeToOptimizeImports(GroovyFile myFile, Editor editor) {
if (!CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false;
if (onTheFly && editor != null) {
// if we stand inside import statements, do not optimize
final VirtualFile vfile = myFile.getVirtualFile();
if (vfile != null && ProjectRootManager.getInstance(myFile.getProject()).getFileIndex().isInSource(vfile)) {
final GrImportStatement[] imports = myFile.getImportStatements();
if (imports.length > 0) {
final int offset = editor.getCaretModel().getOffset();
if (imports[0].getTextRange().getStartOffset() <= offset && offset <= imports[imports.length - 1].getTextRange().getEndOffset()) {
return false;
}
}
}
}
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myFile.getProject());
if (!codeAnalyzer.isHighlightingAvailable(myFile)) return false;
if (!codeAnalyzer.isErrorAnalyzingFinished(myFile)) return false;
Document myDocument = PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
boolean errors = containsErrorsPreventingOptimize(myFile, myDocument);
return !errors && DaemonListeners.canChangeFileSilently(myFile);
}