• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DaemonCodeAnalyzerImpl类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl的典型用法代码示例。如果您正苦于以下问题:Java DaemonCodeAnalyzerImpl类的具体用法?Java DaemonCodeAnalyzerImpl怎么用?Java DaemonCodeAnalyzerImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DaemonCodeAnalyzerImpl类属于com.intellij.codeInsight.daemon.impl包,在下文中一共展示了DaemonCodeAnalyzerImpl类的34个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getScopeAttributes

点赞 3

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private static TextAttributes getScopeAttributes(@NotNull PsiElement element, @NotNull TextAttributesScheme colorsScheme) {
  PsiFile file = element.getContainingFile();
  if (file == null) return null;
  TextAttributes result = null;
  final DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(file.getProject());
  List<Pair<NamedScope,NamedScopesHolder>> scopes = daemonCodeAnalyzer.getScopeBasedHighlightingCachedScopes();
  for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
    NamedScope namedScope = scope.getFirst();
    NamedScopesHolder scopesHolder = scope.getSecond();
    PackageSet packageSet = namedScope.getValue();
    if (packageSet != null && packageSet.contains(file, scopesHolder)) {
      TextAttributesKey scopeKey = ColorAndFontOptions.getScopeTextAttributeKey(namedScope.getName());
      TextAttributes attributes = colorsScheme.getAttributes(scopeKey);
      if (attributes == null || attributes.isEmpty()) {
        continue;
      }
      result = TextAttributes.merge(attributes, result);
    }
  }
  return result;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:22,
代码来源:HighlightNamesUtil.java

示例2: hasErrorsInArgumentList

点赞 3

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
static boolean hasErrorsInArgumentList(final PsiMethodCallExpression call) {
  Project project = call.getProject();
  Document document = PsiDocumentManager.getInstance(project).getDocument(call.getContainingFile());
  if (document == null) return true;

  PsiExpressionList argumentList = call.getArgumentList();
  final TextRange argRange = argumentList.getTextRange();
  return !DaemonCodeAnalyzerImpl.processHighlights(document, project, HighlightSeverity.ERROR,
                                                   //strictly inside arg list
                                                   argRange.getStartOffset()+1,
                                                   argRange.getEndOffset()-1, new Processor<HighlightInfo>() {
      @Override
      public boolean process(HighlightInfo info) {
        return !(info.getActualStartOffset() > argRange.getStartOffset() && info.getActualEndOffset() < argRange.getEndOffset());
      }
    });
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:18,
代码来源:CreateMethodFromUsageFix.java

示例3: testDetectWrongEncoding

点赞 3

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
public void testDetectWrongEncoding() throws Exception {
  configureFromFileText("Win1251.txt", THREE_NOTORIOUS_RUSSIAN_LETTERS);
  VirtualFile virtualFile = getFile().getVirtualFile();
  assertEquals(CharsetToolkit.UTF8_CHARSET, virtualFile.getCharset());
  Charset WINDOWS_1251 = Charset.forName("windows-1251");
  virtualFile.setCharset(WINDOWS_1251);
  FileDocumentManager.getInstance().saveAllDocuments();
  assertEquals(WINDOWS_1251, virtualFile.getCharset());
  assertEquals(THREE_NOTORIOUS_RUSSIAN_LETTERS, new String(virtualFile.contentsToByteArray(), WINDOWS_1251));
  virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);

  doHighlighting();
  List<HighlightInfo> infos = DaemonCodeAnalyzerImpl.getFileLevelHighlights(getProject(), getFile());
  HighlightInfo info = assertOneElement(infos);
  assertEquals("File was loaded in the wrong encoding: 'UTF-8'", info.getDescription());
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:17,
代码来源:LossyEncodingTest.java

示例4: testAutoImportWorks

点赞 3

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
public void testAutoImportWorks() throws Throwable {
  @NonNls final String text = "class S { JFrame x; <caret> }";
  configureByText(StdFileTypes.JAVA, text);
  ((UndoManagerImpl)UndoManager.getInstance(getProject())).flushCurrentCommandMerger();
  ((UndoManagerImpl)UndoManager.getInstance(getProject())).clearUndoRedoQueueInTests(getFile().getVirtualFile());
  assertFalse(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile()));


  doHighlighting();
  assertFalse(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile()));

  type(" ");
  assertTrue(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile()));

  undo();

  assertFalse(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile()));//CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:19,
代码来源:ImportHelperTest.java

示例5: setUp

点赞 3

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();

  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      try {
        myProjectFixture.setUp();
        myTempDirFixture.setUp();
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
      myPsiManager = (PsiManagerImpl)PsiManager.getInstance(getProject());
      configureInspections(myInspections == null ? LocalInspectionTool.EMPTY_ARRAY : myInspections);

      DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
      daemonCodeAnalyzer.prepareForTest();

      DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
      ensureIndexesUpToDate(getProject());
      ((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runPostStartupActivities();
    }
  });
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:27,
代码来源:CodeInsightTestFixtureImpl.java

示例6: getAvailableActions

点赞 3

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
/**
 * Is invoked inside atomic action.
 */
@NotNull
public static List<HighlightInfo.IntentionActionDescriptor> getAvailableActions(@NotNull final Editor editor, @NotNull final PsiFile file, final int passId) {
  final int offset = editor.getCaretModel().getOffset();
  final Project project = file.getProject();

  final List<HighlightInfo.IntentionActionDescriptor> result = new ArrayList<HighlightInfo.IntentionActionDescriptor>();
  DaemonCodeAnalyzerImpl.processHighlightsNearOffset(editor.getDocument(), project, HighlightSeverity.INFORMATION, offset, true, new Processor<HighlightInfo>() {
    @Override
    public boolean process(HighlightInfo info) {
      addAvailableActionsForGroups(info, editor, file, result, passId, offset);
      return true;
    }
  });
  return result;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:19,
代码来源:QuickFixAction.java

示例7: setUp

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();

  final LocalInspectionTool[] tools = configureLocalInspectionTools();

  CodeInsightTestFixtureImpl.configureInspections(tools, getProject(), Collections.<String>emptyList(),
                                                  getTestRootDisposable());

  DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
  daemonCodeAnalyzer.prepareForTest();
  final StartupManagerImpl startupManager = (StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject());
  startupManager.runStartupActivities();
  startupManager.startCacheUpdate();
  startupManager.runPostStartupActivities();
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);

  if (isPerformanceTest()) {
    IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
    PathManagerEx.getTestDataPath(); // to cache stuff
    ReferenceProvidersRegistry.getInstance(); // pre-load tons of classes
    InjectedLanguageManager.getInstance(getProject()); // zillion of Dom Sem classes
    LanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE); // pile of annotator classes loads
    LanguageAnnotators.INSTANCE.allForLanguage(StdLanguages.XML);
    ProblemHighlightFilter.EP_NAME.getExtensions();
    Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
    Extensions.getExtensions(XmlSchemaProvider.EP_NAME);
    Extensions.getExtensions(XmlFileNSInfoProvider.EP_NAME);
    Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
    Extensions.getExtensions(IndexPatternBuilder.EP_NAME);
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:33,
代码来源:DaemonAnalyzerTestCase.java

示例8: tearDown

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
  try {
    DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); // return default value to avoid unnecessary save
    final Project project = getProject();
    if (project != null) {
      ((StartupManagerImpl)StartupManager.getInstance(project)).checkCleared();
      ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project)).cleanupAfterTest();
    }
  }
  finally {
    super.tearDown();
  }
  //((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:16,
代码来源:DaemonAnalyzerTestCase.java

示例9: checkHighlighting

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@NotNull
protected Collection<HighlightInfo> checkHighlighting(@NotNull final ExpectedHighlightingData data) {
  data.init();
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  //to load text
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      TreeUtil.clearCaches((TreeElement)myFile.getNode());
    }
  });


  //to initialize caches
  if (!DumbService.isDumb(getProject())) {
    CacheManager.SERVICE.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
  }
  final JavaPsiFacadeEx facade = getJavaFacade();
  if (facade != null) {
    facade.setAssertOnFileLoadingFilter(myVirtualFileFilter, myTestRootDisposable); // check repository work
  }

  try {
    Collection<HighlightInfo> infos = doHighlighting();

    String text = myEditor.getDocument().getText();
    data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
    data.checkResult(infos, text);
    return infos;
  }
  finally {
    if (facade != null) {
      facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myTestRootDisposable);
    }
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:38,
代码来源:DaemonAnalyzerTestCase.java

示例10: doGetRelatedLineMarkers

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private List<LineMarkerInfo> doGetRelatedLineMarkers() {
  myFixture.doHighlighting();

  final List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(
    myFixture.getEditor().getDocument(), myFixture.getProject());
  final List<LineMarkerInfo> relatedMarkers = new ArrayList<LineMarkerInfo>();

  for (LineMarkerInfo marker : markers) {
    if (marker.getNavigationHandler() instanceof AndroidLineMarkerProvider.MyNavigationHandler) {
      relatedMarkers.add(marker);
    }
  }
  return relatedMarkers;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:15,
代码来源:AndroidGotoRelatedTest.java

示例11: doTest

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private void doTest(int count) {
  final Editor editor = myFixture.getEditor();
  final Project project = myFixture.getProject();

  myFixture.doHighlighting();

  final List<LineMarkerInfo> infoList = DaemonCodeAnalyzerImpl.getLineMarkers(editor.getDocument(), project);
  assertEquals(count, infoList.size());
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:GroovyLineMarkerTest.java

示例12: doHighlighting

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@NotNull
public List<HighlightInfo> doHighlighting(@NotNull PsiFile file, @NotNull Editor editor) {
  final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
  final TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
  final List<HighlightInfo> infos = codeAnalyzer.runPasses(file, editor.getDocument(), Lists.newArrayList(textEditor), new int[0], false, null);
  infos.addAll(DaemonCodeAnalyzerEx.getInstanceEx(myProject).getFileLevelHighlights(myProject, file));
  return infos;
}
 

开发者ID:pantsbuild,
项目名称:intellij-pants-plugin,
代码行数:9,
代码来源:PantsHighlightingIntegrationTest.java

示例13: tearDown

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
  ((StartupManagerImpl)StartupManager.getInstance(getProject())).checkCleared();
  ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest();
  super.tearDown();
  //((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:8,
代码来源:DaemonAnalyzerTestCase.java

示例14: checkHighlighting

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@NotNull
protected Collection<HighlightInfo> checkHighlighting(@NotNull final ExpectedHighlightingData data) {
  data.init();
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  //to load text
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      TreeUtil.clearCaches((TreeElement)myFile.getNode());
    }
  });


  //to initialize caches
  if (!DumbService.isDumb(getProject())) {
    CacheManager.SERVICE.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
  }
  final JavaPsiFacadeEx facade = getJavaFacade();
  if (facade != null) {
    facade.setAssertOnFileLoadingFilter(myFileTreeAccessFilter); // check repository work
  }

  Collection<HighlightInfo> infos = doHighlighting();

  if (facade != null) {
    facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
  }

  String text = myEditor.getDocument().getText();
  data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
  data.checkResult(infos, text);
  return infos;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:35,
代码来源:DaemonAnalyzerTestCase.java

示例15: doHighlighting

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@NotNull
protected List<HighlightInfo> doHighlighting() {
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  TIntArrayList toIgnore = new TIntArrayList();
  if (!doTestLineMarkers()) {
    toIgnore.add(Pass.UPDATE_OVERRIDEN_MARKERS);
    toIgnore.add(Pass.VISIBLE_LINE_MARKERS);
    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.POPUP_HINTS);
    toIgnore.add(Pass.POST_UPDATE_ALL);
    toIgnore.add(Pass.UPDATE_ALL);
    toIgnore.add(Pass.UPDATE_OVERRIDEN_MARKERS);
    toIgnore.add(Pass.VISIBLE_LINE_MARKERS);
  }

  boolean canChange = canChangeDocumentDuringHighlighting();
  List<HighlightInfo> infos = CodeInsightTestFixtureImpl.instantiateAndRun(getFile(), getEditor(), toIgnore.toNativeArray(), canChange);

  if (!canChange) {
    Document document = getDocument(getFile());
    ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).getFileStatusMap().assertAllDirtyScopesAreNull(document);
  }

  return infos;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:35,
代码来源:DaemonAnalyzerTestCase.java

示例16: instantiateAndRun

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的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);
  List<HighlightInfo> infos = codeAnalyzer.runPasses(file, editor.getDocument(), textEditor, toIgnore, canChangeDocument, null);
  infos.addAll(DaemonCodeAnalyzerImpl.getFileLevelHighlights(project, file));
  return infos;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:14,
代码来源:CodeInsightTestFixtureImpl.java

示例17: doGetAvailableIntentions

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private static List<IntentionAction> doGetAvailableIntentions(@NotNull Editor editor, @NotNull PsiFile file) {
  ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
  ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
  List<HighlightInfo.IntentionActionDescriptor> descriptors = new ArrayList<HighlightInfo.IntentionActionDescriptor>();
  descriptors.addAll(intentions.intentionsToShow);
  descriptors.addAll(intentions.errorFixesToShow);
  descriptors.addAll(intentions.inspectionFixesToShow);
  descriptors.addAll(intentions.guttersToShow);

  PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
  List<IntentionAction> result = new ArrayList<IntentionAction>();

  List<HighlightInfo> infos = DaemonCodeAnalyzerImpl.getFileLevelHighlights(file.getProject(), file);
  for (HighlightInfo info : infos) {
    for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> pair : info.quickFixActionRanges) {
      HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
      if (actionInGroup.getAction().isAvailable(file.getProject(), editor, file)) {
        descriptors.add(actionInGroup);
      }
    }
  }

  // add all intention options for simplicity
  for (HighlightInfo.IntentionActionDescriptor descriptor : descriptors) {
    result.add(descriptor.getAction());
    List<IntentionAction> options = descriptor.getOptions(element,editor);
    if (options != null) {
      for (IntentionAction option : options) {
        if (option.isAvailable(file.getProject(), editor, file)) {
          result.add(option);
        }
      }
    }
  }
  return result;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:37,
代码来源:CodeInsightTestFixtureImpl.java

示例18: invoke

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  }

  final LookupEx lookup = LookupManager.getActiveLookup(editor);
  if (lookup != null) {
    lookup.showElementActions();
    return;
  }

  if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction()) return;

  //intentions check isWritable before modification: if (!file.isWritable()) return;
  if (file instanceof PsiCodeFragment) return;

  TemplateState state = TemplateManagerImpl.getTemplateState(editor);
  if (state != null && !state.isFinished()) {
    return;
  }

  final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
  codeAnalyzer.autoImportReferenceAtCursor(editor, file); //let autoimport complete

  ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
  ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);

  if (!intentions.isEmpty()) {
    IntentionHintComponent.showIntentionHint(project, file, editor, intentions, true);
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:35,
代码来源:ShowIntentionActionsHandler.java

示例19: findCodeSmells

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@NotNull
private List<CodeSmellInfo> findCodeSmells(@NotNull PsiFile psiFile, final ProgressIndicator progress, @NotNull Document document) {
  final List<CodeSmellInfo> result = new ArrayList<CodeSmellInfo>();

  DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
  List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, progress);
  collectErrorsAndWarnings(infos, result, document);

  return result;

}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:12,
代码来源:CodeSmellDetectorImpl.java

示例20: applyInformationToEditor

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
public final void applyInformationToEditor() {
  if (!isValid()) return; // Document has changed.
  if (DumbService.getInstance(myProject).isDumb() && !(this instanceof DumbAware)) {
    Document document = getDocument();
    PsiFile file = document == null ? null : PsiDocumentManager.getInstance(myProject).getPsiFile(document);
    if (file != null) {
      ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap().markFileUpToDate(getDocument(), getId());
    }
    return;
  }
  doApplyInformationToEditor();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:14,
代码来源:TextEditorHighlightingPass.java

示例21: doTest

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private void doTest(int count) {
  final Editor editor = myFixture.getEditor();
  final Project project = myFixture.getProject();

  myFixture.doHighlighting();

  final List<LineMarkerInfo> infoList = DaemonCodeAnalyzerImpl.getLineMarkers(editor.getDocument(), project);
  assertNotNull(infoList);
  assertEquals(count, infoList.size());
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:11,
代码来源:GroovyLineMarkerTest.java

示例22: invoke

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@RequiredDispatchThread
@Override
public void invoke(@Nonnull final Project project, @Nonnull Editor editor, @Nonnull PsiFile file) {
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  }

  final LookupEx lookup = LookupManager.getActiveLookup(editor);
  if (lookup != null) {
    lookup.showElementActions();
    return;
  }

  final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
  letAutoImportComplete(editor, file, codeAnalyzer);

  ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
  ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
  IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
  if (hintComponent != null) {
    IntentionHintComponent.PopupUpdateResult result =
            hintComponent.isForEditor(editor) ? hintComponent.updateActions(intentions) : IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE;
    if (result == IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE) {
      hintComponent.hide();
    }
  }

  if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction()) return;

  //intentions check isWritable before modification: if (!file.isWritable()) return;

  TemplateState state = TemplateManagerImpl.getTemplateState(editor);
  if (state != null && !state.isFinished()) {
    return;
  }

  showIntentionHint(project, editor, file, intentions);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:41,
代码来源:ShowIntentionActionsHandler.java

示例23: tearDown

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception
{
	((StartupManagerImpl) StartupManager.getInstance(getProject())).checkCleared();
	((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest();
	super.tearDown();
	//((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:9,
代码来源:DaemonAnalyzerTestCase.java

示例24: checkHighlighting

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@NotNull
protected Collection<HighlightInfo> checkHighlighting(@NotNull final ExpectedHighlightingData data)
{
	data.init();
	PsiDocumentManager.getInstance(myProject).commitAllDocuments();

	//to load text
	ApplicationManager.getApplication().runWriteAction(new Runnable()
	{
		@Override
		public void run()
		{
			TreeUtil.clearCaches((TreeElement) myFile.getNode());
		}
	});


	//to initialize caches
	if(!DumbService.isDumb(getProject()))
	{
		CacheManager.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
	}
	final JavaPsiFacadeEx facade = getJavaFacade();
	if(facade != null)
	{
		facade.setAssertOnFileLoadingFilter(myFileTreeAccessFilter, null); // check repository work
	}

	Collection<HighlightInfo> infos = doHighlighting();

	if(facade != null)
	{
		facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, null);
	}

	String text = myEditor.getDocument().getText();
	data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
	data.checkResult(infos, text);
	return infos;
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:41,
代码来源:DaemonAnalyzerTestCase.java

示例25: setUp

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).prepareForTest();
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:7,
代码来源:LightDaemonAnalyzerTestCase.java

示例26: tearDown

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); // return default value to avoid unnecessary save
  ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest();
  super.tearDown();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:7,
代码来源:LightDaemonAnalyzerTestCase.java

示例27: isEnabledForFile

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private static boolean isEnabledForFile(Project project, Editor editor, PsiFile file) {
  DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
  HighlightInfo info =
    ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(editor.getDocument(), editor.getCaretModel().getOffset(), false);
  return info != null && info.getDescription() != null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:7,
代码来源:ShowErrorDescriptionAction.java

示例28: invoke

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  }

  final LookupEx lookup = LookupManager.getActiveLookup(editor);
  if (lookup != null) {
    lookup.showElementActions();
    return;
  }

  final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
  codeAnalyzer.autoImportReferenceAtCursor(editor, file); //let autoimport complete

  ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
  ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
  IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
  if (hintComponent != null) {
    IntentionHintComponent.PopupUpdateResult result = hintComponent.isForEditor(editor)
                                                      ? hintComponent.updateActions(intentions)
                                                      : IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE;
    if (result == IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE) {
      hintComponent.hide();
    }
  }

  if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction()) return;

  //intentions check isWritable before modification: if (!file.isWritable()) return;

  TemplateState state = TemplateManagerImpl.getTemplateState(editor);
  if (state != null && !state.isFinished()) {
    return;
  }

  if (!intentions.isEmpty()) {
    IntentionHintComponent.showIntentionHint(project, file, editor, intentions, true);
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:43,
代码来源:ShowIntentionActionsHandler.java

示例29: tearDown

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
  ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest();
  super.tearDown();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:6,
代码来源:LightDaemonAnalyzerTestCase.java

示例30: doFix

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
public Result doFix(@NotNull final Editor editor, boolean allowPopup, final boolean allowCaretNearRef) {
  List<PsiClass> classesToImport = getClassesToImport();
  if (classesToImport.isEmpty()) return Result.POPUP_NOT_SHOWN;

  try {
    String name = getQualifiedName(myElement);
    if (name != null) {
      Pattern pattern = Pattern.compile(DaemonCodeAnalyzerSettings.getInstance().NO_AUTO_IMPORT_PATTERN);
      Matcher matcher = pattern.matcher(name);
      if (matcher.matches()) {
        return Result.POPUP_NOT_SHOWN;
      }
    }
  }
  catch (PatternSyntaxException e) {
    //ignore
  }
  final PsiFile psiFile = myElement.getContainingFile();
  if (classesToImport.size() > 1) {
    reduceSuggestedClassesBasedOnDependencyRuleViolation(psiFile, classesToImport);
  }
  PsiClass[] classes = classesToImport.toArray(new PsiClass[classesToImport.size()]);
  final Project project = myElement.getProject();
  CodeInsightUtil.sortIdenticalShortNameClasses(classes, myRef);

  final QuestionAction action = createAddImportAction(classes, project, editor);

  DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);

  boolean canImportHere = true;

  if (classes.length == 1
      && (canImportHere = canImportHere(allowCaretNearRef, editor, psiFile, classes[0].getName()))
      && (JspPsiUtil.isInJspFile(psiFile) ?
          CodeInsightSettings.getInstance().JSP_ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY :
          CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY)
      && (ApplicationManager.getApplication().isUnitTestMode() || codeAnalyzer.canChangeFileSilently(psiFile))
      && !autoImportWillInsertUnexpectedCharacters(classes[0])
      && !LaterInvocator.isInModalContext()
    ) {
    CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
      @Override
      public void run() {
        action.execute();
      }
    });
    return Result.CLASS_AUTO_IMPORTED;
  }

  if (allowPopup && canImportHere) {
    String hintText = ShowAutoImportPass.getMessage(classes.length > 1, classes[0].getQualifiedName());
    if (!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) {
      HintManager.getInstance().showQuestionHint(editor, hintText, getStartOffset(myElement, myRef),
                                                 getEndOffset(myElement, myRef), action);
    }
    return Result.POPUP_SHOWN;
  }
  return Result.POPUP_NOT_SHOWN;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:60,
代码来源:ImportClassFixBase.java

示例31: runHighlightPasses

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Nonnull

public List<GwtHighlightInfo> runHighlightPasses(String fileUrl, final int offset) {
  final VirtualFile fileByUrl = VirtualFileManager.getInstance().findFileByUrl(fileUrl);
  if (fileByUrl != null) {
    if (fileByUrl.isDirectory() || fileByUrl.getFileType().isBinary()) {
      return Collections.emptyList();
    }
    IdentifierHighlighterPassFactory.ourTestingIdentifierHighlighting = true;
    return ApplicationManager.getApplication().runReadAction(new Computable<List<GwtHighlightInfo>>() {
      
      public List<GwtHighlightInfo> compute() {
        final List<GwtHighlightInfo> list = new ArrayList<GwtHighlightInfo>();
        final Project project = getProject();
        final PsiFile file = PsiManager.getInstance(project).findFile(fileByUrl);
        if (file == null) {
          return Collections.emptyList();
        }
        try {

          SwingUtilities.invokeAndWait(new Runnable() {
            
            public void run() {
              Editor editor = findEditor(project, fileByUrl, offset);
              DaemonCodeAnalyzerImpl analyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzerEx.getInstanceEx(project);
              TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
              List<HighlightInfo> highlightInfos =
                      analyzer.runPasses(file, PsiDocumentManager.getInstance(project).getDocument(file), Arrays.asList(textEditor), new int[0], false, null);

              for (HighlightInfo highlightInfo : highlightInfos) {
                TextAttributes textAttributes = highlightInfo.getTextAttributes(null, null);
                if (textAttributes == null) {
                  continue;
                }
                GwtHighlightInfo info = createHighlightInfo(textAttributes, new GwtTextRange(highlightInfo.getStartOffset(), highlightInfo.getEndOffset()),
                                                            highlightInfo.getSeverity().myVal);
                if (highlightInfo.getSeverity() != HighlightInfoType.ELEMENT_UNDER_CARET_SEVERITY) {
                  info.setTooltip(highlightInfo.getToolTip());
                }
                list.add(info);
              }
            }
          });
        }
        catch (Exception e) {
          e.printStackTrace();
        }

        return list;
      }
    });
  }
  return Collections.emptyList();
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:55,
代码来源:GwtTransportServiceImpl.java

示例32: letAutoImportComplete

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
private static void letAutoImportComplete(@Nonnull Editor editor, @Nonnull PsiFile file, DaemonCodeAnalyzerImpl codeAnalyzer) {
  CommandProcessor.getInstance().runUndoTransparentAction(() -> codeAnalyzer.autoImportReferenceAtCursor(editor, file));
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:4,
代码来源:ShowIntentionActionsHandler.java

示例33: setUp

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(LightPlatformTestCase.getProject())).prepareForTest();
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:7,
代码来源:LightDaemonAnalyzerTestCase.java

示例34: tearDown

点赞 2

import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
  ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(LightPlatformTestCase.getProject())).cleanupAfterTest();
  super.tearDown();
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:6,
代码来源:LightDaemonAnalyzerTestCase.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)