本文整理汇总了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);
}
示例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));
}
示例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;
}
示例4: compilePattern
import com.intellij.patterns.compiler.PatternCompilerFactory; //导入依赖的package包/类
@Nullable
public ElementPattern<PsiElement> compilePattern() {
return PatternCompilerFactory.getFactory().<PsiElement>getPatternCompiler(type).compileElementPattern(text);
}
示例5: getCompiler
import com.intellij.patterns.compiler.PatternCompilerFactory; //导入依赖的package包/类
public PatternCompiler<PsiElement> getCompiler() {
return PatternCompilerFactory.getFactory().getPatternCompiler(InjectorUtils.getPatternClasses(getSupportId()));
}
示例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);
}