當前位置: 首頁>>代碼示例>>Java>>正文


Java PatternCompilerFactory類代碼示例

本文整理匯總了Java中com.intellij.patterns.compiler.PatternCompilerFactory的典型用法代碼示例。如果您正苦於以下問題:Java PatternCompilerFactory類的具體用法?Java PatternCompilerFactory怎麽用?Java PatternCompilerFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PatternCompilerFactory類屬於com.intellij.patterns.compiler包,在下文中一共展示了PatternCompilerFactory類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRootByClasses

import com.intellij.patterns.compiler.PatternCompilerFactory; //導入依賴的package包/類
@NotNull
private static PsiFile getRootByClasses(@NotNull PsiFile file, @NotNull Class[] classes) {
  final Project project = file.getProject();
  SoftFactoryMap<Class[], PsiFile> map = project.getUserData(PATTERN_INJECTION_CONTEXT);
  if (map == null) {
    map = new SoftFactoryMap<Class[], PsiFile>() {

      @Override
      protected PsiFile create(Class[] key) {
        String text = PatternCompilerFactory.getFactory().getPatternCompiler(key).dumpContextDeclarations();
        return PsiFileFactory.getInstance(project).createFileFromText("context.groovy", GroovyFileType.GROOVY_FILE_TYPE, text);
      }
    };
    project.putUserData(PATTERN_INJECTION_CONTEXT, map);
  }
  return map.get(classes);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:PatternEditorContextMembersProvider.java

示例2: processRootsByClassNames

import com.intellij.patterns.compiler.PatternCompilerFactory; //導入依賴的package包/類
private static boolean processRootsByClassNames(@NotNull PsiFile file, @Nullable String type, @NotNull Processor<PsiElement> processor) {
  Project project = file.getProject();
  Set<String> classNames = collectDevPatternClassNames(project);
  if (!classNames.isEmpty()) {
    JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
    for (String className : classNames) {
      PsiClass patternClass = psiFacade.findClass(className, GlobalSearchScope.allScope(project));
      if (patternClass != null && !processor.process(patternClass)) return false;
    }
  }
  Class[] classes = StringUtil.isEmpty(type) ? ArrayUtil.EMPTY_CLASS_ARRAY : PatternCompilerFactory.getFactory().getPatternClasses(type);
  return classes.length == 0 || processor.process(getRootByClasses(file, classes));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:PatternEditorContextMembersProvider.java

示例3: getRootsByClassNames

import com.intellij.patterns.compiler.PatternCompilerFactory; //導入依賴的package包/類
private static List<PsiElement> getRootsByClassNames(PsiFile file, String type) {
  final List<PsiElement> roots = ContainerUtil.createLockFreeCopyOnWriteList();

  final Project project = file.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  final PsiClass beanClass = psiFacade.findClass(PatternClassBean.class.getName(), GlobalSearchScope.allScope(project));
  if (beanClass != null) {
    final GlobalSearchScope scope =
      GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), StdFileTypes.XML);
    final TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() {
      @Override
      public boolean execute(PsiElement element, int offsetInElement) {
        final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
        final String className = tag == null ? null : tag.getAttributeValue("className");
        if (className != null && tag.getLocalName().endsWith("patternClass")) {
          ContainerUtil.addIfNotNull(psiFacade.findClass(className, GlobalSearchScope.allScope(project)), roots);
        }
        return true;
      }
    };
    final StringSearcher searcher = new StringSearcher("patternClass", true, true);
    CacheManager.SERVICE.getInstance(beanClass.getProject()).processFilesWithWord(new Processor<PsiFile>() {
      @Override
      public boolean process(PsiFile psiFile) {
        LowLevelSearchUtil
          .processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, new EmptyProgressIndicator());
        return true;
      }
    }, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive());
  }
  final Class[] classes = PatternCompilerFactory.getFactory().getPatternClasses(type);
  if (classes.length != 0) {
    roots.add(getRootByClasses(classes, project));
  }
  return roots;
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:37,代碼來源:PatternEditorContextMembersProvider.java

示例4: compilePattern

import com.intellij.patterns.compiler.PatternCompilerFactory; //導入依賴的package包/類
@Nullable
public ElementPattern<PsiElement> compilePattern() {
  return PatternCompilerFactory.getFactory().<PsiElement>getPatternCompiler(type).compileElementPattern(text);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:ElementPatternBean.java

示例5: getCompiler

import com.intellij.patterns.compiler.PatternCompilerFactory; //導入依賴的package包/類
public PatternCompiler<PsiElement> getCompiler() {
  return PatternCompilerFactory.getFactory().getPatternCompiler(InjectorUtils.getPatternClasses(getSupportId()));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:BaseInjection.java

示例6: getRootByClasses

import com.intellij.patterns.compiler.PatternCompilerFactory; //導入依賴的package包/類
private static PsiFile getRootByClasses(Class[] classes, Project project) {
  final String text = PatternCompilerFactory.getFactory().getPatternCompiler(classes).dumpContextDeclarations();
  return PsiFileFactory.getInstance(project).createFileFromText("context.groovy", GroovyFileType.GROOVY_FILE_TYPE, text);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:5,代碼來源:PatternEditorContextMembersProvider.java


注:本文中的com.intellij.patterns.compiler.PatternCompilerFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。