下面列出了com.intellij.psi.PsiInvalidElementAccessException#com.intellij.psi.stubs.StubElement 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@RequiredReadAction
@Override
public CSharpTypeListStub createStub(@Nonnull DotNetTypeList dotNetTypeList, StubElement stubElement)
{
DotNetType[] types = dotNetTypeList.getTypes();
List<String> typeRefs = new ArrayList<>(types.length);
for(DotNetType type : types)
{
if(type instanceof CSharpUserType)
{
ContainerUtil.addIfNotNull(typeRefs, ((CSharpUserType) type).getReferenceExpression().getReferenceName());
}
}
return new CSharpTypeListStub(stubElement, this, ArrayUtil.toStringArray(typeRefs));
}
@NotNull
public PsiModuleStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
StringRef moduleName = dataStream.readName();
String path = dataStream.readUTFFast();
boolean isComponent = dataStream.readBoolean();
boolean isInterface = dataStream.readBoolean();
assert moduleName != null;
String alias = null;
boolean isAlias = dataStream.readBoolean();
if (isAlias) {
alias = dataStream.readUTFFast();
}
return new PsiModuleStub(parentStub, this, moduleName, path, alias, isComponent, isInterface);
}
@Override
public void indexClass(@Nonnull MsilClassEntryStub stub, @Nonnull IndexSink indexSink)
{
String name = stub.getName();
if(StringUtil.isEmpty(name))
{
return;
}
if(stub.isNested())
{
return;
}
List<StubElement> childrenStubs = stub.getChildrenStubs();
for(StubElement childrenStub : childrenStubs)
{
if(childrenStub instanceof MsilCustomAttributeStub && Comparing.equal(((MsilCustomAttributeStub) childrenStub).getTypeRef(), DotNetTypes.System.Runtime.CompilerServices
.ExtensionAttribute))
{
indexSink.occurrence(CSharpIndexKeys.TYPE_WITH_EXTENSION_METHODS_INDEX, DotNetNamespaceStubUtil.getIndexableNamespace(stub.getNamespace()));
break;
}
}
}
public BashIncludeCommandStub createStub(@NotNull BashIncludeCommand psi, StubElement parentStub) {
BashFileReference fileReference = psi.getFileReference();
String filename = null;
String includer = null;
if (fileReference != null && fileReference.isStatic()) {
filename = fileReference.getFilename();
if (filename.contains("/") && !filename.endsWith("/")) {
int index = filename.lastIndexOf("/");
filename = filename.substring(index + 1);
}
VirtualFile virtualFile = psi.getContainingFile().getUserData(IndexingDataKeys.VIRTUAL_FILE);
if (virtualFile == null) {
virtualFile = psi.getContainingFile().getViewProvider().getVirtualFile();
}
includer = virtualFile.getPath();
}
return new BashIncludeCommandStubImpl(parentStub, StringRef.fromString(filename), StringRef.fromString(includer), BashElementTypes.INCLUDE_COMMAND_ELEMENT);
}
@NotNull
@Override
public StubBuilder getBuilder() {
return new DefaultStubBuilder() {
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file) {
if (file instanceof NASMFile) {
return new NASMFileStub((NASMFile)file);
}
return super.createStubForFile(file);
}
};
}
public PsiLetStub(StubElement parent, @NotNull IStubElementType elementType, String name, String qname, String alias, boolean isFunction, List<String> deconstructionNames) {
super(parent, elementType, name);
m_qname = qname;
m_alias = alias;
m_isFunction = isFunction;
m_deconstructionNames = deconstructionNames;
}
@RequiredReadAction
@Override
public CSharpReferenceExpressionStub createStub(@Nonnull CSharpReferenceExpression psi, StubElement parentStub)
{
String referenceName = psi.getReferenceNameWithAt();
CSharpReferenceExpression.ResolveToKind kind = psi.kind();
boolean global = psi.isGlobalElement();
CSharpReferenceExpression.AccessType memberAccessType = psi.getMemberAccessType();
return new CSharpReferenceExpressionStub(parentStub, this, referenceName, kind.ordinal(), memberAccessType.ordinal(), global);
}
@Nonnull
@Override
public CSharpReferenceExpressionStub deserialize(@Nonnull StubInputStream dataStream, StubElement parentStub) throws IOException
{
StringRef referenceText = dataStream.readName();
int kind = dataStream.readVarInt();
int memberAccessType = dataStream.readVarInt();
boolean global = dataStream.readBoolean();
return new CSharpReferenceExpressionStub(parentStub, this, StringRef.toString(referenceText), kind, memberAccessType, global);
}
@Override
public boolean isValid() {
StubElement parent = myStub.getParentStub();
if (parent == null) {
LOG.error("No parent for stub " + myStub + " of class " + myStub.getClass());
return false;
}
PsiElement psi = parent.getPsi();
return psi != null && psi.isValid();
}
@Override
public void indexMethod(@Nonnull MsilMethodEntryStub stub, @Nonnull IndexSink indexSink)
{
List<StubElement> childrenStubs = stub.getChildrenStubs();
for(StubElement childrenStub : childrenStubs)
{
if(childrenStub instanceof MsilCustomAttributeStub && Comparing.equal(((MsilCustomAttributeStub) childrenStub).getTypeRef(), DotNetTypes.System.Runtime.CompilerServices
.ExtensionAttribute))
{
indexSink.occurrence(CSharpIndexKeys.EXTENSION_METHOD_BY_NAME_INDEX, stub.getNameFromBytecode());
break;
}
}
}
public PsiModuleStub(StubElement parent, @NotNull IStubElementType elementType, @Nullable StringRef name, @Nullable String path, String alias,
boolean isComponent, boolean isInterface) {
super(parent, elementType, name);
m_path = path;
m_qname = path == null || path.length() == 0 ? "" + name : path + "." + name;
m_alias = alias;
m_isComponent = isComponent;
m_isInterface = isInterface;
}
public static int calcStubIndex(@Nonnull StubBasedPsiElement psi) {
if (psi instanceof PsiFile) {
return 0;
}
StubElement liveStub = psi instanceof StubBasedPsiElementBase ? ((StubBasedPsiElementBase)psi).getGreenStub() : psi.getStub();
if (liveStub != null) {
return ((StubBase)liveStub).getStubId();
}
return ((PsiFileImpl)psi.getContainingFile()).calcTreeElement().getStubbedSpine().getStubIndex(psi);
}
@RequiredReadAction
@Override
public CSharpModifierListStub createStub(@Nonnull DotNetModifierList modifierList, StubElement stubElement)
{
int modifierMask = CSharpModifierListStub.getModifierMask(modifierList);
return new CSharpModifierListStub(stubElement, this, modifierMask);
}
@Override
public StubBuilder getBuilder()
{
return new DefaultStubBuilder()
{
@Nonnull
@Override
protected StubElement createStubForFile(@Nonnull PsiFile file)
{
if(file instanceof CSharpFileImpl)
{
return new CSharpFileStub((CSharpFileImpl) file);
}
return super.createStubForFile(file);
}
@Override
public boolean skipChildProcessingWhenBuildingStubs(@Nonnull ASTNode parent, @Nonnull ASTNode node)
{
// skip any lazy parseable elements, like preprocessors or code blocks etc
if(node.getElementType() instanceof ILazyParseableElementType)
{
return true;
}
return false;
}
};
}
@Override
public CSharpWithStringValueStub<CSharpAttribute> createStub(@Nonnull CSharpAttribute attribute, StubElement stubElement)
{
CSharpReferenceExpression referenceExpression = attribute.getReferenceExpression();
String referenceText = referenceExpression == null ? null : referenceExpression.getText();
return new CSharpWithStringValueStub<CSharpAttribute>(stubElement, this, referenceText);
}
@Nonnull
@RequiredReadAction
@Override
public CSharpMethodDeclStub createStub(@Nonnull CSharpMethodDeclaration methodDeclaration, StubElement stubElement)
{
String parentQName = methodDeclaration.getPresentableParentQName();
int otherModifierMask = CSharpMethodDeclStub.getOtherModifierMask(methodDeclaration);
int operatorIndex = CSharpMethodDeclStub.getOperatorIndex(methodDeclaration);
return new CSharpMethodDeclStub(stubElement, parentQName, otherModifierMask, operatorIndex);
}
@Nullable
@RequiredReadAction
public static String getName(StubElement<?> element)
{
CSharpIdentifierStub identifierStub = element.findChildStubByType(CSharpStubElements.IDENTIFIER);
if(identifierStub == null)
{
return null;
}
return identifierStub.getValue();
}
@RequiredReadAction
@Override
public CSharpMethodDeclStub createStub(@Nonnull CSharpConstructorDeclarationImpl methodDeclaration, StubElement stubElement)
{
String qname = methodDeclaration.getPresentableParentQName();
int otherModifierMask = CSharpMethodDeclStub.getOtherModifierMask(methodDeclaration);
return new CSharpMethodDeclStub(stubElement, this, qname, otherModifierMask, -1);
}
@NotNull
@Override
public AtStateStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub)
throws IOException {
final StringRef ref = dataStream.readName();
final StringRef ref2 = dataStream.readName();
return new AtStateStub(
parentStub, ref.getString(), ref2.getString());
}
@Nonnull
@Override
public CSharpWithStringValueStub<CSharpUserType> deserialize(@Nonnull StubInputStream stubInputStream,
StubElement stubElement) throws IOException
{
StringRef ref = stubInputStream.readName();
return new CSharpWithStringValueStub<CSharpUserType>(stubElement, this, ref);
}
@Nonnull
@Override
public CSharpIndexMethodDeclStub deserialize(@Nonnull StubInputStream inputStream, StubElement stubElement) throws IOException
{
StringRef qname = inputStream.readName();
return new CSharpIndexMethodDeclStub(stubElement, StringRef.toString(qname));
}
@NotNull
@Override
public TemplateDefinitionStub deserialize(
@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
final StringRef ref = dataStream.readName();
return new TemplateDefinitionStub(parentStub, ref.getString());
}
public CSharpReferenceExpressionStub(StubElement parent, IStubElementType elementType, String referenceText, int kindIndex, int memberAccessType, boolean global)
{
super(parent, elementType);
myGlobal = global;
myReferenceText = referenceText;
myKindIndex = kindIndex;
myMemberAccessTypeIndex = memberAccessType;
}
@NotNull
@Override
public NamespaceDeclarationStub deserialize(
@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
final StringRef ref = dataStream.readName();
return new NamespaceDeclarationStub(parentStub, ref.getString());
}
@Nonnull
@RequiredReadAction
@Override
public CSharpXXXAccessorStub createStub(@Nonnull DotNetXAccessor accessor, StubElement stubElement)
{
int otherModifiers = CSharpXXXAccessorStub.getOtherModifiers(accessor);
return new CSharpXXXAccessorStub(stubElement, otherModifiers);
}
@Override
public CSharpWithIntValueStub<CSharpGenericConstraintKeywordValue> createStub(@Nonnull CSharpGenericConstraintKeywordValue keywordValue,
StubElement stubElement)
{
int index = ArrayUtil.indexOf(CSharpGenericConstraintKeywordValue.KEYWORDS_AS_ARRAY, keywordValue.getKeywordElementType());
assert index != -1;
return new CSharpWithIntValueStub<CSharpGenericConstraintKeywordValue>(stubElement, this, index);
}
public static FileStub getContainingStubFile(StubElement e) {
StubElement parent = e.getParentStub();
while (parent != null) {
if (parent instanceof FileStub) {
return (FileStub) parent;
}
parent = parent.getParentStub();
}
return null;
}
@RequiredReadAction
@Override
public CSharpTypeDeclStub createStub(@Nonnull CSharpTypeDeclaration typeDeclaration, StubElement stubElement)
{
String parentQName = typeDeclaration.getPresentableParentQName();
String vmQName = typeDeclaration.getVmQName();
int otherModifierMask = CSharpTypeDeclStub.getOtherModifiers(typeDeclaration);
return new CSharpTypeDeclStub(stubElement, parentQName, vmQName, otherModifierMask);
}
@RequiredReadAction
@Override
public CSharpIndexMethodDeclStub createStub(@Nonnull CSharpIndexMethodDeclaration declaration, StubElement stubElement)
{
String parentQName = declaration.getPresentableParentQName();
return new CSharpIndexMethodDeclStub(stubElement, parentQName);
}
@RequiredReadAction
@Override
public CSharpIdentifierStub createStub(@Nonnull CSharpIdentifier psi, StubElement parentStub)
{
String value = psi.getValue();
return new CSharpIdentifierStub(parentStub, this, value);
}