當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。