本文整理匯總了Java中com.intellij.psi.search.GlobalSearchScope.allScope方法的典型用法代碼示例。如果您正苦於以下問題:Java GlobalSearchScope.allScope方法的具體用法?Java GlobalSearchScope.allScope怎麽用?Java GlobalSearchScope.allScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.search.GlobalSearchScope
的用法示例。
在下文中一共展示了GlobalSearchScope.allScope方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addJavaImport
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
public static void addJavaImport(Project project, @NotNull PsiJavaFile psiJavaFile, GlobalSearchScope scope, String... classQNames) {
if (project == null) {
project = psiJavaFile.getProject();
}
if (scope == null) {
scope = GlobalSearchScope.allScope(project);
}
if (classQNames != null) {
JavaCodeStyleManager factory = JavaCodeStyleManager.getInstance(project);
for (String name : classQNames) {
PsiClass clazz = JavaPsiFacade.getInstance(project).findClass(name, scope);
if (clazz != null) {
factory.addImport(psiJavaFile, clazz);
}
}
}
}
示例2: addImport
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
public static void addImport(Project project, @NotNull PsiJavaFile psiJavaFile, GlobalSearchScope scope, String... classQNames) {
if (project == null) {
project = psiJavaFile.getProject();
}
if (scope == null) {
scope = GlobalSearchScope.allScope(project);
}
if (classQNames != null) {
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
for (String name : classQNames) {
PsiClass clazz = JavaPsiFacade.getInstance(project).findClass(name, scope);
if (clazz != null) {
PsiImportStatement importStatement = factory.createImportStatement(clazz);
psiJavaFile.getImportList().add(importStatement);
}
}
}
}
示例3: getPossibleNextIdentifierFragments
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
/**
* Finds all fully qualified template names starting with a given prefix with respect to aliases
* and template visibility.
*/
public static Collection<Fragment> getPossibleNextIdentifierFragments(
Project project, PsiElement identifierElement, String identifier, boolean isDelegate) {
AliasMapper mapper = new AliasMapper(identifierElement.getContainingFile());
GlobalSearchScope scope =
isDelegate
? GlobalSearchScope.allScope(project)
: GlobalSearchScope.allScope(project)
.intersectWith(
GlobalSearchScope.notScope(
GlobalSearchScope.fileScope(
identifierElement.getContainingFile().getOriginalFile())));
return TemplateBlockIndex.INSTANCE
.getAllKeys(project)
.stream()
// Filter out private templates, assuming those end with "_".
.filter((key) -> !key.endsWith("_"))
// Filter out deltemplates or normal templates based on `isDelegate`.
// Also checks template's lang.
.filter(
(key) ->
TemplateBlockIndex.INSTANCE
.get(key, project, scope)
.stream()
.anyMatch((block) -> block.isDelegate() == isDelegate))
// Project matches into denormalized key space.
.flatMap(mapper::denormalizeIdentifier)
// Find the denormalized keys that match the identifier.
.filter((key) -> key.startsWith(identifier))
// Collect next fragments.
.map((key) -> getNextFragment(key, identifier))
.collect(Collectors.toList());
}
示例4: AndroidLogConsole
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
AndroidLogConsole(Project project, LogFilterModel logFilterModel, LogFormatter logFormatter) {
super(project, null, "", false, logFilterModel, GlobalSearchScope.allScope(project), logFormatter);
myPreferences = AndroidLogcatPreferences.getInstance(project);
myRegexFilterComponent.setFilter(myPreferences.TOOL_WINDOW_CUSTOM_FILTER);
myRegexFilterComponent.setIsRegex(myPreferences.TOOL_WINDOW_REGEXP_FILTER);
myRegexFilterComponent.addRegexListener(filter -> {
myPreferences.TOOL_WINDOW_CUSTOM_FILTER = filter.getFilter();
myPreferences.TOOL_WINDOW_REGEXP_FILTER = filter.isRegex();
});
}
示例5: getPsiClassByName
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
private PsiClass getPsiClassByName(Project project, String cls) {
GlobalSearchScope searchScope = GlobalSearchScope.allScope(project);
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
return javaPsiFacade.findClass(cls, searchScope);
}
示例6: buildVisitor
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpArrayCreationExpression(ArrayCreationExpression expression) {
final PsiFile file = expression.getContainingFile();
if (!TranslationProviderUtil.isProvider(file)) {
return;
}
/* prepare scope of index search */
GlobalSearchScope theScope = GlobalSearchScope.allScope(expression.getProject());
theScope = GlobalSearchScope.getScopeRestrictedByFileTypes(theScope, PhpFileType.INSTANCE, HtmlFileType.INSTANCE, TwigFileType.INSTANCE);
/* iterate defined translations and report unused */
final String searchPrefix = file.getName().replaceAll("\\.php$", "|");
final Project project = expression.getProject();
for (ArrayHashElement pair : expression.getHashElements()) {
final PhpPsiElement key = pair.getKey();
if (!(key instanceof StringLiteralExpression)) {
continue;
}
final StringLiteralExpression literal = (StringLiteralExpression) key;
final String messageToFind = PhpStringUtil.unescapeText(literal.getContents(), literal.isSingleQuote());
final String regularEntry = searchPrefix + messageToFind;
final Set<String> usages
= new HashSet<>(FileBasedIndex.getInstance().getAllKeys(TranslationCallsIndexer.identity, project));
boolean found = usages.contains(regularEntry);
if (!found && usages.size() > 0) {
final String slashedCategoryEntry = "/" + regularEntry;
for (String usage : usages) {
if (usage.endsWith(slashedCategoryEntry)) {
found = true;
break;
}
}
}
usages.clear();
if (!found) {
holder.registerProblem(pair, messagePattern, ProblemHighlightType.LIKE_UNUSED_SYMBOL, new TheLocalFix());
}
}
}
};
}
示例7: buildVisitor
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpMethodReference(MethodReference reference) {
/* ensure that it's a target call; category is not empty and has no injections; we have messages */
TranslationCallsProcessUtil.ProcessingResult extracted = TranslationCallsProcessUtil.process(reference, true);
if (null == extracted) {
return;
}
/* handle `category` and `category/subcategory` cases */
String categoryForFileName = extracted.getCategory().getContents();
if (-1 != categoryForFileName.indexOf('/')) {
categoryForFileName
= categoryForFileName.substring(1 + categoryForFileName.lastIndexOf('/'), categoryForFileName.length());
}
final String expectedFileName = categoryForFileName + ".php";
/* iterate found translations and validate correctness */
final Map<StringLiteralExpression, PsiElement> messages = extracted.getMessages();
for (StringLiteralExpression literal : messages.keySet()) {
/* only quotes, no content presented */
if (literal.getTextLength() <= 2) {
continue;
}
final String message = literal.getContents();
final PsiElement reportingTarget = messages.get(literal);
/* warn injections are presented and skip further processing */
if (REPORT_INJECTIONS && null != literal.getFirstPsiChild()) {
holder.registerProblem(reportingTarget, messageInjection, ProblemHighlightType.WEAK_WARNING);
continue;
}
/* warn if non-ascii characters has been used */
if (REPORT_NONASCII_CHARACTERS && nonAsciiCharsRegex.matcher(message).matches()) {
holder.registerProblem(reportingTarget, messageNonAscii, ProblemHighlightType.WEAK_WARNING);
}
/* warn if the message is have no translations in the group */
final Set<String> searchEntry
= new HashSet<>(Collections.singletonList(PhpStringUtil.unescapeText(message, literal.isSingleQuote())));
GlobalSearchScope theScope = GlobalSearchScope.allScope(reference.getProject());
theScope = GlobalSearchScope.getScopeRestrictedByFileTypes(theScope, PhpFileType.INSTANCE);
final Set<VirtualFile> providers = new HashSet<>();
FileBasedIndex.getInstance()
.getFilesWithKey(TranslationKeysIndexer.identity, searchEntry, virtualFile -> {
if (virtualFile.getName().equals(expectedFileName)) {
providers.add(virtualFile);
}
return true;
}, theScope);
/* report found cases */
if (REPORT_UNKNOWN_TRANSLATIONS && 0 == providers.size()) {
holder.registerProblem(reportingTarget, messageNoTranslations, ProblemHighlightType.WEAK_WARNING);
}
providers.clear();
}
extracted.dispose();
}
};
}
示例8: CreateExtensionMethodClassDialog
import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
public CreateExtensionMethodClassDialog( Project project )
{
super( "Create Extension Method Class", project, GlobalSearchScope.allScope( project ), null, null );
}