当前位置: 首页>>代码示例>>Java>>正文


Java IntentionManager类代码示例

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


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

示例1: assertIntentionIsAvailable

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
public void assertIntentionIsAvailable(LanguageFileType languageFileType, String configureByText, String intentionText) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    Set<String> items = new HashSet<>();

    for (IntentionAction intentionAction : IntentionManager.getInstance().getIntentionActions()) {
        if(!intentionAction.isAvailable(getProject(), getEditor(), psiElement.getContainingFile())) {
            continue;
        }

        String text = intentionAction.getText();
        items.add(text);

        if(!text.equals(intentionText)) {
            continue;
        }

        return;
    }

    fail(String.format("Fail intention action '%s' is available in element '%s' with '%s'", intentionText, psiElement.getText(), items));
}
 
开发者ID:Haehnchen,项目名称:idea-php-behat-plugin,代码行数:24,代码来源:BehatLightCodeInsightFixtureTestCase.java

示例2: registerFixesForUnusedParameter

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
@Override
public void registerFixesForUnusedParameter(@NotNull PsiParameter parameter, @NotNull Object highlightInfo) {
  Project myProject = parameter.getProject();
  InspectionProfile profile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
  UnusedParametersInspection unusedParametersInspection =
    (UnusedParametersInspection)profile.getUnwrappedTool(UnusedSymbolLocalInspectionBase.UNUSED_PARAMETERS_SHORT_NAME, parameter);
  LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || unusedParametersInspection != null);
  List<IntentionAction> options = new ArrayList<IntentionAction>();
  HighlightDisplayKey myUnusedSymbolKey = HighlightDisplayKey.find(UnusedSymbolLocalInspectionBase.SHORT_NAME);
  options.addAll(IntentionManager.getInstance().getStandardIntentionOptions(myUnusedSymbolKey, parameter));
  if (unusedParametersInspection != null) {
    SuppressQuickFix[] batchSuppressActions = unusedParametersInspection.getBatchSuppressActions(parameter);
    Collections.addAll(options, SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions));
  }
  //need suppress from Unused Parameters but settings from Unused Symbol
  QuickFixAction.registerQuickFixAction((HighlightInfo)highlightInfo, new SafeDeleteFix(parameter),
                                        options, HighlightDisplayKey.getDisplayNameByKey(myUnusedSymbolKey));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:QuickFixFactoryImpl.java

示例3: createActionGroupPopup

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
@Nullable
protected JBPopup createActionGroupPopup(PsiFile file, Project project, Editor editor) {
  final DefaultActionGroup group = new DefaultActionGroup();
  for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
    if (shouldShowInGutterPopup(action) && action.isAvailable(project, editor, file)) {
      group.add(new ApplyIntentionAction(action, action.getText(), editor, file));
    }
  }

  if (group.getChildrenCount() > 0) {
    final DataContext context = SimpleDataContext.getProjectContext(null);
    return JBPopupFactory.getInstance()
      .createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExternalAnnotationsLineMarkerProvider.java

示例4: registerFixesForUnusedParameter

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
@Override
public void registerFixesForUnusedParameter(@NotNull PsiParameter parameter, @NotNull Object highlightInfo)
{
	Project myProject = parameter.getProject();
	InspectionProfile profile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
	UnusedDeclarationInspectionBase unusedParametersInspection = (UnusedDeclarationInspectionBase) profile.getUnwrappedTool(UnusedSymbolLocalInspectionBase.SHORT_NAME, parameter);
	LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || unusedParametersInspection != null);
	List<IntentionAction> options = new ArrayList<>();
	HighlightDisplayKey myUnusedSymbolKey = HighlightDisplayKey.find(UnusedSymbolLocalInspectionBase.SHORT_NAME);
	options.addAll(IntentionManager.getInstance().getStandardIntentionOptions(myUnusedSymbolKey, parameter));
	if(unusedParametersInspection != null)
	{
		SuppressQuickFix[] batchSuppressActions = unusedParametersInspection.getBatchSuppressActions(parameter);
		Collections.addAll(options, SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions));
	}
	//need suppress from Unused Parameters but settings from Unused Symbol
	QuickFixAction.registerQuickFixAction((HighlightInfo) highlightInfo, new SafeDeleteFix(parameter), options, HighlightDisplayKey.getDisplayNameByKey(myUnusedSymbolKey));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:QuickFixFactoryImpl.java

示例5: createActionGroupPopup

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
@Nullable
protected JBPopup createActionGroupPopup(PsiFile file, Project project, Editor editor)
{
	final DefaultActionGroup group = new DefaultActionGroup();
	for(final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions())
	{
		if(shouldShowInGutterPopup(action) && action.isAvailable(project, editor, file))
		{
			group.add(new ApplyIntentionAction(action, action.getText(), editor, file));
		}
	}

	if(group.getChildrenCount() > 0)
	{
		final DataContext context = SimpleDataContext.getProjectContext(null);
		return JBPopupFactory.getInstance().createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
	}

	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:ExternalAnnotationsLineMarkerProvider.java

示例6: assertIntentionIsAvailable

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
public void assertIntentionIsAvailable(LanguageFileType languageFileType, String configureByText, String intentionText) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    for (IntentionAction intentionAction : IntentionManager.getInstance().getIntentionActions()) {
        if(intentionAction.isAvailable(getProject(), getEditor(), psiElement.getContainingFile()) && intentionAction.getText().equals(intentionText)) {
            return;
        }
    }

    fail(String.format("Fail intention action '%s' is available in element '%s'", intentionText, psiElement.getText()));
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:13,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例7: setUp

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的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: setUp

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

  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LanguageAnnotators.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LineMarkerProviders.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(JavaConcatenationInjectorManager.CONCATENATION_INJECTOR_EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME)));

  IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
  PathManagerEx.getTestDataPath(); // to cache stuff
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:LightAdvHighlightingPerformanceTest.java

示例9: customize

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:SpellCheckingEditorCustomization.java

示例10: reset

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
public void reset(){
  while (((IntentionManagerImpl)IntentionManager.getInstance()).hasActiveRequests()) {
    TimeoutUtil.sleep(100);
  }
  resetCheckStatus();    
  reset(IntentionManagerSettings.getInstance().getMetaData());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:IntentionSettingsTree.java

示例11: reset

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
public void reset(){
  while (((IntentionManagerImpl)IntentionManager.getInstance()).hasActiveRequests()) {
    try {
      Thread.sleep(100);
    }
    catch (InterruptedException ignored) {
    }
  }
  resetCheckStatus();    
  reset(IntentionManagerSettings.getInstance().getMetaData());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:IntentionSettingsTree.java

示例12: registerIntentionActions

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
/**
 * register intention actions for project
 */
private void registerIntentionActions() {
  IntentionManager manager = IntentionManager.getInstance();

  manager.registerIntentionAndMetaData(new GenerateResultsForResultMapAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateParametersForParameterMapAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateSQLForSelectAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateSQLForInsertAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateSQLForUpdateAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateSQLForDeleteAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateSQLForCrudAction(), "iBATIS");
  manager.registerIntentionAndMetaData(new GenerateStatementXmlCodeAction(), "iBATIS");
}
 
开发者ID:code4craft,项目名称:ibatis-plugin,代码行数:16,代码来源:IbatisProjectComponent.java

示例13: setUp

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

  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LanguageAnnotators.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LineMarkerProviders.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(JavaConcatenationInjectorManager.CONCATENATION_INJECTOR_EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(MultiHostInjector.EP_NAME)));

  IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:LightAdvHighlightingPerformanceTest.java

示例14: getActionsToShow

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
public static void getActionsToShow(@NotNull final Editor hostEditor,
                                    @NotNull final PsiFile hostFile,
                                    @NotNull final IntentionsInfo intentions,
                                    int passIdToShowIntentionsFor) {
  final PsiElement psiElement = hostFile.findElementAt(hostEditor.getCaretModel().getOffset());
  LOG.assertTrue(psiElement == null || psiElement.isValid(), psiElement);

  int offset = hostEditor.getCaretModel().getOffset();
  final Project project = hostFile.getProject();

  List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableActions(hostEditor, hostFile, passIdToShowIntentionsFor);
  final DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
  final Document hostDocument = hostEditor.getDocument();
  HighlightInfo infoAtCursor = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(hostDocument, offset, true);
  if (infoAtCursor == null) {
    intentions.errorFixesToShow.addAll(fixes);
  }
  else {
    final boolean isError = infoAtCursor.getSeverity() == HighlightSeverity.ERROR;
    for (HighlightInfo.IntentionActionDescriptor fix : fixes) {
      if (fix.isError() && isError) {
        intentions.errorFixesToShow.add(fix);
      }
      else {
        intentions.inspectionFixesToShow.add(fix);
      }
    }
  }

  for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
    Pair<PsiFile, Editor> place =
      ShowIntentionActionsHandler.chooseBetweenHostAndInjected(hostFile, hostEditor, new PairProcessor<PsiFile, Editor>() {
        @Override
        public boolean process(PsiFile psiFile, Editor editor) {
          return ShowIntentionActionsHandler.availableFor(psiFile, editor, action);
        }
      });

    if (place != null) {
      List<IntentionAction> enableDisableIntentionAction = new ArrayList<IntentionAction>();
      enableDisableIntentionAction.add(new IntentionHintComponent.EnableDisableIntentionAction(action));
      enableDisableIntentionAction.add(new IntentionHintComponent.EditIntentionSettingsAction(action));
      HighlightInfo.IntentionActionDescriptor descriptor = new HighlightInfo.IntentionActionDescriptor(action, enableDisableIntentionAction, null);
      if (!fixes.contains(descriptor)) {
        intentions.intentionsToShow.add(descriptor);
      }
    }
  }

  final int line = hostDocument.getLineNumber(offset);
  MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(hostDocument, project, true);
  CommonProcessors.CollectProcessor<RangeHighlighterEx> processor = new CommonProcessors.CollectProcessor<RangeHighlighterEx>();
  model.processRangeHighlightersOverlappingWith(hostDocument.getLineStartOffset(line),
                                                hostDocument.getLineEndOffset(line),
                                                processor);

  for (RangeHighlighterEx highlighter : processor.getResults()) {
    GutterIntentionAction.addActions(project, hostEditor, hostFile, highlighter, intentions.guttersToShow);
  }

  boolean cleanup = appendCleanupCode(intentions.inspectionFixesToShow, hostFile);
  if (!cleanup) {
    appendCleanupCode(intentions.errorFixesToShow, hostFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:66,代码来源:ShowIntentionsPass.java

示例15: getMetaData

import com.intellij.codeInsight.intention.IntentionManager; //导入依赖的package包/类
@NotNull
public synchronized List<IntentionActionMetaData> getMetaData() {
  IntentionManager.getInstance(); // TODO: Hack to make IntentionManager actually register metadata here. Dependencies between IntentionManager and IntentionManagerSettings should be revised.
  return new ArrayList<IntentionActionMetaData>(myMetaData.values());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:IntentionManagerSettings.java


注:本文中的com.intellij.codeInsight.intention.IntentionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。