List<ContextFilter> (Map args) { List<ContextFilter> result = new ArrayList<>(); PsiFilePattern.Capture<GroovyFile> scriptPattern = GroovyPatterns.groovyScript(); if (extension != null && !extension.isEmpty()) { scriptPattern = scriptPattern.withVirtualFile(PlatformPatterns.virtualFile().withExtension(extension)); } result.add(new FileContextFilter(scriptPattern)); // Name matcher if (namePattern != null && !namePattern.isEmpty()) { result.add(new FileContextFilter( PlatformPatterns.psiFile().withName(StandardPatterns.string().matches(namePattern)))); } // Process unqualified references only String ctype = (String)args.get("ctype"); if (ctype == null || ctype.isEmpty()) { ElementPattern synt = StandardPatterns.instanceOf(SyntheticElement.class); PsiClassPattern psiClass = PsiJavaPatterns.psiClass(); ElementPattern pattern = doAnd(psiClass, synt); result.add(ClassContextFilter.fromClassPattern(pattern)); } return result; }