use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.
the class PyStubsTest method testImportFeatures.
public void testImportFeatures() {
final PyFileImpl file = (PyFileImpl) getTestFile();
assertTrue(file.hasImportFromFuture(FutureFeature.DIVISION));
assertTrue(file.hasImportFromFuture(FutureFeature.UNICODE_LITERALS));
assertNotParsed(file);
}
use of com.jetbrains.python.psi.impl.PyFileImpl 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());
}
Aggregations