本文整理汇总了Java中com.intellij.psi.stubs.StubElement类的典型用法代码示例。如果您正苦于以下问题:Java StubElement类的具体用法?Java StubElement怎么用?Java StubElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StubElement类属于com.intellij.psi.stubs包,在下文中一共展示了StubElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
public void doTest() throws Exception {
final List<String> data = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
String fileText = data.get(0);
PsiFile psiFile = TestUtils.createPseudoPhysicalGroovyFile(getProject(), fileText);
ASTNode node = psiFile.getNode();
Assert.assertNotNull(node);
IElementType type = node.getElementType();
Assert.assertTrue(type instanceof IStubFileElementType);
IStubFileElementType stubFileType = (IStubFileElementType) type;
StubBuilder builder = stubFileType.getBuilder();
StubElement element = builder.buildStubTree(psiFile);
StringBuffer buffer = new StringBuffer();
getStubsTreeImpl(element, buffer, "");
String stubTree = buffer.toString().trim();
assertEquals(data.get(1), stubTree);
}
示例2: processChildrenScopes
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
private boolean processChildrenScopes(@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
final StubElement<?> stub = getStub();
if (stub != null) {
return true; // only local usages are traversed here. Having a stub means the clients are outside and won't see our variables
}
PsiElement run = lastParent == null ? getLastChild() : lastParent.getPrevSibling();
while (run != null) {
if (shouldProcess(lastParent, run) &&
!run.processDeclarations(processor, state, null, place)) {
return false;
}
run = run.getPrevSibling();
}
return true;
}
示例3: indexStub
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@Override
public void indexStub(@NotNull PsiClassReferenceListStub stub, @NotNull IndexSink sink) {
PsiReferenceList.Role role = stub.getRole();
if (role == PsiReferenceList.Role.EXTENDS_LIST || role == PsiReferenceList.Role.IMPLEMENTS_LIST) {
String[] names = stub.getReferencedNames();
for (String name : names) {
String shortName = PsiNameHelper.getShortClassName(name);
if (!StringUtil.isEmptyOrSpaces(shortName)) {
sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, shortName);
}
}
if (role == PsiReferenceList.Role.EXTENDS_LIST) {
StubElement parentStub = stub.getParentStub();
if (parentStub instanceof PsiClassStub) {
PsiClassStub psiClassStub = (PsiClassStub)parentStub;
if (psiClassStub.isEnum()) {
sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Enum");
}
if (psiClassStub.isAnnotationType()) {
sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Annotation");
}
}
}
}
}
示例4: deserialize
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@NotNull
@Override
public PsiClassStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
byte flags = dataStream.readByte();
boolean isAnonymous = PsiClassStubImpl.isAnonymous(flags);
boolean isEnumConst = PsiClassStubImpl.isEnumConstInitializer(flags);
JavaClassElementType type = typeForClass(isAnonymous, isEnumConst);
if (!isAnonymous) {
StringRef name = dataStream.readName();
StringRef qname = dataStream.readName();
int languageLevelId = dataStream.readByte();
StringRef sourceFileName = dataStream.readName();
PsiClassStubImpl classStub = new PsiClassStubImpl(type, parentStub, qname, name, null, flags);
classStub.setLanguageLevel(LanguageLevel.values()[languageLevelId]);
classStub.setSourceFileName(sourceFileName);
return classStub;
}
else {
StringRef baseRef = dataStream.readName();
return new PsiClassStubImpl(type, parentStub, null, null, baseRef, flags);
}
}
示例5: createStub
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@Override
public PsiImportStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
boolean isOnDemand = false;
String refText = null;
for (LighterASTNode child : tree.getChildren(node)) {
IElementType type = child.getTokenType();
if (type == JavaElementType.JAVA_CODE_REFERENCE || type == JavaElementType.IMPORT_STATIC_REFERENCE) {
refText = JavaSourceUtil.getReferenceText(tree, child);
}
else if (type == JavaTokenType.ASTERISK) {
isOnDemand = true;
}
}
byte flags = PsiImportStatementStubImpl.packFlags(isOnDemand, node.getTokenType() == JavaElementType.IMPORT_STATIC_STATEMENT);
return new PsiImportStatementStubImpl(parentStub, refText, flags);
}
示例6: getWrappersFromStub
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@Nullable
private Modifier getWrappersFromStub() {
final StubElement parentStub = getStub().getParentStub();
final List childrenStubs = parentStub.getChildrenStubs();
int index = childrenStubs.indexOf(getStub());
if (index >= 0 && index < childrenStubs.size() - 1) {
StubElement nextStub = (StubElement)childrenStubs.get(index + 1);
if (nextStub instanceof PyTargetExpressionStub) {
final PyTargetExpressionStub targetExpressionStub = (PyTargetExpressionStub)nextStub;
if (targetExpressionStub.getInitializerType() == PyTargetExpressionStub.InitializerType.CallExpression) {
final QualifiedName qualifiedName = targetExpressionStub.getInitializer();
if (QualifiedName.fromComponents(PyNames.CLASSMETHOD).equals(qualifiedName)) {
return CLASSMETHOD;
}
if (QualifiedName.fromComponents(PyNames.STATICMETHOD).equals(qualifiedName)) {
return STATICMETHOD;
}
}
}
}
return null;
}
示例7: createStub
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
public PyTargetExpressionStub createStub(@NotNull final PyTargetExpression psi, final StubElement parentStub) {
final String name = psi.getName();
final PyExpression assignedValue = psi.findAssignedValue();
final String docString = DocStringUtil.getDocStringValue(psi);
for (CustomTargetExpressionStubType customStubType : getCustomStubTypes()) {
CustomTargetExpressionStub customStub = customStubType.createStub(psi);
if (customStub != null) {
return new PyTargetExpressionStubImpl(name, docString, customStub, parentStub);
}
}
PyTargetExpressionStub.InitializerType initializerType = PyTargetExpressionStub.InitializerType.Other;
QualifiedName initializer = null;
if (assignedValue instanceof PyReferenceExpression) {
initializerType = PyTargetExpressionStub.InitializerType.ReferenceExpression;
initializer = ((PyReferenceExpression) assignedValue).asQualifiedName();
}
else if (assignedValue instanceof PyCallExpression) {
initializerType = PyTargetExpressionStub.InitializerType.CallExpression;
final PyExpression callee = ((PyCallExpression)assignedValue).getCallee();
if (callee instanceof PyReferenceExpression) {
initializer = ((PyReferenceExpression) callee).asQualifiedName();
}
}
return new PyTargetExpressionStubImpl(name, docString, initializerType, initializer, psi.isQualified(), parentStub);
}
示例8: applyAnnotations
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
if (modifierList == null) return this;
List<PsiAnnotationStub> annotationStubs = null;
for (StubElement child : modifierList.getChildrenStubs()) {
if (!(child instanceof PsiAnnotationStub)) continue;
PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
if (PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement())) {
if (annotationStubs == null) annotationStubs = new SmartList<PsiAnnotationStub>();
annotationStubs.add(annotationStub);
}
}
PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
if (annotationStubs != null) stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
示例9: createStubForFile
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree) {
if (!(file instanceof PsiJavaFile)) {
return super.createStubForFile(file, tree);
}
String refText = "";
LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
if (pkg != null) {
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
if (ref != null) {
refText = JavaSourceUtil.getReferenceText(tree, ref);
}
}
return new PsiJavaFileStubImpl((PsiJavaFile)file, StringRef.fromString(refText), false);
}
示例10: testSOEProof
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
public void testSOEProof() {
StringBuilder sb = new StringBuilder();
SecureRandom random = new SecureRandom();
sb.append("class SOE_test {\n BigInteger BIG = new BigInteger(\n");
int i;
for (i = 0; i < 100000; i++) {
sb.append(" \"").append(Math.abs(random.nextInt())).append("\" +\n");
}
sb.append(" \"\");\n}");
PsiJavaFile file = (PsiJavaFile)createLightFile("SOE_test.java", sb.toString());
long t = System.currentTimeMillis();
StubElement tree = myBuilder.buildStubTree(file);
t = System.currentTimeMillis() - t;
assertEquals("PsiJavaFileStub []\n" +
" IMPORT_LIST:PsiImportListStub\n" +
" CLASS:PsiClassStub[name=SOE_test fqn=SOE_test]\n" +
" MODIFIER_LIST:PsiModifierListStub[mask=4096]\n" +
" TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
" EXTENDS_LIST:PsiRefListStub[EXTENDS_LIST:]\n" +
" IMPLEMENTS_LIST:PsiRefListStub[IMPLEMENTS_LIST:]\n" +
" FIELD:PsiFieldStub[BIG:BigInteger=;INITIALIZER_NOT_STORED;]\n" +
" MODIFIER_LIST:PsiModifierListStub[mask=4096]\n",
DebugUtil.stubTreeToString(tree));
System.out.println("SOE depth=" + i + ", time=" + t + "ms");
}
示例11: doTest
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
private void doTest(String source, String expected) {
PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", source);
FileASTNode fileNode = file.getNode();
assertNotNull(fileNode);
assertFalse(fileNode.isParsed());
StubElement lightTree = myBuilder.buildStubTree(file);
assertFalse(fileNode.isParsed());
file.getNode().getChildren(null); // force switch to AST
StubElement astBasedTree = myBuilder.buildStubTree(file);
assertTrue(fileNode.isParsed());
assertEquals("light tree differs", expected, DebugUtil.stubTreeToString(lightTree));
assertEquals("AST-based tree differs", expected, DebugUtil.stubTreeToString(astBasedTree));
}
示例12: getBuilder
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@Override
public StubBuilder getBuilder() {
return new DefaultStubBuilder() {
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file) {
if (file instanceof RmlFile) {
return new RmlFileStub((RmlFile) file);
}
return super.createStubForFile(file);
}
};
}
示例13: deserialize
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@NotNull
@Override
public TemplateDefinitionStub deserialize(
@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
final StringRef ref = dataStream.readName();
return new TemplateDefinitionStub(parentStub, ref.getString());
}
示例14: deserialize
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@NotNull
@Override
public NamespaceDeclarationStub deserialize(
@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
final StringRef ref = dataStream.readName();
return new NamespaceDeclarationStub(parentStub, ref.getString());
}
示例15: getBuilder
import com.intellij.psi.stubs.StubElement; //导入依赖的package包/类
@Override
public StubBuilder getBuilder() {
return new DefaultStubBuilder() {
@Override
protected StubElement createStubForFile(@NotNull PsiFile file) {
return new FileStub((SoyFile) file);
}
};
}