com.intellij.psi.stubs.StubElement Java Examples

The following examples show how to use com.intellij.psi.stubs.StubElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BashIncludeCommandElementType.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: PsiModuleStubElementType.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@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);
}
 
Example #3
Source File: CSharpTypeListElementType.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #4
Source File: CSharpMsilStubIndexer.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@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;
		}
	}
}
 
Example #5
Source File: CSharpTypeStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #6
Source File: CSharpAttributeStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: CSharpReferenceExpressionStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: AtStateStub.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #9
Source File: CSharpUserTypeStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpWithStringValueStub<CSharpUserType> deserialize(@Nonnull StubInputStream stubInputStream,
		StubElement stubElement) throws IOException
{
	StringRef ref = stubInputStream.readName();
	return new CSharpWithStringValueStub<CSharpUserType>(stubElement, this, ref);
}
 
Example #10
Source File: CSharpIndexMethodStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpIndexMethodDeclStub deserialize(@Nonnull StubInputStream inputStream, StubElement stubElement) throws IOException
{
	StringRef qname = inputStream.readName();
	return new CSharpIndexMethodDeclStub(stubElement, StringRef.toString(qname));
}
 
Example #11
Source File: TemplateDefinitionStub.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public TemplateDefinitionStub deserialize(
    @NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  final StringRef ref = dataStream.readName();
  return new TemplateDefinitionStub(parentStub, ref.getString());
}
 
Example #12
Source File: CSharpReferenceExpressionStub.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #13
Source File: NamespaceDeclarationStub.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public NamespaceDeclarationStub deserialize(
    @NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  final StringRef ref = dataStream.readName();
  return new NamespaceDeclarationStub(parentStub, ref.getString());
}
 
Example #14
Source File: CSharpXAccessorStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredReadAction
@Override
public CSharpXXXAccessorStub createStub(@Nonnull DotNetXAccessor accessor, StubElement stubElement)
{
	int otherModifiers = CSharpXXXAccessorStub.getOtherModifiers(accessor);
	return new CSharpXXXAccessorStub(stubElement, otherModifiers);
}
 
Example #15
Source File: CSharpGenericConstraintKeywordValueStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #16
Source File: StubUtils.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #17
Source File: PsiLetStub.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
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;
}
 
Example #18
Source File: CSharpIndexMethodStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Override
public CSharpIndexMethodDeclStub createStub(@Nonnull CSharpIndexMethodDeclaration declaration, StubElement stubElement)
{
	String parentQName = declaration.getPresentableParentQName();
	return new CSharpIndexMethodDeclStub(stubElement, parentQName);
}
 
Example #19
Source File: CSharpIdentifierStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Override
public CSharpIdentifierStub createStub(@Nonnull CSharpIdentifier psi, StubElement parentStub)
{
	String value = psi.getValue();
	return new CSharpIdentifierStub(parentStub, this, value);
}
 
Example #20
Source File: CSharpXAccessorStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpXXXAccessorStub deserialize(@Nonnull StubInputStream inputStream, StubElement stubElement) throws IOException
{
	int otherModifiers = inputStream.readVarInt();
	return new CSharpXXXAccessorStub(stubElement, otherModifiers);
}
 
Example #21
Source File: CSharpConstructorStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpMethodDeclStub deserialize(@Nonnull StubInputStream stubInputStream, StubElement stubElement) throws IOException
{
	StringRef qname = stubInputStream.readName();
	int otherModifierMask = stubInputStream.readVarInt();
	return new CSharpMethodDeclStub(stubElement, this, StringRef.toString(qname), otherModifierMask, -1);
}
 
Example #22
Source File: CSharpModifierListStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpModifierListStub deserialize(@Nonnull StubInputStream stubInputStream, StubElement stubElement) throws IOException
{
	int modifierMask = stubInputStream.readVarInt();
	return new CSharpModifierListStub(stubElement, this, modifierMask);
}
 
Example #23
Source File: DataTypeStub.java    From protobuf-jetbrains-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public S deserialize(@NotNull StubInputStream dataStream, StubElement parentStub)
        throws IOException {
    return createStub(parentStub, dataStream.readName().getString(),
            dataStream.readName().getString());
}
 
Example #24
Source File: BashSimpleCommandElementType.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
public BashCommandStub createStub(@NotNull BashCommand psi, StubElement parentStub) {
    String filename = null;

    String commandName = psi.getReferencedCommandName();
    if (commandName != null) {
        filename = PathUtilRt.getFileName(commandName);
    }

    return new BashCommandStubImpl(parentStub, filename, BashElementTypes.SIMPLE_COMMAND_ELEMENT, psi.isInternalCommand(false), psi.isInternalCommand(true), psi.isGenericCommand());
}
 
Example #25
Source File: CSharpTypeStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpTypeDeclStub deserialize(@Nonnull StubInputStream stubInputStream, StubElement stubElement) throws IOException
{
	StringRef parentQName = stubInputStream.readName();
	StringRef vmQName = stubInputStream.readName();
	int otherModifierMask = stubInputStream.readVarInt();
	return new CSharpTypeDeclStub(stubElement, StringRef.toString(parentQName), StringRef.toString(vmQName), otherModifierMask);
}
 
Example #26
Source File: CSharpGenericConstraintStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public CSharpWithStringValueStub<CSharpGenericConstraint> createStub(@Nonnull CSharpGenericConstraint constraint, StubElement stubElement)
{
	CSharpReferenceExpression genericParameterReference = constraint.getGenericParameterReference();
	String text = genericParameterReference == null ? null : genericParameterReference.getText();
	return new CSharpWithStringValueStub<CSharpGenericConstraint>(stubElement, this, text);
}
 
Example #27
Source File: CSharpGenericConstraintStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpWithStringValueStub<CSharpGenericConstraint> deserialize(@Nonnull StubInputStream inputStream,
		StubElement stubElement) throws IOException
{
	StringRef text = inputStream.readName();
	return new CSharpWithStringValueStub<CSharpGenericConstraint>(stubElement, this, text);
}
 
Example #28
Source File: ShaderLabFile.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nullable
public ShaderDef getShaderDef()
{
	StubElement<?> stub = getStub();
	if(stub != null)
	{
		StubElement<ShaderDef> childStubByType = stub.findChildStubByType(ShaderLabStubElements.SHADER_DEF);
		if(childStubByType != null)
		{
			return childStubByType.getPsi();
		}
	}
	return findChildByClass(ShaderDef.class);
}
 
Example #29
Source File: CSharpAttributeListStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpAttributeListStub createStub(@Nonnull CSharpAttributeList attributeList, StubElement stubElement)
{
	DotNetAttributeTargetType targetType = attributeList.getTargetType();
	return new CSharpAttributeListStub(stubElement, this, targetType);
}
 
Example #30
Source File: CSharpAttributeStubElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CSharpWithStringValueStub<CSharpAttribute> deserialize(@Nonnull StubInputStream stubInputStream,
		StubElement stubElement) throws IOException
{
	StringRef referenceText = stubInputStream.readName();
	return new CSharpWithStringValueStub<CSharpAttribute>(stubElement, this, referenceText);
}