Java 类com.intellij.psi.stubs.PsiClassHolderFileStub 实例源码

项目:consulo-java    文件:ClsFileImpl.java   
@Override
public PsiPackageStatement getPackageStatement()
{
    ClsPackageStatementImpl statement = myPackageStatement;
    if(statement == null)
    {
        statement = ClsPackageStatementImpl.NULL_PACKAGE;
        PsiClassHolderFileStub<?> stub = getStub();
        if(!(stub instanceof PsiJavaFileStub) || stub.findChildStubByType(JavaStubElementTypes.MODULE) == null)
        {
            String packageName = findPackageName(stub);
            if(packageName != null)
            {
                statement = new ClsPackageStatementImpl(this, packageName);
            }
        }
        myPackageStatement = statement;
    }
    return statement != ClsPackageStatementImpl.NULL_PACKAGE ? statement : null;
}
项目:consulo-java    文件:ClsFileImpl.java   
private static String findPackageName(PsiClassHolderFileStub<?> stub)
{
    String packageName = null;

    if(stub instanceof PsiJavaFileStub)
    {
        packageName = ((PsiJavaFileStub) stub).getPackageName();
    }
    else
    {
        PsiClass[] psiClasses = stub.getClasses();
        if(psiClasses.length > 0)
        {
            String className = psiClasses[0].getQualifiedName();
            if(className != null)
            {
                int index = className.lastIndexOf('.');
                if(index >= 0)
                {
                    packageName = className.substring(0, index);
                }
            }
        }
    }

    return !StringUtil.isEmpty(packageName) ? packageName : null;
}
项目:consulo-java    文件:ClsFileImpl.java   
@Override
@NotNull
public LanguageLevel getLanguageLevel()
{
    PsiClassHolderFileStub<?> stub = getStub();
    if(stub instanceof PsiJavaFileStub)
    {
        LanguageLevel level = ((PsiJavaFileStub) stub).getLanguageLevel();
        if(level != null)
        {
            return level;
        }
    }
    return LanguageLevel.HIGHEST;
}
项目:consulo-java    文件:ClsFileImpl.java   
@Nullable
@Override
public PsiJavaModule getModuleDeclaration()
{
    PsiClassHolderFileStub<?> stub = getStub();
    return stub instanceof PsiJavaFileStub ? ((PsiJavaFileStub) stub).getModule() : null;
}
项目:consulo-java    文件:ClsFileImpl.java   
@Override
@NotNull
public PsiClassHolderFileStub<?> getStub()
{
    return (PsiClassHolderFileStub) getStubTree().getRoot();
}