下面列出了怎么用com.intellij.psi.stubs.StubIndex的API类实例代码及写法,或者点击链接到github查看源代码。
@Nullable
private static String findNamespaceByAlias(Project project, String alias) {
Collection<FusionNamespaceDeclaration> namespaces = StubIndex.getElements(
FusionNamespaceDeclarationIndex.KEY,
alias,
project,
GlobalSearchScope.projectScope(project),
FusionNamespaceDeclaration.class);
if (!namespaces.isEmpty()) {
FusionNamespace namespace = namespaces.iterator().next().getNamespace();
if (namespace != null) {
return namespace.getText();
}
}
return null;
}
/**
* @param path for function "TestFoo" in target "//foo/bar:baz" would be "//foo/bar:baz::TestFoo".
* See {@link BlazeGoTestEventsHandler#testLocationUrl}.
*/
@SuppressWarnings("rawtypes")
private static List<Location> findTestFunction(Project project, String path) {
String[] parts = path.split(SmRunnerUtils.TEST_NAME_PARTS_SPLITTER);
if (parts.length != 2) {
return ImmutableList.of();
}
String labelString = parts[0];
String functionName = parts[1];
TargetIdeInfo target = getGoTestTarget(project, labelString);
if (target == null) {
return ImmutableList.of();
}
List<VirtualFile> goFiles = getGoFiles(project, target);
if (goFiles.isEmpty()) {
return ImmutableList.of();
}
GlobalSearchScope scope = FilesScope.filesScope(project, goFiles);
Collection<GoFunctionDeclaration> functions =
StubIndex.getElements(
GoFunctionIndex.KEY, functionName, project, scope, GoFunctionDeclaration.class);
return functions.stream().map(PsiLocation::new).collect(Collectors.toList());
}
public static void collectIncludedFiles(PsiFile file, Set<PsiFile> files, boolean followNestedFiles) {
String filePath = file.getVirtualFile().getPath();
Collection<BashIncludeCommand> commands = StubIndex.getElements(BashIncludeCommandIndex.KEY, filePath, file.getProject(), GlobalSearchScope.fileScope(file), BashIncludeCommand.class);
for (BashIncludeCommand command : commands) {
PsiFile includedFile = findIncludedFile(command);
if (includedFile != null) {
boolean followFile = followNestedFiles && !files.contains(includedFile);
files.add(includedFile);
if (followFile) {
collectIncludedFiles(includedFile, files, true);
}
}
}
}
@Override
public void processElementsWithName(
@Nonnull String name, @Nonnull Processor<NavigationItem> navigationItemProcessor, @Nonnull FindSymbolParameters findSymbolParameters)
{
Project project = findSymbolParameters.getProject();
IdFilter idFilter = findSymbolParameters.getIdFilter();
GlobalSearchScope searchScope = findSymbolParameters.getSearchScope();
StubIndex.getInstance().processElements(CSharpIndexKeys.METHOD_INDEX, name, project, searchScope, idFilter,
DotNetLikeMethodDeclaration.class, (Processor) navigationItemProcessor);
StubIndex.getInstance().processElements(CSharpIndexKeys.EVENT_INDEX, name, project, searchScope, idFilter,
DotNetEventDeclaration.class, (Processor) navigationItemProcessor);
StubIndex.getInstance().processElements(CSharpIndexKeys.PROPERTY_INDEX, name, project, searchScope, idFilter,
DotNetPropertyDeclaration.class, (Processor) navigationItemProcessor);
StubIndex.getInstance().processElements(CSharpIndexKeys.FIELD_INDEX, name, project, searchScope, idFilter,
DotNetFieldDeclaration.class, (Processor) navigationItemProcessor);
}
private static Collection<PhpClass> getPhpClassInsideNamespace(Project project, PhpIndex phpIndex, String namespaceName, int maxDeep) {
final Collection<PhpClass> phpClasses = new ArrayList<>();
if(maxDeep-- <= 0) {
return phpClasses;
}
StubIndex.getInstance().processElements(PhpNamespaceIndex.KEY, namespaceName.toLowerCase(), project, phpIndex.getSearchScope(), PhpNamespace.class, phpNamespace -> {
phpClasses.addAll(PsiTreeUtil.getChildrenOfTypeAsList(phpNamespace.getStatements(), PhpClass.class));
return true;
});
for(String ns: phpIndex.getChildNamespacesByParentName(namespaceName + "\\")) {
phpClasses.addAll(getPhpClassInsideNamespace(project, phpIndex, namespaceName + "\\" + ns, maxDeep));
}
return phpClasses;
}
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
Collection<String> keys = StubIndex.getInstance().getAllKeys(FusionPrototypeDeclarationIndex.KEY, parameters.getPosition().getProject());
Project project = parameters.getPosition().getProject();
for (String key : keys) {
Collection<FusionPrototypeSignature> prototypes = StubIndex.getElements(FusionPrototypeDeclarationIndex.KEY, key, project, GlobalSearchScope.projectScope(project), FusionPrototypeSignature.class );
for (FusionPrototypeSignature signature : prototypes) {
if (signature.getType() != null) {
result.addElement(LookupElementBuilder.create(signature.getType().getText()).withIcon(FusionIcons.PROTOTYPE));
}
}
}
}
/**
* Finds all files which include the given file.
* The bash files of the module are checked if they include the file.
*
* @param project The project
* @param file The file for which the includers should be found.
* @return
*/
@NotNull
public static Set<BashFile> findIncluders(@NotNull Project project, @NotNull PsiFile file) {
if (DumbService.isDumb(project)) {
return Collections.emptySet();
}
GlobalSearchScope searchScope = BashSearchScopes.moduleScope(file);
String filename = file.getName();
if (StringUtils.isEmpty(filename)) {
return Collections.emptySet();
}
Collection<BashIncludeCommand> includeCommands = StubIndex.getElements(BashIncludedFilenamesIndex.KEY, filename, project, BashSearchScopes.bashOnly(searchScope), BashIncludeCommand.class);
if (includeCommands == null || includeCommands.isEmpty()) {
return Collections.emptySet();
}
Set<BashFile> includers = Sets.newLinkedHashSet();
for (BashIncludeCommand command : includeCommands) {
BashFile includer = (BashFile) BashPsiUtils.findFileContext(command);
if (!file.equals(includer)) {
includers.add(includer);
}
}
return includers;
}
/**
* Returns the commands of file which include the other file.
*
* @param file
* @param filterByFile
* @return The list of commands, may be empty but wont be null
*/
public static List<BashIncludeCommand> findIncludeCommands(PsiFile file, @Nullable final PsiFile filterByFile) {
String filePath = file.getVirtualFile().getPath();
List<BashIncludeCommand> result = Lists.newLinkedList();
Collection<BashIncludeCommand> commands = StubIndex.getElements(BashIncludeCommandIndex.KEY, filePath, file.getProject(), GlobalSearchScope.fileScope(file), BashIncludeCommand.class);
for (BashIncludeCommand command : commands) {
if (filterByFile == null || filterByFile.equals(findIncludedFile(command))) {
result.add(command);
}
}
return result;
}
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
Collection<HaskellNamedElement> result = StubIndex.getElements(HaskellAllNameIndex.KEY, name, project, scope, HaskellNamedElement.class);
List<NavigationItem> items = ContainerUtil.newArrayListWithCapacity(result.size());
for (HaskellNamedElement element : result) {
items.add(element);
}
return items.toArray(new NavigationItem[items.size()]);
}
@Override
public void collectTypes(@Nonnull String s, @Nonnull GlobalSearchScope searchScope, @Nullable IdFilter filter, @Nonnull final Processor<DotNetTypeDeclaration> processor)
{
StubIndex.getInstance().processElements(CSharpIndexKeys.TYPE_INDEX, s, myProject, searchScope, filter, CSharpTypeDeclaration.class, processor);
StubIndex.getInstance().processElements(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, s, myProject, searchScope, filter, CSharpMethodDeclaration.class, methodDeclaration ->
{
ProgressManager.checkCanceled();
CSharpTypeDeclaration typeFromDelegate = CSharpLambdaResolveResultUtil.createTypeFromDelegate(methodDeclaration, DotNetGenericExtractor.EMPTY);
return processor.process(typeFromDelegate);
});
}
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> navigationItemProcessor, @Nonnull FindSymbolParameters findSymbolParameters)
{
Project project = findSymbolParameters.getProject();
IdFilter idFilter = findSymbolParameters.getIdFilter();
Processor temp = navigationItemProcessor;
GlobalSearchScope searchScope = findSymbolParameters.getSearchScope();
StubIndex.getInstance().processElements(CSharpIndexKeys.TYPE_INDEX, name, project, searchScope, idFilter, CSharpTypeDeclaration.class, temp);
StubIndex.getInstance().processElements(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, name, project, searchScope, idFilter, CSharpMethodDeclaration.class, temp);
}
@Override
public void processNames(@Nonnull Processor<String> stringProcessor, @Nonnull GlobalSearchScope searchScope, @Nullable IdFilter idFilter)
{
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.METHOD_INDEX, stringProcessor, searchScope, idFilter);
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.EVENT_INDEX, stringProcessor, searchScope, idFilter);
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.PROPERTY_INDEX, stringProcessor, searchScope, idFilter);
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.FIELD_INDEX, stringProcessor, searchScope, idFilter);
}
@NotNull
@Override
public Collection<PsiParameter> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
return StubIndex.getElements(getKey(), integer, project, /*new JavaSourceFilterScope(scope) TODO*/scope, PsiParameter.class);
}
@NotNull
@Override
public Collection<PsiModule> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
return StubIndex.getElements(getKey(), integer, project, scope, PsiModule.class);
}
@NotNull
@Override
public Collection<PsiVariantDeclaration> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
return StubIndex.getElements(getKey(), integer, project, scope, PsiVariantDeclaration.class);
}
@NotNull
@Override
public Collection<PsiException> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
return StubIndex.getElements(getKey(), integer, project, scope, PsiException.class);
}
@NotNull
@Override
public Collection<PsiLet> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
return StubIndex.getElements(getKey(), integer, project, /*new JavaSourceFilterScope(scope) TODO*/scope, PsiLet.class);
}
@NotNull
@Override
public Collection<PsiVal> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
return StubIndex.getElements(getKey(), integer, project, /*new JavaSourceFilterScope(scope) TODO*/scope, PsiVal.class);
}
public static List<PsiElement> getPrototypeDefinitions(Project project, String name, @Nullable String namespace) {
String instanceAliasNamespace = null;
if (namespace != null) {
instanceAliasNamespace = findNamespaceByAlias(project, namespace);
}
// find all prototypes that have the name of this instance
List<PsiElement> result = new ArrayList<>();
Collection<FusionPrototypeSignature> possiblePrototypes = StubIndex.getElements(
FusionPrototypeDeclarationIndex.KEY,
name,
project,
GlobalSearchScope.projectScope(project),
FusionPrototypeSignature.class);
// check for each prototype if the namespace matches by resolving aliases
for (FusionPrototypeSignature possiblePrototype : possiblePrototypes) {
FusionType prototypeType = possiblePrototype.getType();
if (prototypeType != null) {
PsiElement prototypeNamespace = prototypeType.getObjectTypeNamespace();
if (prototypeNamespace != null) {
// check if prototype has default namespace
if (namespace == null) {
if (prototypeNamespace.getText().equals("TYPO3.Neos")
|| prototypeNamespace.getText().equals("Neos.Neos")) {
result.add(possiblePrototype);
}
continue;
}
String prototypeNs = prototypeType.getObjectTypeNamespace().getText();
if (prototypeNs.equals(namespace) || prototypeNs.equals(instanceAliasNamespace)) {
result.add(possiblePrototype);
} else {
prototypeNs = findNamespaceByAlias(project, prototypeNs);
if (namespace.equals(prototypeNs)) {
result.add(possiblePrototype);
}
}
} else if (namespace == null
|| (namespace.equals("TYPO3.Neos")
|| namespace.equals("Neos.Neos"))) {
result.add(possiblePrototype);
}
}
}
// If one of the results is a prototype inheritance, return it as the only result
for (PsiElement resultPrototype : result) {
if (resultPrototype instanceof FusionPrototypeSignature
&& ((FusionPrototypeSignature)resultPrototype).isInheritanceDefinition()) {
result.clear();
result.add(resultPrototype);
return result;
}
}
return result;
}
@NotNull
public static Set<PsiFile> findIncludedFiles(@NotNull PsiFile sourceFile, boolean diveDeep, boolean bashOnly) {
if (!(sourceFile instanceof BashFile)) {
return Collections.emptySet();
}
if (!sourceFile.isPhysical()) {
return Collections.emptySet();
}
if (DumbService.isDumb(sourceFile.getProject())) {
return Collections.emptySet();
}
Project project = sourceFile.getProject();
Set<PsiFile> includersTodo = Sets.newLinkedHashSet(Collections.singletonList(sourceFile));
Set<PsiFile> includersDone = Sets.newLinkedHashSet();
Set<PsiFile> allIncludedFiles = Sets.newHashSet();
while (!includersTodo.isEmpty()) {
Iterator<PsiFile> iterator = includersTodo.iterator();
PsiFile file = iterator.next();
iterator.remove();
includersDone.add(file);
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
continue;
}
String filePath = virtualFile.getPath();
Collection<BashIncludeCommand> commands = StubIndex.getElements(BashIncludeCommandIndex.KEY, filePath, project, BashSearchScopes.bashOnly(BashSearchScopes.moduleScope(file)), BashIncludeCommand.class);
if (commands.isEmpty()) {
continue;
}
for (BashIncludeCommand command : commands) {
BashFileReference fileReference = command.getFileReference();
if (fileReference != null && fileReference.isStatic()) {
PsiFile referencedFile = fileReference.findReferencedFile();
if (bashOnly && !(referencedFile instanceof BashFile)) {
continue;
}
if (referencedFile != null) {
allIncludedFiles.add(referencedFile);
if (!includersDone.contains(referencedFile)) {
//the include commands of this command have to be collected, too
includersTodo.add(referencedFile);
}
}
}
}
if (!diveDeep) {
//the first iteration is the original source
break;
}
}
return allIncludedFiles;
}
public static PsiElement resolve(BashVar bashVar, boolean dumbMode, ResolveProcessor processor) {
if (bashVar == null || !bashVar.isPhysical()) {
return null;
}
final String varName = bashVar.getReferenceName();
if (varName == null) {
return null;
}
PsiFile psiFile = BashPsiUtils.findFileContext(bashVar);
VirtualFile virtualFile = psiFile.getVirtualFile();
String filePath = virtualFile != null ? virtualFile.getPath() : null;
Project project = bashVar.getProject();
ResolveState resolveState = ResolveState.initial();
GlobalSearchScope fileScope = GlobalSearchScope.fileScope(psiFile);
Collection<BashVarDef> varDefs;
if (dumbMode || isScratchFile(virtualFile) || isNotIndexedFile(project, virtualFile)) {
varDefs = PsiTreeUtil.collectElementsOfType(psiFile, BashVarDef.class);
} else {
varDefs = StubIndex.getElements(BashVarDefIndex.KEY, varName, project, fileScope, BashVarDef.class);
}
for (BashVarDef varDef : varDefs) {
ProgressManager.checkCanceled();
processor.execute(varDef, resolveState);
}
if (!dumbMode && filePath != null) {
Collection<BashIncludeCommand> includeCommands = StubIndex.getElements(BashIncludeCommandIndex.KEY, filePath, project, fileScope, BashIncludeCommand.class);
if (!includeCommands.isEmpty()) {
boolean varIsInFunction = BashPsiUtils.findNextVarDefFunctionDefScope(bashVar) != null;
for (BashIncludeCommand command : includeCommands) {
ProgressManager.checkCanceled();
boolean includeIsInFunction = BashPsiUtils.findNextVarDefFunctionDefScope(command) != null;
//either one of var or include command is in a function or the var is used after the include command
if (varIsInFunction || includeIsInFunction || (BashPsiUtils.getFileTextOffset(bashVar) > BashPsiUtils.getFileTextEndOffset(command))) {
try {
resolveState = resolveState.put(Keys.resolvingIncludeCommand, command);
command.processDeclarations(processor, resolveState, command, bashVar);
} finally {
resolveState = resolveState.put(Keys.resolvingIncludeCommand, null);
}
}
}
}
}
processor.prepareResults();
return processor.getBestResult(false, bashVar);
}
/**
* @return true if the definition of this variable is not child of a conditional command or loop.
*/
public static boolean hasStaticVarDefPath(BashVar bashVar) {
BashReference reference = bashVar.getNeighborhoodReference();
if (reference == null) {
return false;
}
PsiElement closestDef = reference.resolve();
if (closestDef == null) {
return false;
}
// if the closest def is in a different def scope, then we can't handle that
// (e.g. var is top-level, def is in a function or var is in a function and def in another function, etc.)
BashFunctionDef varScope = BashPsiUtils.findNextVarDefFunctionDefScope(bashVar);
BashFunctionDef defScope = BashPsiUtils.findNextVarDefFunctionDefScope(closestDef);
if (varScope == null && defScope != null) {
return false;
}
// we can't handle different functions as scope
if (varScope != null && !varScope.isEquivalentTo(defScope)) {
return false;
}
// atm we can't handle different files
PsiFile psiFile = bashVar.getContainingFile();
if (varScope == null && !psiFile.isEquivalentTo(closestDef.getContainingFile())) {
return false;
}
Collection<BashVarDef> allDefs = StubIndex.getElements(BashVarDefIndex.KEY, bashVar.getReferenceName(), bashVar.getProject(), GlobalSearchScope.fileScope(psiFile), BashVarDef.class);
for (BashVarDef candidateDef : allDefs) {
ProgressManager.checkCanceled();
// skip var defs which are not in our own def scope
BashFunctionDef scope = BashPsiUtils.findNextVarDefFunctionDefScope(candidateDef);
if (varScope != null && !varScope.isEquivalentTo(scope)) {
continue;
}
// it's not a static path if the var def is in a conditional block or loop and if our var is not
PsiElement parent = PsiTreeUtil.findFirstParent(candidateDef, psi -> psi instanceof BashConditionalBlock || psi instanceof BashLoop);
if (parent != null && !PsiTreeUtil.isAncestor(parent, bashVar, true)) {
return false;
}
}
return true;
}
public static SearchScope getElementUseScope(BashPsiElement element, Project project) {
//all files which include this element's file belong to the requested scope
//bash files can call other bash files, thus the scope needs to be the module scope at minumum
//fixme can this be optimized?
PsiFile currentFile = BashPsiUtils.findFileContext(element);
if (currentFile == null) {
//no other fallback possible here
return GlobalSearchScope.projectScope(project);
}
Set<BashFile> includers = FileInclusionManager.findIncluders(project, currentFile);
Set<PsiFile> included = FileInclusionManager.findIncludedFiles(currentFile, true, true);
//find all files which reference the source file
Set<PsiFile> referencingScriptFiles = Sets.newLinkedHashSet();
if (element instanceof BashFile) {
String searchedName = ((BashFile) element).getName();
if (searchedName != null) {
Collection<BashCommand> commands = StubIndex.getElements(
BashCommandNameIndex.KEY,
searchedName,
project,
GlobalSearchScope.projectScope(project), //module scope isn't working as expected because it doesn't include non-src dirs
BashCommand.class);
if (commands != null) {
for (BashCommand command : commands) {
referencingScriptFiles.add(BashPsiUtils.findFileContext(command));
}
}
}
}
if (includers.isEmpty() && included.isEmpty() && referencingScriptFiles.isEmpty()) {
//we should return a local search scope if we only have local references
//not return a local scope because then inline renaming is not possible
return GlobalSearchScope.fileScope(currentFile);
}
//fixme improve this
Set<PsiFile> union = Sets.newLinkedHashSet();
union.addAll(included);
union.addAll(includers);
union.addAll(referencingScriptFiles);
Collection<VirtualFile> virtualFiles = Collections2.transform(union, psiToVirtualFile());
return GlobalSearchScope.fileScope(currentFile).union(GlobalSearchScope.filesScope(project, virtualFiles));
}
@Nullable
@Override
public PsiElement resolveInner() {
final String referencedName = cmd.getReferencedCommandName();
if (referencedName == null) {
return null;
}
final ResolveProcessor processor = new BashFunctionProcessor(referencedName);
Project project = cmd.getProject();
PsiFile currentFile = cmd.getContainingFile();
GlobalSearchScope allFiles = FileInclusionManager.includedFilesUnionScope(currentFile);
Collection<BashFunctionDef> functionDefs = StubIndex.getElements(BashFunctionNameIndex.KEY, referencedName, project, allFiles, BashFunctionDef.class);
ResolveState initial = ResolveState.initial();
for (BashFunctionDef functionDef : functionDefs) {
processor.execute(functionDef, initial);
}
//find include commands which are relevant for the start element
if (!processor.hasResults()) {
Set<BashFile> includingFiles = FileInclusionManager.findIncluders(project, currentFile);
List<GlobalSearchScope> scopes = Lists.newLinkedList();
for (BashFile file : includingFiles) {
scopes.add(GlobalSearchScope.fileScope(file));
}
if (!scopes.isEmpty()) {
GlobalSearchScope scope = GlobalSearchScope.union(scopes.toArray(new GlobalSearchScope[scopes.size()]));
functionDefs = StubIndex.getElements(BashFunctionNameIndex.KEY, referencedName, project, scope, BashFunctionDef.class);
for (BashFunctionDef def : functionDefs) {
processor.execute(def, initial);
}
}
}
processor.prepareResults();
return processor.hasResults() ? processor.getBestResult(true, cmd) : null;
}
@Override
public void processNames(@Nonnull Processor<String> processor, @Nonnull GlobalSearchScope scope, @Nullable IdFilter filter)
{
StubIndex.getInstance().processAllKeys(UnityScriptIndexKeys.FILE_BY_NAME_INDEX, processor, scope, filter);
}
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> processor, @Nonnull FindSymbolParameters parameters)
{
StubIndex.getInstance().processElements(UnityScriptIndexKeys.FILE_BY_NAME_INDEX, name, parameters.getProject(), parameters.getSearchScope(), parameters.getIdFilter(), JSFile.class,
new Processor<JSFile>()
{
@Override
public boolean process(final JSFile file)
{
return processor.process(new FakePsiElement()
{
@Override
public String getName()
{
return FileUtil.getNameWithoutExtension(file.getName());
}
@Nonnull
@Override
public Project getProject()
{
return file.getProject();
}
@Nullable
@Override
public Image getIcon()
{
IconDescriptor descriptor = new IconDescriptor(AllIcons.Nodes.Class);
descriptor.addLayerIcon(Unity3dIcons.Js);
descriptor.setRightIcon(AllIcons.Nodes.C_public);
return descriptor.toIcon();
}
@Override
public PsiElement getParent()
{
return file;
}
});
}
});
}
@NotNull
@Override
public String[] getNames(Project project, boolean includeNonProjectItems) {
return ArrayUtil.toStringArray(StubIndex.getInstance().getAllKeys(HaskellAllNameIndex.KEY, project));
}
@RequiredReadAction
public List<CSharpResolveContext> collectResolveContexts()
{
String qName = myNamespaceAsElement.getPresentableQName();
if(qName == null)
{
return Collections.emptyList();
}
Project project = myNamespaceAsElement.getProject();
String indexableName = DotNetNamespaceStubUtil.getIndexableNamespace(qName);
Set<DotNetTypeDeclaration> result = new THashSet<>();
StubIndex.getInstance().processElements(CSharpIndexKeys.TYPE_WITH_EXTENSION_METHODS_INDEX, indexableName, project, myResolveScope, DotNetTypeDeclaration.class, Processors
.cancelableCollectProcessor(result));
Set<String> processed = new THashSet<>();
List<CSharpResolveContext> list = new SmartList<>();
for(DotNetTypeDeclaration typeDeclaration : result)
{
ProgressManager.checkCanceled();
PsiElement wrappedDeclaration = ToNativeElementTransformers.transform(typeDeclaration);
if(typeDeclaration instanceof CSharpTypeDeclaration && typeDeclaration.hasModifier(CSharpModifier.PARTIAL))
{
String vmQName = typeDeclaration.getVmQName();
if(processed.contains(vmQName))
{
continue;
}
processed.add(vmQName);
}
CSharpResolveContext context = CSharpResolveContextUtil.createContext(DotNetGenericExtractor.EMPTY, myResolveScope, wrappedDeclaration);
list.add(context);
}
return list.isEmpty() ? Collections.emptyList() : list;
}
@Override
public void collectTypeNames(@Nonnull Processor<String> processor, @Nonnull GlobalSearchScope searchScope, @Nullable IdFilter filter)
{
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.TYPE_INDEX, processor, searchScope, filter);
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, processor, searchScope, filter);
}
@Override
public void processNames(@Nonnull Processor<String> stringProcessor, @Nonnull GlobalSearchScope searchScope, @Nullable IdFilter idFilter)
{
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.TYPE_INDEX, stringProcessor, searchScope, idFilter);
StubIndex.getInstance().processAllKeys(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, stringProcessor, searchScope, idFilter);
}