use of com.intellij.psi.stubs.StubElement in project intellij-community by JetBrains.
the class PyFileImpl method hasImportFromFuture.
@Override
public boolean hasImportFromFuture(FutureFeature feature) {
final StubElement stub = getStub();
if (stub instanceof PyFileStub) {
return ((PyFileStub) stub).getFutureFeatures().get(feature.ordinal());
}
Boolean enabled = myFutureFeatures.get(feature);
if (enabled == null) {
enabled = calculateImportFromFuture(feature);
myFutureFeatures.put(feature, enabled);
// NOTE: ^^^ not synchronized. if two threads will try to modify this, both can only be expected to set the same value.
}
return enabled;
}
use of com.intellij.psi.stubs.StubElement in project intellij-community by JetBrains.
the class PyStubsTest method testRenamingUpdatesTheStub.
public void testRenamingUpdatesTheStub() {
final PyFile file = getTestFile("LoadingTreeRetainsKnownPsiElement.py");
final List<PyClass> classes = file.getTopLevelClasses();
assertEquals(1, classes.size());
final PyClass pyClass = classes.get(0);
assertEquals("SomeClass", pyClass.getName());
// Ensure we haven't loaded the tree yet.
final PyFileImpl fileImpl = (PyFileImpl) file;
assertNull(fileImpl.getTreeElement());
// Load the tree
final PsiElement[] children = file.getChildren();
assertNotNull(fileImpl.getTreeElement());
assertEquals(1, children.length);
assertSame(pyClass, children[0]);
new WriteCommandAction(myFixture.getProject(), fileImpl) {
@Override
protected void run(@NotNull final Result result) throws Throwable {
pyClass.setName("RenamedClass");
assertEquals("RenamedClass", pyClass.getName());
}
}.execute();
StubElement fileStub = fileImpl.getStub();
assertNull("There should be no stub if file holds tree element", fileStub);
new WriteCommandAction(myFixture.getProject(), fileImpl) {
@Override
protected void run(@NotNull Result result) throws Throwable {
((SingleRootFileViewProvider) fileImpl.getViewProvider()).onContentReload();
}
}.execute();
// Test unload succeeded.
assertNull(fileImpl.getTreeElement());
assertEquals("RenamedClass", fileImpl.getTopLevelClasses().get(0).getName());
}
use of com.intellij.psi.stubs.StubElement in project intellij-plugins by JetBrains.
the class FlexStyleIndex method getIndexer.
@NotNull
@Override
public DataIndexer<String, Set<FlexStyleIndexInfo>, FileContent> getIndexer() {
return new DataIndexer<String, Set<FlexStyleIndexInfo>, FileContent>() {
@Override
@NotNull
public Map<String, Set<FlexStyleIndexInfo>> map(@NotNull FileContent inputData) {
final THashMap<String, Set<FlexStyleIndexInfo>> map = new THashMap<>();
if (JavaScriptSupportLoader.isFlexMxmFile(inputData.getFileName())) {
PsiFile file = inputData.getPsiFile();
VirtualFile virtualFile = inputData.getFile();
if (file instanceof XmlFile) {
indexMxmlFile((XmlFile) file, virtualFile, map);
}
} else {
StubTree tree = JSPackageIndex.getStubTree(inputData);
if (tree != null) {
for (StubElement e : tree.getPlainList()) {
if (e instanceof JSClassStub) {
final PsiElement psiElement = e.getPsi();
if (psiElement instanceof JSClass) {
final String qName = ((JSClass) psiElement).getQualifiedName();
indexAttributes(psiElement, qName, true, map);
}
} else if (e instanceof PsiFileStub) {
PsiElement psiElement = e.getPsi();
if (psiElement instanceof JSFile) {
String name = ((JSFile) psiElement).getName();
indexAttributes(psiElement, name, false, map);
}
}
}
}
}
return map;
}
};
}
Aggregations