本文整理汇总了Java中com.intellij.psi.stubs.PsiFileStub类的典型用法代码示例。如果您正苦于以下问题:Java PsiFileStub类的具体用法?Java PsiFileStub怎么用?Java PsiFileStub使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiFileStub类属于com.intellij.psi.stubs包,在下文中一共展示了PsiFileStub类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitInnerClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitInnerClass(final String name, final String outerName, final String innerName, final int access) {
if ((access & Opcodes.ACC_SYNTHETIC) != 0) return;
if (!isCorrectName(innerName) || outerName == null) return;
if ((getClassName(outerName) + "." + innerName).equals(myResult.getQualifiedName())) {
// our result is inner class
if (myParent instanceof PsiFileStub) {
throw new OutOfOrderInnerClassException();
}
}
if (!namesEqual(outerName, myResult.getQualifiedName())) {
return;
}
T innerClass = myInnersStrategy.findInnerClass(innerName, mySource);
if (innerClass != null) {
StubBuildingVisitor<T> visitor = new StubBuildingVisitor<T>(innerClass, myInnersStrategy, myResult, access, innerName);
myInnersStrategy.accept(innerClass, visitor);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:StubBuildingVisitor.java
示例2: isAnonymousOrLocal
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
private static boolean isAnonymousOrLocal(PsiClass aClass) {
if (aClass instanceof PsiAnonymousClass) return true;
final PsiClassStub stub = ((PsiClassImpl)aClass).getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
return !(parentStub instanceof PsiClassStub || parentStub instanceof PsiFileStub);
}
PsiElement parent = aClass.getParent();
while (parent != null) {
if (parent instanceof PsiMethod || parent instanceof PsiField || parent instanceof PsiClassInitializer) return true;
if (parent instanceof PsiClass || parent instanceof PsiFile) return false;
parent = parent.getParent();
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiClassImpl.java
示例3: visitInnerClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitInnerClass(final String name, final String outerName, final String innerName, final int access) {
if ((access & Opcodes.ACC_SYNTHETIC) != 0) return;
if (!isCorrectName(innerName)) return;
if (innerName == null || outerName == null) return;
if ((getClassName(outerName) + "." + innerName).equals(myResult.getQualifiedName())) {
// Our result is inner class
if (myParent instanceof PsiFileStub) {
throw new OutOfOrderInnerClassException();
}
}
if (!getClassName(outerName).equals(myResult.getQualifiedName())) return;
final T innerSource = myInnersStrategy.findInnerClass(innerName, mySource);
if (innerSource == null) return;
final ClassReader reader = myInnersStrategy.readerForInnerClass(innerSource);
if (reader == null) return;
final StubBuildingVisitor<T> classVisitor = new StubBuildingVisitor<T>(innerSource, myInnersStrategy, myResult, access);
reader.accept(classVisitor, ClassReader.SKIP_FRAMES);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:StubBuildingVisitor.java
示例4: buildStubTree
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public StubElement buildStubTree(FileContent fileContent) {
try {
VirtualFile file = fileContent.getFile();
Project project = fileContent.getProject();
byte[] content = fileContent.getContent();
final ClsStubBuilderFactory[] factories = Extensions.getExtensions(ClsStubBuilderFactory.EP_NAME);
for (ClsStubBuilderFactory factory : factories) {
if (!factory.isInnerClass(file) && factory.canBeProcessed(file, content)) {
PsiFileStub stub = factory.buildFileStub(file, content, project);
if (stub != null) return stub;
}
}
if (!fileContent.getFileName().contains("$")) {
LOG.info("No stub built for file " + fileContent);
}
return null;
}
catch (ClsFormatException e) {
return null;
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:ClassFileStubBuilder.java
示例5: visitInnerClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access)
{
if(isSet(access, Opcodes.ACC_SYNTHETIC))
{
return;
}
if(innerName == null || outerName == null)
{
return;
}
if(myParent instanceof PsiFileStub && myInternalName.equals(name))
{
throw new OutOfOrderInnerClassException(); // our result is inner class
}
if(myInternalName.equals(outerName))
{
T innerClass = myInnersStrategy.findInnerClass(innerName, mySource);
if(innerClass != null)
{
myInnersStrategy.accept(innerClass, new StubBuildingVisitor<>(innerClass, myInnersStrategy, myResult, access, innerName));
}
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:StubBuildingVisitor.java
示例6: getFileStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
private PsiJavaFileStub getFileStub(StubT stub) {
StubElement parent = stub;
while (!(parent instanceof PsiFileStub)) {
parent = parent.getParentStub();
}
return (PsiJavaFileStub)parent;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaStubElementType.java
示例7: getContainingFile
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public PsiFile getContainingFile() {
StubElement p = myStub;
while (!(p instanceof PsiFileStub)) {
p = p.getParentStub();
}
return (PsiFile)p.getPsi();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ClsRepositoryPsiElement.java
示例8: getParent
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public PsiElement getParent() {
final PsiClassStub stub = getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
if (parentStub instanceof PsiFileStub || parentStub instanceof PsiClassStub
) {
return parentStub.getPsi();
}
}
return SharedImplUtil.getParent(getNode());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PsiClassImpl.java
示例9: getContainingFile
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Nonnull
@Override
public PsiFile getContainingFile() {
StubElement stub = myStub;
while (!(stub instanceof PsiFileStub)) {
stub = stub.getParentStub();
}
PsiFile psi = (PsiFile)stub.getPsi();
if (psi != null) {
return psi;
}
return reportError(stub);
}
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:SubstrateRef.java
示例10: visitOuterClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitOuterClass(String owner, String name, String desc)
{
if(myParent instanceof PsiFileStub)
{
throw new OutOfOrderInnerClassException();
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:StubBuildingVisitor.java
示例11: isAnonymousOrLocal
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
private static boolean isAnonymousOrLocal(PsiClass aClass)
{
if(aClass instanceof PsiAnonymousClass)
{
return true;
}
final PsiClassStub stub = ((PsiClassImpl) aClass).getGreenStub();
if(stub != null)
{
final StubElement parentStub = stub.getParentStub();
return !(parentStub instanceof PsiClassStub || parentStub instanceof PsiFileStub);
}
PsiElement parent = aClass.getParent();
while(parent != null)
{
if(parent instanceof PsiMethod || parent instanceof PsiField || parent instanceof PsiClassInitializer)
{
return true;
}
if(parent instanceof PsiClass || parent instanceof PsiFile)
{
return false;
}
parent = parent.getParent();
}
return false;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:PsiClassImpl.java
示例12: buildFileStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
public PsiFileStub<T> buildFileStub(final VirtualFile file, byte[] bytes, Project project) throws ClsFormatException {
return buildFileStub(file, bytes);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ClsStubBuilderFactory.java
示例13: visitOuterClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitOuterClass(final String owner, final String name, final String desc) {
if (myParent instanceof PsiFileStub) {
throw new OutOfOrderInnerClassException();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:StubBuildingVisitor.java
示例14: packModifierList
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
public static int packModifierList(@NotNull LighterAST tree, @NotNull LighterASTNode modList, @NotNull StubElement parent) {
int packed = 0;
final LighterASTNode modListOwner = tree.getParent(modList);
if (modListOwner != null && modListOwner.getTokenType() == parent.getStubType()) {
final StubElement grandParent = parent.getParentStub();
if (parent instanceof PsiClassStub) {
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.STATIC_MASK;
}
if (((PsiClassStub)parent).isInterface()) {
packed |= ModifierFlags.ABSTRACT_MASK;
if (grandParent instanceof PsiClassStub) {
packed |= ModifierFlags.STATIC_MASK;
}
}
else if (((PsiClassStub)parent).isEnum()) {
if (!(grandParent instanceof PsiFileStub)) {
packed |= ModifierFlags.STATIC_MASK;
}
boolean isFinal = true;
final List<LighterASTNode> enumConstants = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.ENUM_CONSTANT);
for (final LighterASTNode constant : enumConstants) {
if (LightTreeUtil.firstChildOfType(tree, constant, JavaElementType.ENUM_CONSTANT_INITIALIZER) != null) {
isFinal = false;
break;
}
}
if (isFinal) {
packed |= ModifierFlags.FINAL_MASK;
}
final List<LighterASTNode> methods = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.METHOD);
for (final LighterASTNode method : methods) {
final LighterASTNode mods = LightTreeUtil.requiredChildOfType(tree, method, JavaElementType.MODIFIER_LIST);
if (LightTreeUtil.firstChildOfType(tree, mods, JavaTokenType.ABSTRACT_KEYWORD) != null) {
packed |= ModifierFlags.ABSTRACT_MASK;
break;
}
}
}
}
else if (parent instanceof PsiMethodStub) {
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.ABSTRACT_MASK;
}
}
else if (parent instanceof PsiFieldStub) {
if (parent.getStubType() == JavaElementType.ENUM_CONSTANT ||
grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.STATIC_MASK;
packed |= ModifierFlags.FINAL_MASK;
}
}
}
for (final LighterASTNode child : tree.getChildren(modList)) {
final int flag = ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.get(child.getTokenType());
if (flag != 0) {
packed |= flag;
}
}
if ((packed & ModifierFlags.DEFENDER_MASK) != 0) {
packed &= ~ModifierFlags.ABSTRACT_MASK;
}
if ((packed & (ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK | ModifierFlags.PUBLIC_MASK)) == 0) {
packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
}
return packed;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:78,代码来源:RecordUtil.java
示例15: reason
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@NonNls
@NotNull
private static String reason(@NotNull PsiElement root) {
if (root == PsiUtilCore.NULL_PSI_ELEMENT) return "NULL_PSI_ELEMENT";
PsiElement element = root instanceof PsiFile ? root : root.getParent();
if (element == null) {
String m = "parent is null";
if (root instanceof StubBasedPsiElement) {
StubElement stub = ((StubBasedPsiElement)root).getStub();
while (stub != null) {
m += "\n each stub=" + stub;
if (stub instanceof PsiFileStub) {
m += "; fileStub.psi=" + stub.getPsi() + "; reason=" + ((PsiFileStub)stub).getInvalidationReason();
}
stub = stub.getParentStub();
}
}
return m;
}
while (element != null && !(element instanceof PsiFile)) element = element.getParent();
PsiFile file = (PsiFile)element;
if (file == null) return "containing file is null";
FileViewProvider provider = file.getViewProvider();
VirtualFile vFile = provider.getVirtualFile();
if (!vFile.isValid()) return vFile + " is invalid";
if (!provider.isPhysical()) {
PsiElement context = file.getContext();
if (context != null && !context.isValid()) {
return "invalid context: " + reason(context);
}
}
PsiManager manager = file.getManager();
if (manager.getProject().isDisposed()) return "project is disposed";
Language language = file.getLanguage();
if (language != provider.getBaseLanguage()) return "File language:" + language + " != Provider base language:" + provider.getBaseLanguage();
FileViewProvider p = manager.findViewProvider(vFile);
if (provider != p) return "different providers: " + provider + "(" + id(provider) + "); " + p + "(" + id(p) + ")";
if (!provider.isPhysical()) return "non-physical provider: " + provider; // "dummy" file?
return "psi is outdated";
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:PsiInvalidElementAccessException.java
示例16: buildFileStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Nullable
public abstract PsiFileStub<T> buildFileStub(final VirtualFile file, byte[] bytes) throws ClsFormatException;
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:3,代码来源:ClsStubBuilderFactory.java
示例17: visitMethod
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
@Nullable
public MethodVisitor visitMethod(final int access,
final String name,
final String desc,
final String signature,
final String[] exceptions) {
// JLS 13.1 says: Any constructs introduced by the compiler that do not have a corresponding construct in the source code
// must be marked as synthetic, except for default constructors and the class initialization method.
// However Scala compiler erroneously generates ACC_BRIDGE instead of ACC_SYNTHETIC flag for in-trait implementation delegation.
// See IDEA-78649
if ((access & Opcodes.ACC_SYNTHETIC) != 0) return null;
if (SYNTHETIC_CLASS_INIT_METHOD.equals(name)) return null;
boolean isDeprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
boolean isConstructor = SYNTHETIC_INIT_METHOD.equals(name);
boolean isVarargs = (access & Opcodes.ACC_VARARGS) != 0;
boolean isAnnotationMethod = myResult.isAnnotationType();
if (!isConstructor && !isCorrectName(name)) return null;
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false);
final String canonicalMethodName = isConstructor ? myResult.getName() : name;
final List<String> args = new ArrayList<String>();
final List<String> throwables = exceptions != null ? new ArrayList<String>() : null;
final PsiMethodStubImpl stub = new PsiMethodStubImpl(myResult, StringRef.fromString(canonicalMethodName), flags, null);
final PsiModifierListStub modList = new PsiModifierListStubImpl(stub, packMethodFlags(access, myResult.isInterface()));
boolean parsedViaGenericSignature = false;
String returnType;
if (signature == null) {
returnType = parseMethodViaDescription(desc, stub, args);
}
else {
try {
returnType = parseMethodViaGenericSignature(signature, stub, args, throwables);
parsedViaGenericSignature = true;
}
catch (ClsFormatException e) {
returnType = parseMethodViaDescription(desc, stub, args);
}
}
stub.setReturnType(TypeInfo.fromString(returnType));
final boolean isNonStaticInnerClassConstructor =
isConstructor && !(myParent instanceof PsiFileStub) && (myModList.getModifiersMask() & Opcodes.ACC_STATIC) == 0;
final boolean shouldSkipFirstParamForNonStaticInnerClassConstructor = !parsedViaGenericSignature && isNonStaticInnerClassConstructor;
final PsiParameterListStubImpl parameterList = new PsiParameterListStubImpl(stub);
final int paramCount = args.size();
final PsiParameterStubImpl[] paramStubs = new PsiParameterStubImpl[paramCount];
for (int i = 0; i < paramCount; i++) {
if (shouldSkipFirstParamForNonStaticInnerClassConstructor && i == 0) continue;
String arg = args.get(i);
boolean isEllipsisParam = isVarargs && i == paramCount - 1;
final TypeInfo typeInfo = TypeInfo.fromString(arg, isEllipsisParam);
String paramName = i < parameterNames.length ? parameterNames[i] : "p" + (i + 1);
PsiParameterStubImpl parameterStub = new PsiParameterStubImpl(parameterList, paramName, typeInfo, isEllipsisParam);
paramStubs [i] = parameterStub;
new PsiModifierListStubImpl(parameterStub, 0);
}
String[] thrownTypes = buildThrowsList(exceptions, throwables, parsedViaGenericSignature);
newReferenceList(JavaStubElementTypes.THROWS_LIST, stub, thrownTypes);
final int localVarIgnoreCount = (access & Opcodes.ACC_STATIC) != 0 ? 0 : isConstructor && myResult.isEnum() ? 3 : 1;
final int paramIgnoreCount = isConstructor && myResult.isEnum() ? 2 : isNonStaticInnerClassConstructor ? 1 : 0;
return new AnnotationParamCollectingVisitor(stub, modList, localVarIgnoreCount, paramIgnoreCount, paramCount, paramStubs);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:77,代码来源:StubBuildingVisitor.java
示例18: createStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public PsiClassStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub)
{
String qualifiedName = null;
String name = null;
if(parentStub instanceof PsiFileStub)
{
PsiElement psi = parentStub.getPsi();
if(psi instanceof PsiFile)
{
name = JspClassImpl.buildName((PsiFile) psi);
}
}
if(name != null)
{
if(parentStub instanceof PsiJavaFileStub)
{
final String pkg = ((PsiJavaFileStub) parentStub).getPackageName();
if(!pkg.isEmpty())
{
qualifiedName = pkg + '.' + name;
}
else
{
qualifiedName = name;
}
}
else if(parentStub instanceof PsiClassStub)
{
final String parentFqn = ((PsiClassStub) parentStub).getQualifiedName();
qualifiedName = parentFqn != null ? parentFqn + '.' + name : null;
}
else if(parentStub instanceof PsiClassLevelDeclarationStatementStub)
{
StubElement parent = parentStub;
while(parent != null)
{
if(parent instanceof PsiClassStub)
{
qualifiedName = ((PsiClassStub) parent).getQualifiedName();
break;
}
parent = parent.getParentStub();
}
}
}
return new PsiClassStubImpl(this, parentStub, qualifiedName, name, null, (byte) 0);
}
开发者ID:consulo,项目名称:consulo-javaee,代码行数:52,代码来源:JspClassStubElementType.java
示例19: reason
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@NonNls
@Nonnull
private static String reason(@Nonnull PsiElement root) {
if (root == PsiUtilCore.NULL_PSI_ELEMENT) return "NULL_PSI_ELEMENT";
PsiElement element = root instanceof PsiFile ? root : root.getParent();
if (element == null) {
String m = "parent is null";
if (root instanceof StubBasedPsiElement) {
StubElement stub = ((StubBasedPsiElement)root).getStub();
while (stub != null) {
m += "\n each stub=" + stub;
if (stub instanceof PsiFileStub) {
m += "; fileStub.psi=" + stub.getPsi() + "; reason=" + ((PsiFileStub)stub).getInvalidationReason();
}
stub = stub.getParentStub();
}
}
return m;
}
while (element != null && !(element instanceof PsiFile)) element = element.getParent();
PsiFile file = (PsiFile)element;
if (file == null) return "containing file is null";
FileViewProvider provider = file.getViewProvider();
VirtualFile vFile = provider.getVirtualFile();
if (!vFile.isValid()) return vFile + " is invalid";
if (!provider.isPhysical()) {
PsiElement context = file.getContext();
if (context != null && !context.isValid()) {
return "invalid context: " + reason(context);
}
}
PsiManager manager = file.getManager();
if (manager.getProject().isDisposed()) return "project is disposed";
Language language = file.getLanguage();
if (language != provider.getBaseLanguage()) return "File language:" + language + " != Provider base language:" + provider.getBaseLanguage();
FileViewProvider p = manager.findViewProvider(vFile);
if (provider != p) return "different providers: " + provider + "(" + id(provider) + "); " + p + "(" + id(p) + ")";
if (!provider.isPhysical()) return "non-physical provider: " + provider; // "dummy" file?
return "psi is outdated";
}
开发者ID:consulo,项目名称:consulo,代码行数:49,代码来源:PsiInvalidElementAccessException.java
示例20: buildFileStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
/**
* May return {@code null} for inner or synthetic classes - i.e. those indexed as a part of their parent .class file.
*/
@Nullable
public abstract PsiFileStub<?> buildFileStub(@NotNull FileContent fileContent) throws ClsFormatException;
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ClsStubBuilder.java
注:本文中的com.intellij.psi.stubs.PsiFileStub类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论