use of com.intellij.psi.impl.file.PsiPackageImpl in project intellij-community by JetBrains.
the class PackagePrefixElementFinder method getSubPackages.
@NotNull
@Override
public PsiPackage[] getSubPackages(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
final Map<String, PsiPackage> packagesMap = new HashMap<>();
final String qualifiedName = psiPackage.getQualifiedName();
for (final String prefix : myPackagePrefixIndex.getAllPackagePrefixes(scope)) {
if (StringUtil.isEmpty(qualifiedName) || StringUtil.startsWithConcatenation(prefix, qualifiedName, ".")) {
final int i = prefix.indexOf('.', qualifiedName.length() + 1);
String childName = i >= 0 ? prefix.substring(0, i) : prefix;
if (!packagesMap.containsKey(childName)) {
packagesMap.put(childName, new PsiPackageImpl(psiPackage.getManager(), childName));
}
}
}
// avoid SOE caused by returning a package as a subpackage of itself
packagesMap.remove(qualifiedName);
return packagesMap.values().toArray(new PsiPackage[packagesMap.size()]);
}
use of com.intellij.psi.impl.file.PsiPackageImpl in project android by JetBrains.
the class DataBindingProjectComponent method getOrCreateDataBindingPsiPackage.
/**
* Returns a {@linkplain PsiPackage} instance for the given package name.
* <p>
* If it does not exist in the cache, a new one is created.
*
* @param packageName The qualified package name
* @return A {@linkplain PsiPackage} that represents the given qualified name
*/
public synchronized PsiPackage getOrCreateDataBindingPsiPackage(String packageName) {
PsiPackage pkg = myDataBindingPsiPackages.get(packageName);
if (pkg == null) {
pkg = new PsiPackageImpl(PsiManager.getInstance(myProject), packageName) {
@Override
public boolean isValid() {
return true;
}
};
myDataBindingPsiPackages.put(packageName, pkg);
}
return pkg;
}
Aggregations