mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
[stubs] Reduce amount of raw types
GitOrigin-RevId: 169895a6ee3c98db193443dbb0ced98497221430
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d345431d4a
commit
6bb83bc8e5
@@ -31,7 +31,7 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull IStubFileElementType getType() {
|
||||
public @NotNull IStubFileElementType<?> getType() {
|
||||
return JavaParserDefinition.JAVA_FILE;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
@Override
|
||||
public PsiParameterStub findParameter(final int idx) {
|
||||
PsiParameterListStub list = null;
|
||||
for (StubElement child : getChildrenStubs()) {
|
||||
for (StubElement<?> child : getChildrenStubs()) {
|
||||
if (child instanceof PsiParameterListStub) {
|
||||
list = (PsiParameterListStub)child;
|
||||
break;
|
||||
@@ -91,7 +91,7 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
}
|
||||
|
||||
if (list != null) {
|
||||
final List<StubElement> params = list.getChildrenStubs();
|
||||
final List<StubElement<?>> params = list.getChildrenStubs();
|
||||
return (PsiParameterStub)params.get(idx);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PsiTypeParameterStubImpl extends StubBase<PsiTypeParameter> impleme
|
||||
|
||||
@Override
|
||||
public @NotNull List<PsiAnnotationStub> getAnnotations() {
|
||||
List<StubElement> children = getChildrenStubs();
|
||||
List<StubElement<?>> children = getChildrenStubs();
|
||||
|
||||
return ContainerUtil.mapNotNull(children,
|
||||
stubElement -> stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null);
|
||||
|
||||
@@ -791,7 +791,7 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
assertNotNull(fileNode);
|
||||
assertFalse(fileNode.isParsed());
|
||||
StubElement<?> element = myBuilder.buildStubTree(file);
|
||||
@SuppressWarnings("rawtypes") List<StubElement> stubs = element.getChildrenStubs();
|
||||
List<StubElement<?>> stubs = element.getChildrenStubs();
|
||||
assertSize(2, stubs);
|
||||
PsiClassStub<?> classStub = (PsiClassStub<?>)stubs.get(1);
|
||||
assertFalse(classStub.isInterface());
|
||||
|
||||
@@ -26,10 +26,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PsiFileStub<T extends PsiFile> extends StubElement<T>, UserDataHolder {
|
||||
PsiFileStub[] EMPTY_ARRAY = new PsiFileStub[0];
|
||||
PsiFileStub<?>[] EMPTY_ARRAY = new PsiFileStub[0];
|
||||
|
||||
@NotNull
|
||||
StubFileElementType getType();
|
||||
StubFileElementType<?> getType();
|
||||
|
||||
@Nullable
|
||||
String getInvalidationReason();
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
private static final AtomicReferenceFieldUpdater<StubBase, PsiElement> myPsiUpdater =
|
||||
AtomicReferenceFieldUpdater.newUpdater(StubBase.class, PsiElement.class, "myPsi");
|
||||
|
||||
protected StubBase(@Nullable StubElement parent, IStubElementType elementType) {
|
||||
protected StubBase(@Nullable StubElement parent, IStubElementType<?, ?> elementType) {
|
||||
super(parent);
|
||||
myStubList = parent == null ? new MaterialStubList(10) : ((StubBase<?>)parent).myStubList;
|
||||
myStubList.addStub(this, (StubBase<?>)parent, elementType);
|
||||
@@ -34,7 +34,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public StubElement getParentStub() {
|
||||
public StubElement<?> getParentStub() {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public @NotNull List<StubElement> getChildrenStubs() {
|
||||
public @NotNull List<StubElement<?>> getChildrenStubs() {
|
||||
return (List)myStubList.getChildrenStubs(id);
|
||||
}
|
||||
|
||||
@@ -73,13 +73,13 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
if (psi != null) return psi;
|
||||
|
||||
//noinspection unchecked
|
||||
psi = (T)getStubType().createPsi(this);
|
||||
psi = ((IStubElementType<StubBase<T>, T>)getStubType()).createPsi(this);
|
||||
return myPsiUpdater.compareAndSet(this, null, psi) ? psi : Objects.requireNonNull(myPsi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends PsiElement> E @NotNull [] getChildrenByType(final @NotNull IElementType elementType, E[] array) {
|
||||
List<StubElement> childrenStubs = getChildrenStubs();
|
||||
List<StubElement<?>> childrenStubs = getChildrenStubs();
|
||||
int count = countChildren(elementType, childrenStubs);
|
||||
|
||||
array = ArrayUtil.ensureExactSize(count, array);
|
||||
@@ -91,7 +91,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
|
||||
@Override
|
||||
public <E extends PsiElement> E @NotNull [] getChildrenByType(final @NotNull TokenSet filter, E[] array) {
|
||||
List<StubElement> childrenStubs = getChildrenStubs();
|
||||
List<StubElement<?>> childrenStubs = getChildrenStubs();
|
||||
int count = countChildren(filter, childrenStubs);
|
||||
|
||||
array = ArrayUtil.ensureExactSize(count, array);
|
||||
@@ -104,7 +104,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
@Override
|
||||
public <E extends PsiElement> E @NotNull [] getChildrenByType(final @NotNull IElementType elementType,
|
||||
final @NotNull ArrayFactory<? extends E> f) {
|
||||
List<StubElement> childrenStubs = getChildrenStubs();
|
||||
List<StubElement<?>> childrenStubs = getChildrenStubs();
|
||||
int count = countChildren(elementType, childrenStubs);
|
||||
|
||||
E[] result = f.create(count);
|
||||
@@ -113,7 +113,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int countChildren(IElementType elementType, List<? extends StubElement> childrenStubs) {
|
||||
private static int countChildren(IElementType elementType, List<? extends StubElement<?>> childrenStubs) {
|
||||
int count = 0;
|
||||
for (int i = 0, childrenStubsSize = childrenStubs.size(); i < childrenStubsSize; i++) {
|
||||
StubElement<?> childStub = childrenStubs.get(i);
|
||||
@@ -123,7 +123,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
return count;
|
||||
}
|
||||
|
||||
private static int countChildren(TokenSet types, List<? extends StubElement> childrenStubs) {
|
||||
private static int countChildren(TokenSet types, List<? extends StubElement<?>> childrenStubs) {
|
||||
int count = 0;
|
||||
for (int i = 0, childrenStubsSize = childrenStubs.size(); i < childrenStubsSize; i++) {
|
||||
StubElement<?> childStub = childrenStubs.get(i);
|
||||
@@ -135,7 +135,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
|
||||
private static <E extends PsiElement> void fillFilteredChildren(IElementType type,
|
||||
E[] result,
|
||||
List<? extends StubElement> childrenStubs) {
|
||||
List<? extends StubElement<?>> childrenStubs) {
|
||||
int count = 0;
|
||||
for (int i = 0, childrenStubsSize = childrenStubs.size(); i < childrenStubsSize; i++) {
|
||||
StubElement<?> childStub = childrenStubs.get(i);
|
||||
@@ -148,7 +148,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
assert count == result.length;
|
||||
}
|
||||
|
||||
private static <E extends PsiElement> void fillFilteredChildren(TokenSet set, E[] result, List<? extends StubElement> childrenStubs) {
|
||||
private static <E extends PsiElement> void fillFilteredChildren(TokenSet set, E[] result, List<? extends StubElement<?>> childrenStubs) {
|
||||
int count = 0;
|
||||
for (int i = 0, childrenStubsSize = childrenStubs.size(); i < childrenStubsSize; i++) {
|
||||
StubElement<?> childStub = childrenStubs.get(i);
|
||||
@@ -164,7 +164,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
@Override
|
||||
public <E extends PsiElement> E @NotNull [] getChildrenByType(final @NotNull TokenSet filter,
|
||||
final @NotNull ArrayFactory<? extends E> f) {
|
||||
List<StubElement> childrenStubs = getChildrenStubs();
|
||||
List<StubElement<?>> childrenStubs = getChildrenStubs();
|
||||
int count = countChildren(filter, childrenStubs);
|
||||
|
||||
E[] array = f.create(count);
|
||||
@@ -190,7 +190,7 @@ public abstract class StubBase<T extends PsiElement> extends ObjectStubBase<Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStubElementType getStubType() {
|
||||
public IStubElementType<?, ?> getStubType() {
|
||||
return myStubList.getStubType(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ import java.util.List;
|
||||
|
||||
public interface StubElement<T extends PsiElement> extends Stub {
|
||||
@Override
|
||||
IStubElementType getStubType();
|
||||
IStubElementType<?, ?> getStubType();
|
||||
@Override
|
||||
StubElement getParentStub();
|
||||
StubElement<?> getParentStub();
|
||||
|
||||
@Nullable PsiFileStub<?> getContainingFileStub();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
List<StubElement> getChildrenStubs();
|
||||
List<StubElement<?>> getChildrenStubs();
|
||||
|
||||
@Nullable
|
||||
<P extends PsiElement, S extends StubElement<P>> S findChildStubByType(@NotNull IStubElementType<S, P> elementType);
|
||||
|
||||
@@ -10,7 +10,7 @@ final class StubSerializationUtil {
|
||||
static ObjectStubSerializer<Stub, Stub> getSerializer(@NotNull Stub rootStub) {
|
||||
if (rootStub instanceof PsiFileStub) {
|
||||
//noinspection unchecked
|
||||
return ((PsiFileStub<?>)rootStub).getType();
|
||||
return ((PsiFileStub)rootStub).getType();
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (ObjectStubSerializer<Stub, Stub>)rootStub.getStubType();
|
||||
|
||||
@@ -594,7 +594,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
/**
|
||||
* @return a root stub of {@link #getStubTree()}, or null if the file is not stub-based or AST has been loaded.
|
||||
*/
|
||||
public @Nullable StubElement getStub() {
|
||||
public @Nullable StubElement<?> getStub() {
|
||||
StubTree stubHolder = getStubTree();
|
||||
return stubHolder != null ? stubHolder.getRoot() : null;
|
||||
}
|
||||
@@ -707,14 +707,14 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
ObjectStubTree<?> tree = StubTreeLoader.getInstance().readOrBuild(getProject(), vFile, this);
|
||||
if (!(tree instanceof StubTree)) return Pair.empty();
|
||||
FileViewProvider viewProvider = getViewProvider();
|
||||
List<Pair<IStubFileElementType, PsiFile>> roots = StubTreeBuilder.getStubbedRoots(viewProvider);
|
||||
List<Pair<IStubFileElementType<?>, PsiFile>> roots = StubTreeBuilder.getStubbedRoots(viewProvider);
|
||||
|
||||
try {
|
||||
synchronized (myPsiLock) {
|
||||
FileElement treeElementOnLock = getTreeElement();
|
||||
StubTree derefdOnLock = derefStub();
|
||||
if (derefdOnLock != null || treeElementOnLock != null) {
|
||||
return Pair.create(derefdOnLock, treeElementOnLock);
|
||||
StubTree dereferencedOnLock = derefStub();
|
||||
if (dereferencedOnLock != null || treeElementOnLock != null) {
|
||||
return Pair.create(dereferencedOnLock, treeElementOnLock);
|
||||
}
|
||||
|
||||
PsiFileStubImpl<?> baseRoot = (PsiFileStubImpl<?>)((StubTree)tree).getRoot();
|
||||
@@ -773,7 +773,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
|
||||
protected PsiFileImpl cloneImpl(FileElement treeElementClone) {
|
||||
PsiFileImpl clone = (PsiFileImpl)super.clone();
|
||||
clone.setTreeElementPointer(treeElementClone); // should not use setTreeElement here because cloned file still have VirtualFile (SCR17963)
|
||||
clone.setTreeElementPointer(treeElementClone); // should not use setTreeElement here because the cloned file still has VirtualFile (SCR17963)
|
||||
treeElementClone.setPsi(clone);
|
||||
return clone;
|
||||
}
|
||||
@@ -813,7 +813,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
|
||||
@Override
|
||||
public PsiElement @NotNull [] getChildren() {
|
||||
return calcTreeElement().getChildrenAsPsiElements((TokenSet)null, PsiElement.ARRAY_FACTORY);
|
||||
return calcTreeElement().getChildrenAsPsiElements((TokenSet)null, ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
public static final IStubFileElementType TYPE = new IStubFileElementType(Language.ANY);
|
||||
private volatile T myFile;
|
||||
private volatile String myInvalidationReason;
|
||||
private volatile PsiFileStub[] myStubRoots;
|
||||
private volatile PsiFileStub<?>[] myStubRoots;
|
||||
|
||||
public PsiFileStubImpl(T file) {
|
||||
super(null, null);
|
||||
@@ -58,13 +58,13 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull IStubFileElementType getType() {
|
||||
public @NotNull IStubFileElementType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/** Don't call this method, it's public for implementation reasons */
|
||||
@ApiStatus.Internal
|
||||
public PsiFileStub @NotNull [] getStubRoots() {
|
||||
public PsiFileStub<?> @NotNull [] getStubRoots() {
|
||||
if (myStubRoots != null) return myStubRoots;
|
||||
|
||||
T psi = getPsi();
|
||||
@@ -77,18 +77,18 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
|
||||
StubTree baseTree = getOrCalcStubTree(stubBindingRoot);
|
||||
if (baseTree != null) {
|
||||
List<PsiFileStub> roots = new SmartList<>(baseTree.getRoot());
|
||||
List<Pair<IStubFileElementType, PsiFile>> stubbedRoots = StubTreeBuilder.getStubbedRoots(viewProvider);
|
||||
for (Pair<IStubFileElementType, PsiFile> stubbedRoot : stubbedRoots) {
|
||||
List<PsiFileStub<?>> roots = new SmartList<>(baseTree.getRoot());
|
||||
List<Pair<IStubFileElementType<?>, PsiFile>> stubbedRoots = StubTreeBuilder.getStubbedRoots(viewProvider);
|
||||
for (Pair<IStubFileElementType<?>, PsiFile> stubbedRoot : stubbedRoots) {
|
||||
if (stubbedRoot.second == stubBindingRoot) continue;
|
||||
StubTree secondaryStubTree = getOrCalcStubTree(stubbedRoot.second);
|
||||
if (secondaryStubTree != null) {
|
||||
PsiFileStub root = secondaryStubTree.getRoot();
|
||||
PsiFileStub<?> root = secondaryStubTree.getRoot();
|
||||
roots.add(root);
|
||||
}
|
||||
}
|
||||
PsiFileStub[] rootsArray = roots.toArray(PsiFileStub.EMPTY_ARRAY);
|
||||
for (PsiFileStub root : rootsArray) {
|
||||
PsiFileStub<?>[] rootsArray = roots.toArray(EMPTY_ARRAY);
|
||||
for (PsiFileStub<?> root : rootsArray) {
|
||||
if (root instanceof PsiFileStubImpl) {
|
||||
((PsiFileStubImpl<?>)root).setStubRoots(rootsArray);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
myStubRoots = rootsArray;
|
||||
return rootsArray;
|
||||
}
|
||||
return PsiFileStub.EMPTY_ARRAY;
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
private static StubTree getOrCalcStubTree(PsiFile stubBindingRoot) {
|
||||
@@ -111,7 +111,7 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setStubRoots(PsiFileStub @NotNull [] roots) {
|
||||
public void setStubRoots(PsiFileStub<?> @NotNull [] roots) {
|
||||
if (roots.length == 0) {
|
||||
Logger.getInstance(getClass()).error("Incorrect psi file stub roots count" + this + "," + getStubType());
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public final class StubTextInconsistencyException extends RuntimeException imple
|
||||
List<PsiFileStub<?>> fromText = restoreStubsFromText(viewProvider);
|
||||
|
||||
List<PsiFileStub<?>> fromPsi = ContainerUtil
|
||||
.map(StubTreeBuilder.getStubbedRoots(viewProvider), p -> (PsiFileStub<?>)((PsiFileImpl)p.getSecond()).calcStubTree().getRoot());
|
||||
.map(StubTreeBuilder.getStubbedRoots(viewProvider), p -> ((PsiFileImpl)p.getSecond()).calcStubTree().getRoot());
|
||||
|
||||
if (fromPsi.size() != fromText.size()) {
|
||||
reportInconsistency(file, reason, InconsistencyType.DifferentNumberOfPsiTrees);
|
||||
@@ -135,7 +135,6 @@ public final class StubTextInconsistencyException extends RuntimeException imple
|
||||
project);
|
||||
fc.setProject(project);
|
||||
PsiFileStubImpl<?> copyTree = (PsiFileStubImpl<?>)StubTreeBuilder.buildStubTree(fc);
|
||||
//noinspection unchecked
|
||||
return copyTree == null ? Collections.emptyList() : Arrays.asList(copyTree.getStubRoots());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ import java.util.List;
|
||||
public class StubTree extends ObjectStubTree<StubElement<?>> {
|
||||
private final StubSpine mySpine = new StubSpine(this);
|
||||
|
||||
public StubTree(@NotNull PsiFileStub root) {
|
||||
public StubTree(@NotNull PsiFileStub<?> root) {
|
||||
this(root, true);
|
||||
}
|
||||
|
||||
public StubTree(@NotNull PsiFileStub root, boolean withBackReference) {
|
||||
super((ObjectStubBase)root, withBackReference);
|
||||
public StubTree(@NotNull PsiFileStub<?> root, boolean withBackReference) {
|
||||
super((ObjectStubBase<?>)root, withBackReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,15 +29,15 @@ public class StubTree extends ObjectStubTree<StubElement<?>> {
|
||||
|
||||
@Override
|
||||
final @NotNull List<StubElement<?>> getPlainListFromAllRoots() {
|
||||
PsiFileStub[] roots = ((PsiFileStubImpl<?>)getRoot()).getStubRoots();
|
||||
PsiFileStub<?>[] roots = ((PsiFileStubImpl<?>)getRoot()).getStubRoots();
|
||||
if (roots.length == 1) return super.getPlainListFromAllRoots();
|
||||
|
||||
return ContainerUtil.concat(roots, stub -> ((PsiFileStubImpl<?>)stub).myStubList.toPlainList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PsiFileStub getRoot() {
|
||||
return (PsiFileStub)myRoot;
|
||||
public @NotNull PsiFileStub<?> getRoot() {
|
||||
return (PsiFileStub<?>)myRoot;
|
||||
}
|
||||
|
||||
public @NotNull StubbedSpine getSpine() {
|
||||
|
||||
@@ -140,11 +140,11 @@ public final class StubTreeBuilder {
|
||||
LightStubBuilder.FORCED_AST.set(fileContent.getLighterAST());
|
||||
}
|
||||
built = handleStubBuilderException(inputData, stubBuilderType, () -> stubBuilder.buildStubTree(psi));
|
||||
List<Pair<IStubFileElementType, PsiFile>> stubbedRoots = getStubbedRoots(viewProvider);
|
||||
List<Pair<IStubFileElementType<?>, PsiFile>> stubbedRoots = getStubbedRoots(viewProvider);
|
||||
List<PsiFileStub<?>> stubs = new ArrayList<>(stubbedRoots.size());
|
||||
stubs.add((PsiFileStub<?>)built);
|
||||
|
||||
for (Pair<IStubFileElementType, PsiFile> stubbedRoot : stubbedRoots) {
|
||||
for (Pair<IStubFileElementType<?>, PsiFile> stubbedRoot : stubbedRoots) {
|
||||
PsiFile secondaryPsi = stubbedRoot.second;
|
||||
if (psi == secondaryPsi) continue;
|
||||
StubBuilder stubbedRootBuilder = stubbedRoot.first.getBuilder();
|
||||
@@ -185,7 +185,7 @@ public final class StubTreeBuilder {
|
||||
}
|
||||
|
||||
/** Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()} */
|
||||
public static @NotNull List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@NotNull FileViewProvider viewProvider) {
|
||||
public static @NotNull List<Pair<IStubFileElementType<?>, PsiFile>> getStubbedRoots(@NotNull FileViewProvider viewProvider) {
|
||||
List<Trinity<Language, IStubFileElementType<?>, PsiFile>> roots =
|
||||
new SmartList<>();
|
||||
PsiFile stubBindingRoot = viewProvider.getStubBindingRoot();
|
||||
|
||||
@@ -245,9 +245,9 @@ public abstract class StubTreeLoader {
|
||||
|
||||
public static @NonNls String getFileViewProviderMismatchDiagnostics(@NotNull FileViewProvider provider) {
|
||||
Function<PsiFile, String> fileClassName = file -> file.getClass().getSimpleName();
|
||||
Function<Pair<IStubFileElementType, PsiFile>, String> stubRootToString =
|
||||
Function<Pair<IStubFileElementType<?>, PsiFile>, String> stubRootToString =
|
||||
pair -> "(" + pair.first.toString() + ", " + pair.first.getLanguage() + " -> " + fileClassName.fun(pair.second) + ")";
|
||||
List<Pair<IStubFileElementType, PsiFile>> roots = StubTreeBuilder.getStubbedRoots(provider);
|
||||
List<Pair<IStubFileElementType<?>, PsiFile>> roots = StubTreeBuilder.getStubbedRoots(provider);
|
||||
return ", stubBindingRoot = " + fileClassName.fun(provider.getStubBindingRoot()) +
|
||||
", languages = [" + StringUtil.join(provider.getLanguages(), Language::getID, ", ") +
|
||||
"], fileTypes = [" + StringUtil.join(provider.getAllFiles(), file -> file.getFileType().getName(), ", ") +
|
||||
|
||||
@@ -98,7 +98,7 @@ public final class SerializedStubTree {
|
||||
serializationManager.serialize(rootStub, bytes);
|
||||
byte[] treeBytes = bytes.getInternalBuffer();
|
||||
int treeByteLength = bytes.size();
|
||||
ObjectStubBase<?> root = (ObjectStubBase)rootStub;
|
||||
ObjectStubBase<?> root = (ObjectStubBase<?>)rootStub;
|
||||
Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> indexedStubs = indexTree(root);
|
||||
final BufferExposingByteArrayOutputStream indexBytes = new BufferExposingByteArrayOutputStream();
|
||||
forwardIndexExternalizer.save(new DataOutputStream(indexBytes), indexedStubs);
|
||||
@@ -237,7 +237,7 @@ public final class SerializedStubTree {
|
||||
|
||||
static @NotNull Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> indexTree(@NotNull Stub root) {
|
||||
ObjectStubTree<?> objectStubTree = root instanceof PsiFileStub
|
||||
? new StubTree((PsiFileStub)root, false)
|
||||
? new StubTree((PsiFileStub<?>)root, false)
|
||||
: new ObjectStubTree<>((ObjectStubBase<?>)root, false);
|
||||
Map<StubIndexKey<?, ?>, Map<Object, int[]>> map = objectStubTree.indexStubTree(k -> {
|
||||
//noinspection unchecked
|
||||
@@ -245,7 +245,7 @@ public final class SerializedStubTree {
|
||||
});
|
||||
|
||||
// xxx:fix refs inplace
|
||||
for (StubIndexKey key : map.keySet()) {
|
||||
for (StubIndexKey<?, ?> key : map.keySet()) {
|
||||
Map<Object, int[]> value = map.get(key);
|
||||
for (Object k : value.keySet()) {
|
||||
int[] ints = value.get(k);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class GrFileStub extends PsiFileStubImpl<GroovyFile> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IStubFileElementType getType() {
|
||||
public IStubFileElementType<?> getType() {
|
||||
return GroovyParserDefinition.GROOVY_FILE;
|
||||
}
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ public final class PyPsiUtils {
|
||||
Pair<List<PsiComment>, PsiElement> blockAndAnchor = getPrecedingCommentsAndAnchor(anchor, true, false);
|
||||
anchor = blockAndAnchor.getSecond();
|
||||
List<PsiComment> block = blockAndAnchor.getFirst();
|
||||
if (block.size() != 0 || anchor instanceof PsiComment) {
|
||||
if (!block.isEmpty() || anchor instanceof PsiComment) {
|
||||
blocks.add(block);
|
||||
}
|
||||
}
|
||||
@@ -414,7 +414,7 @@ public final class PyPsiUtils {
|
||||
@NotNull Class<T> elementType) {
|
||||
if (stub != null) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
@SuppressWarnings("rawtypes") final List<StubElement> children = stub.getChildrenStubs();
|
||||
final List<StubElement<?>> children = stub.getChildrenStubs();
|
||||
for (StubElement<?> child : children) {
|
||||
PsiElement childPsi = child.getPsi();
|
||||
if (elementType.isInstance(childPsi)) {
|
||||
@@ -428,11 +428,11 @@ public final class PyPsiUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static List<PsiElement> collectAllStubChildren(PsiElement e, StubElement stub) {
|
||||
static List<PsiElement> collectAllStubChildren(PsiElement e, StubElement<?> stub) {
|
||||
if (stub != null) {
|
||||
final List<PsiElement> result = new ArrayList<>();
|
||||
final List<StubElement> children = stub.getChildrenStubs();
|
||||
for (StubElement child : children) {
|
||||
final List<StubElement<?>> children = stub.getChildrenStubs();
|
||||
for (StubElement<?> child : children) {
|
||||
result.add(child.getPsi());
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -310,7 +310,7 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
// filter blank sequences
|
||||
final List<List<PyClassLikeType>> nonBlankSequences = new ArrayList<>(sequences.size());
|
||||
for (List<PyClassLikeType> item : sequences) {
|
||||
if (item.size() > 0) nonBlankSequences.add(item);
|
||||
if (!item.isEmpty()) nonBlankSequences.add(item);
|
||||
}
|
||||
if (nonBlankSequences.isEmpty()) return result;
|
||||
// find a clean head
|
||||
@@ -713,7 +713,7 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
private Property processStubProperties(@Nullable Processor<? super Property> filter) {
|
||||
final PyClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
for (StubElement subStub : stub.getChildrenStubs()) {
|
||||
for (StubElement<?> subStub : stub.getChildrenStubs()) {
|
||||
if (subStub.getStubType() == PyElementTypes.TARGET_EXPRESSION) {
|
||||
final PyTargetExpressionStub targetStub = (PyTargetExpressionStub)subStub;
|
||||
final PropertyStubStorage prop = targetStub.getCustomStub(PropertyStubStorage.class);
|
||||
@@ -1205,8 +1205,8 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
public boolean processClassLevelDeclarations(@NotNull PsiScopeProcessor processor) {
|
||||
final PyClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
final List<StubElement> children = stub.getChildrenStubs();
|
||||
for (StubElement child : children) {
|
||||
final List<StubElement<?>> children = stub.getChildrenStubs();
|
||||
for (StubElement<?> child : children) {
|
||||
if (!processor.execute(child.getPsi(), ResolveState.initial())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
private ExportedNameCache(long modificationStamp) {
|
||||
myModificationStamp = modificationStamp;
|
||||
|
||||
final StubElement stub = getStub();
|
||||
final StubElement<?> stub = getStub();
|
||||
processDeclarations(PyPsiUtils.collectAllStubChildren(PyFileImpl.this, stub), element -> {
|
||||
if (element instanceof PsiNamedElement namedElement &&
|
||||
!(element instanceof PyKeywordArgument) &&
|
||||
|
||||
@@ -73,7 +73,7 @@ public class PyFileStubImpl extends PsiFileStubImpl<PyFile> implements PyFileStu
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IStubFileElementType getType() {
|
||||
return (IStubFileElementType) LanguageParserDefinitions.INSTANCE.forLanguage(PythonLanguage.getInstance()).getFileNodeType();
|
||||
public IStubFileElementType<?> getType() {
|
||||
return (IStubFileElementType<?>) LanguageParserDefinitions.INSTANCE.forLanguage(PythonLanguage.getInstance()).getFileNodeType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiFileEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.stubs.ObjectStubTree;
|
||||
import com.intellij.psi.stubs.Stub;
|
||||
import com.intellij.psi.stubs.StubTreeLoader;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
@@ -47,11 +46,8 @@ public class DomServiceImpl extends DomService {
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile instanceof VirtualFileWithId) {
|
||||
ObjectStubTree<?> tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
|
||||
if (tree != null) {
|
||||
Stub root = tree.getRoot();
|
||||
if (root instanceof FileStub) {
|
||||
return ((FileStub)root).getHeader();
|
||||
}
|
||||
if (tree != null && tree.getRoot() instanceof FileStub fileStub) {
|
||||
return fileStub.getHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class DomStubTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
StubTreeLoader loader = StubTreeLoader.getInstance();
|
||||
VirtualFile file = psiFile.getVirtualFile();
|
||||
assertTrue(loader.canHaveStub(file));
|
||||
ObjectStubTree stubTree = loader.readFromVFile(fixture.getProject(), file);
|
||||
ObjectStubTree<?> stubTree = loader.readFromVFile(fixture.getProject(), file);
|
||||
assertNotNull(stubTree);
|
||||
ElementStub root = (ElementStub)stubTree.getRoot();
|
||||
assertNotNull(root);
|
||||
@@ -102,7 +102,7 @@ public abstract class DomStubTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
assertNotNull(virtualFile);
|
||||
XmlFile file = (XmlFile)((PsiManagerEx)getPsiManager()).getFileManager().findFile(virtualFile);
|
||||
assertFalse(file.getNode().isParsed());
|
||||
ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file);
|
||||
ObjectStubTree<?> tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file);
|
||||
assertNotNull("Can't build stubs for " + path, tree);
|
||||
|
||||
((PsiManagerImpl)getPsiManager()).cleanupForNextTest();
|
||||
|
||||
Reference in New Issue
Block a user