本文整理汇总了Java中com.intellij.codeInsight.daemon.DaemonCodeAnalyzer.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DaemonCodeAnalyzer.getInstance方法的具体用法?Java DaemonCodeAnalyzer.getInstance怎么用?Java DaemonCodeAnalyzer.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
的用法示例。
在下文中一共展示了DaemonCodeAnalyzer.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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");
}
}
示例4: 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);
}
示例5: updateContext
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
void updateContext(Collection<Namespace> namespaces, Collection<Variable> variables) {
final HistoryElement selectedItem = myModel.getSelectedItem();
final HistoryElement newElement;
if (selectedItem != null) {
newElement = selectedItem.changeContext(namespaces, variables);
} else {
newElement = new HistoryElement(myDocument.getText(), variables, namespaces);
}
myModel.setSelectedItem(newElement);
// FIXME
if (myNamespaceCache == null) {
myContextProvider.getNamespaceContext().setMap(asMap(namespaces));
}
final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(myProject);
analyzer.restart(myXPathFile);
}
示例6: 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 instanceof StatusBarEx) {
StatusBarEx barEx = (StatusBarEx)statusBar;
if (!text.equals(barEx.getInfo())){
statusBar.setInfo(text, "updater");
}
}
}
示例7: instantiateAndRun
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@Nonnull
public static List<HighlightInfo> instantiateAndRun(@Nonnull PsiFile file, @Nonnull Editor editor, @Nonnull 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 < 100; i++) {
try {
List<HighlightInfo> infos = codeAnalyzer.runPasses(file, editor.getDocument(), Arrays.asList(textEditor), toIgnore, canChangeDocument, null);
infos.addAll(DaemonCodeAnalyzerEx.getInstanceEx(project).getFileLevelHighlights(project, file));
return infos;
}
catch (ProcessCanceledException e) {
exception = e;
}
}
// unable to highlight after 100 retries
throw exception;
}
示例8: processTerminated
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@Override
public void processTerminated(ProcessEvent event) {
if (m_bsbError != null) {
m_bucklescript.setError(m_fileProcessed, m_bsbError);
reset();
}
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(m_project);
codeAnalyzer.restart();
}
示例9: customize
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@Override
public void customize(@NotNull EditorEx editor) {
boolean apply = isEnabled();
if (!READY) {
return;
}
Project project = editor.getProject();
if (project == null) {
return;
}
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null) {
return;
}
Function<InspectionProfileWrapper, InspectionProfileWrapper> strategy = file.getUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY);
if (strategy == null) {
file.putUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY, strategy = new MyInspectionProfileStrategy());
}
if (!(strategy instanceof MyInspectionProfileStrategy)) {
return;
}
((MyInspectionProfileStrategy)strategy).setUseSpellCheck(apply);
if (apply) {
editor.putUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY, false);
}
// Update representation.
DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project);
if (analyzer != null) {
analyzer.restart(file);
}
}
示例10: findCodeSmells
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@NotNull
private List<CodeSmellInfo> findCodeSmells(@NotNull final VirtualFile file, @NotNull final ProgressIndicator progress) {
final List<CodeSmellInfo> result = Collections.synchronizedList(new ArrayList<CodeSmellInfo>());
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
final ProgressIndicator daemonIndicator = new DaemonProgressIndicator();
((ProgressIndicatorEx)progress).addStateDelegate(new AbstractProgressIndicatorExBase() {
@Override
public void cancel() {
super.cancel();
daemonIndicator.cancel();
}
});
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
DumbService.getInstance(myProject).runReadActionInSmartMode(new Runnable() {
@Override
public void run() {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (psiFile == null || document == null) {
return;
}
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator);
convertErrorsAndWarnings(infos, result, document);
}
});
}
}, daemonIndicator);
return result;
}
示例11: doCollectInformation
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@Override
public void doCollectInformation(@NotNull ProgressIndicator progress) {
if (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getContentComponent().hasFocus()) return;
TemplateState state = TemplateManagerImpl.getTemplateState(myEditor);
if (state != null && !state.isFinished()) return;
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
getIntentionActionsToShow();
updateActions(codeAnalyzer);
}
示例12: showMessageWhenNoHighlights
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
static void showMessageWhenNoHighlights(Project project, PsiFile file, Editor editor) {
DaemonCodeAnalyzerImpl codeHighlighter = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
String message = codeHighlighter.isErrorAnalyzingFinished(file)
? InspectionsBundle.message("no.errors.found.in.this.file")
: InspectionsBundle.message("error.analysis.is.in.progress");
HintManager.getInstance().showInformationHint(editor, message);
}
示例13: invoke
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
int offset = editor.getCaretModel().getOffset();
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
HighlightInfo info = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(editor.getDocument(), offset, false);
if (info != null) {
DaemonTooltipUtil.showInfoTooltip(info, editor, editor.getCaretModel().getOffset(), myWidth);
}
}
示例14: actionPerformed
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e){
PsiFile psiFile=getTargetFile(e.getDataContext());
LOG.assertTrue(psiFile!=null);
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
LOG.assertTrue(project!=null);
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
codeAnalyzer.setImportHintsEnabled(psiFile,!codeAnalyzer.isImportHintsEnabled(psiFile));
DaemonListeners.getInstance(project).updateStatusBar();
}
示例15: doRehighlightMavenFile
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; //导入方法依赖的package包/类
private void doRehighlightMavenFile(VirtualFile file) {
Document doc = FileDocumentManager.getInstance().getCachedDocument(file);
if (doc == null) return;
PsiFile psi = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(doc);
if (psi == null) return;
if (!MavenDomUtil.isMavenFile(psi)) return;
DaemonCodeAnalyzer daemon = DaemonCodeAnalyzer.getInstance(myProject);
daemon.restart(psi);
}