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


Java ContainerUtil.findInstance方法代码示例

本文整理汇总了Java中com.intellij.util.containers.ContainerUtil.findInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtil.findInstance方法的具体用法?Java ContainerUtil.findInstance怎么用?Java ContainerUtil.findInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.ContainerUtil的用法示例。


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

示例1: methodCall

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public PsiMethodCallPattern methodCall(final ElementPattern<? extends PsiMethod> method) {
  final PsiNamePatternCondition nameCondition = ContainerUtil.findInstance(method.getCondition().getConditions(), PsiNamePatternCondition.class);
  return new PsiMethodCallPattern().and(this).with(new PatternCondition<PsiMethodCallExpression>("methodCall") {
    public boolean accepts(@NotNull PsiMethodCallExpression callExpression, ProcessingContext context) {
      PsiReferenceExpression methodExpression = callExpression.getMethodExpression();
      if (nameCondition != null && !nameCondition.getNamePattern().accepts(methodExpression.getReferenceName())) {
        return false;
      }

      for (JavaResolveResult result : methodExpression.multiResolve(true)) {
        if (method.accepts(result.getElement(), context)) {
          return true;
        }
      }
      return false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiExpressionPattern.java

示例2: doDynamicFix

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private GrReferenceExpression doDynamicFix() throws Throwable {
  myFixture.enableInspections(new GrUnresolvedAccessInspection());

  final List<IntentionAction> actions = myFixture.getAvailableIntentions(getTestName(false) + ".groovy");

  DynamicPropertyFix dynamicFix = ContainerUtil.findInstance(actions, DynamicPropertyFix.class);
  if (dynamicFix != null) {
    dynamicFix.invoke(getProject());
    return dynamicFix.getReferenceExpression();
  }
  else {
    final DynamicMethodFix fix = ContainerUtil.findInstance(actions, DynamicMethodFix.class);
    assertNotNull(fix);
    fix.invoke(getProject());
    return fix.getReferenceExpression();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DynamicTest.java

示例3: doAdd

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static void doAdd(CompletionParameters parameters, final CompletionResultSet result) {
  PsiElement position = parameters.getPosition();
  PsiReference[] references = ArrayUtil.mergeArrays(position.getReferences(), position.getParent().getReferences());
  PropertyReference propertyReference = ContainerUtil.findInstance(references, PropertyReference.class);
  if (propertyReference != null && !hasMoreImportantReference(references, propertyReference)) {
    final int startOffset = parameters.getOffset();
    PsiElement element = propertyReference.getElement();
    final int offsetInElement = startOffset - element.getTextRange().getStartOffset();
    TextRange range = propertyReference.getRangeInElement();
    if (offsetInElement >= range.getStartOffset()) {
      final String prefix = element.getText().substring(range.getStartOffset(), offsetInElement);

      LookupElement[] variants = getVariants(propertyReference);
      result.withPrefixMatcher(prefix).addAllElements(Arrays.asList(variants));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PropertiesCompletionContributor.java

示例4: apply

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
  if (!(psiElement instanceof PsiArrayInitializerExpression)) return;
  PsiArrayInitializerExpression expr = (PsiArrayInitializerExpression)psiElement;
  if (!expr.getText().endsWith("}")) {
    PsiErrorElement err = ContainerUtil.findInstance(expr.getChildren(), PsiErrorElement.class);
    int endOffset = (err != null ? err : expr).getTextRange().getEndOffset();
    editor.getDocument().insertString(endOffset, "}");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MissingArrayInitializerBraceFixer.java

示例5: testLiveTemplate

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public void testLiveTemplate() throws Throwable {
  final Template template = TemplateManager.getInstance(getProject()).createTemplate("foo", "zzz");
  template.addTextSegment("FooFactory.createFoo()");
  final SmartCompletionContextType completionContextType =
    ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
  ((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
  CodeInsightTestUtil.addTemplate(template, myTestRootDisposable);
  doTest();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SmartTypeCompletionTest.java

示例6: addTemplate

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void addTemplate(String key, String text, String description, String group) {
  TemplateManager manager = TemplateManager.getInstance(getProject());
  TemplateImpl template = (TemplateImpl)manager.createTemplate(key, group, text);
  template.setDescription(description);
  TemplateContextType contextType = ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JavaCodeContextType.class);
  template.getTemplateContext().setEnabled(contextType, true);
  CodeInsightTestUtil.addTemplate(template, getTestRootDisposable());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ListTemplateActionTest.java

示例7: getModuleSourceEntry

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
private ModuleSourceOrderEntry getModuleSourceEntry(@NotNull List<VirtualFile> hierarchy,
                                                    @NotNull VirtualFile moduleContentRoot,
                                                    @NotNull MultiMap<VirtualFile, OrderEntry> libClassRootEntries) {
  Module module = contentRootOf.get(moduleContentRoot);
  for (VirtualFile root : hierarchy) {
    if (sourceRootOf.get(root).contains(module)) {
      return ContainerUtil.findInstance(ModuleRootManager.getInstance(module).getOrderEntries(), ModuleSourceOrderEntry.class);
    }
    if (libClassRootEntries.containsKey(root)) {
      return null;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:RootIndex.java

示例8: getConsoleExecuteAction

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
public static ConsoleExecuteAction getConsoleExecuteAction(@Nullable ConsoleView consoleView) {
  if (!(consoleView instanceof LanguageConsoleView)) {
    return null;
  }

  List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView)consoleView).getConsoleEditor().getComponent());
  ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
  return action == null || !action.isEnabled() ? null : action;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:XEvaluateInConsoleFromEditorActionHandler.java

示例9: hasTemplatePrefix

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public static boolean hasTemplatePrefix(LookupImpl lookup, char shortcutChar) {
  lookup.refreshUi(false, false); // to bring the list model up to date

  CompletionProcess completion = CompletionService.getCompletionService().getCurrentCompletion();
  if (completion == null || !completion.isAutopopupCompletion()) {
    return false;
  }

  if (lookup.isSelectionTouched()) {
    return false;
  }

  final PsiFile file = lookup.getPsiFile();
  if (file == null) return false;

  final Editor editor = lookup.getEditor();
  final int offset = editor.getCaretModel().getOffset();
  PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());

  final LiveTemplateLookupElement liveTemplateLookup = ContainerUtil.findInstance(lookup.getItems(), LiveTemplateLookupElement.class);
  if (liveTemplateLookup == null || !liveTemplateLookup.sudden) {
    // Lookup doesn't contain sudden live templates. It means that 
    // - there are no live template with given key:
    //    in this case we should find live template with appropriate prefix (custom live templates doesn't participate in this action). 
    // - completion provider worked too long:
    //    in this case we should check custom templates that provides completion lookup.
    if (LiveTemplateCompletionContributor.customTemplateAvailableAndHasCompletionItem(shortcutChar, editor, file, offset)) {
      return true;
    }

    List<TemplateImpl> templates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(editor, file, false);
    TemplateImpl template = LiveTemplateCompletionContributor.findFullMatchedApplicableTemplate(editor, offset, templates);
    if (template != null && shortcutChar == TemplateSettings.getInstance().getShortcutChar(template)) {
      return true;
    }
    return false;
  }

  return liveTemplateLookup.getTemplateShortcut() == shortcutChar;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:ChooseItemAction.java

示例10: createJsonTemplate

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private Template createJsonTemplate(@NotNull String name, @NotNull String group, @NotNull String text) {
  final TemplateManager templateManager = TemplateManager.getInstance(getProject());
  final Template template = templateManager.createTemplate(name, group, text);

  final TemplateContextType context = ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JsonContextType.class);
  assertNotNull(context);
  ((TemplateImpl)template).getTemplateContext().setEnabled(context, true);

  CodeInsightTestUtil.addTemplate(template, myTestRootDisposable);
  return template;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JsonLiveTemplateTest.java

示例11: getResolveScope

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
@Override
public GlobalSearchScope getResolveScope(@NotNull VirtualFile file, Project project) {
  if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)) return null;

  ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
  JdkOrderEntry entry = ContainerUtil.findInstance(index.getOrderEntriesForFile(file), JdkOrderEntry.class);
  final Sdk sdk = entry == null ? null : entry.getJdk();
  if (sdk == null || !(sdk.getSdkType() instanceof AndroidSdkType)) {
    return null;
  }

  return new MyJdkScope(project, entry, index.isInLibrarySource(file));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AndroidSdkResolveScopeProvider.java

示例12: getInstance

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public static LuaConfigurationType getInstance() {
    return ContainerUtil.findInstance(Extensions.getExtensions(CONFIGURATION_TYPE_EP), LuaConfigurationType.class);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:4,代码来源:LuaConfigurationType.java

示例13: getInstance

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public static JavaFindUsagesHandlerFactory getInstance(@NotNull Project project) {
  return ContainerUtil.findInstance(Extensions.getExtensions(EP_NAME, project), JavaFindUsagesHandlerFactory.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:JavaFindUsagesHandlerFactory.java

示例14: getFirstKeyboardShortcutText

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public static String getFirstKeyboardShortcutText(@NotNull String actionId) {
  Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
  KeyboardShortcut shortcut = ContainerUtil.findInstance(shortcuts, KeyboardShortcut.class);
  return shortcut == null? "" : getShortcutText(shortcut);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:KeymapUtil.java

示例15: findExtension

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public <V extends T> V findExtension(Class<V> instanceOf) {
  return ContainerUtil.findInstance(getExtensions(), instanceOf);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ExtensionPointName.java


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