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


Java GlobalSearchScope.allScope方法代碼示例

本文整理匯總了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);
            }
        }
    }
}
 
開發者ID:Jamling,項目名稱:Android-ORM-ASPlugin,代碼行數:18,代碼來源:Utils.java

示例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);
            }
        }
    }
}
 
開發者ID:Jamling,項目名稱:Android-ORM-ASPlugin,代碼行數:19,代碼來源:Utils.java

示例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());
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:43,代碼來源:TemplateNameUtils.java

示例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();
    });
}
 
開發者ID:josesamuel,項目名稱:logviewer,代碼行數:11,代碼來源:LogView.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:PsiClassUtil.java

示例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());
                }
            }
        }
    };
}
 
開發者ID:kalessil,項目名稱:yii2inspections,代碼行數:50,代碼來源:UnusedTranslationsInspector.java

示例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();
        }
    };
}
 
開發者ID:kalessil,項目名稱:yii2inspections,代碼行數:68,代碼來源:TranslationsCorrectnessInspector.java

示例8: CreateExtensionMethodClassDialog

import com.intellij.psi.search.GlobalSearchScope; //導入方法依賴的package包/類
public CreateExtensionMethodClassDialog( Project project )
{
  super( "Create Extension Method Class", project, GlobalSearchScope.allScope( project ), null, null );
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:5,代碼來源:CreateExtensionMethodClassDialog.java


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