use of com.intellij.structuralsearch.impl.matcher.CompiledPattern in project intellij-community by JetBrains.
the class JavaCompilingVisitor method visitClass.
@Override
public void visitClass(PsiClass psiClass) {
super.visitClass(psiClass);
CompiledPattern pattern = myCompilingVisitor.getContext().getPattern();
final MatchingHandler handler = pattern.getHandler(psiClass);
if (needsSupers(psiClass, handler)) {
((JavaCompiledPattern) pattern).setRequestsSuperInners(true);
}
handleReferenceText(psiClass.getName(), myCompilingVisitor.getContext());
GlobalCompilingVisitor.setFilter(handler, ClassFilter.getInstance());
}
use of com.intellij.structuralsearch.impl.matcher.CompiledPattern in project intellij-community by JetBrains.
the class PatternCompiler method compilePattern.
public static CompiledPattern compilePattern(final Project project, final MatchOptions options) throws MalformedPatternException, UnsupportedOperationException {
FileType fileType = options.getFileType();
assert fileType instanceof LanguageFileType;
Language language = ((LanguageFileType) fileType).getLanguage();
StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language);
assert profile != null;
CompiledPattern result = profile.createCompiledPattern();
final String[] prefixes = result.getTypedVarPrefixes();
assert prefixes.length > 0;
final CompileContext context = new CompileContext();
if (ApplicationManager.getApplication().isUnitTestMode())
lastTestingContext = context;
try {
context.init(result, options, project, options.getScope() instanceof GlobalSearchScope);
List<PsiElement> elements = compileByAllPrefixes(project, options, result, context, prefixes);
final CompiledPattern pattern = context.getPattern();
checkForUnknownVariables(pattern, elements);
pattern.setNodes(elements);
if (context.getSearchHelper().doOptimizing() && context.getSearchHelper().isScannedSomething()) {
final Set<PsiFile> set = context.getSearchHelper().getFilesSetToScan();
final List<PsiFile> filesToScan = new ArrayList<>(set.size());
final GlobalSearchScope scope = (GlobalSearchScope) options.getScope();
for (final PsiFile file : set) {
if (!scope.contains(file.getVirtualFile())) {
continue;
}
if (file instanceof PsiFileImpl) {
((PsiFileImpl) file).clearCaches();
}
filesToScan.add(file);
}
if (filesToScan.size() == 0) {
throw new MalformedPatternException(SSRBundle.message("ssr.will.not.find.anything"));
}
result.setScope(new LocalSearchScope(PsiUtilCore.toPsiElementArray(filesToScan)));
}
} finally {
context.clear();
}
return result;
}
use of com.intellij.structuralsearch.impl.matcher.CompiledPattern in project intellij-community by JetBrains.
the class JavaCompilingVisitor method visitField.
@Override
public void visitField(PsiField psiField) {
super.visitField(psiField);
CompiledPattern pattern = myCompilingVisitor.getContext().getPattern();
final MatchingHandler handler = pattern.getHandler(psiField);
if (needsSupers(psiField, handler)) {
assert pattern instanceof JavaCompiledPattern;
((JavaCompiledPattern) pattern).setRequestsSuperFields(true);
}
}
use of com.intellij.structuralsearch.impl.matcher.CompiledPattern in project intellij-community by JetBrains.
the class JavaCompilingVisitor method visitMethod.
@Override
public void visitMethod(PsiMethod psiMethod) {
super.visitMethod(psiMethod);
CompiledPattern pattern = myCompilingVisitor.getContext().getPattern();
final MatchingHandler handler = pattern.getHandler(psiMethod);
if (needsSupers(psiMethod, handler)) {
assert pattern instanceof JavaCompiledPattern;
((JavaCompiledPattern) pattern).setRequestsSuperMethods(true);
}
GlobalCompilingVisitor.setFilter(handler, MethodFilter.getInstance());
handleReferenceText(psiMethod.getName(), myCompilingVisitor.getContext());
}
Aggregations