Search in sources :

Example 1 with PyFileImpl

use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.

the class PyStubsTest method testDunderAllAsSum.

public void testDunderAllAsSum() {
    final PyFileImpl file = (PyFileImpl) getTestFile();
    final List<String> all = file.getDunderAll();
    assertSameElements(all, "md5", "sha1", "algorithms_guaranteed", "algorithms_available");
    assertNotParsed(file);
}
Also used : PyFileImpl(com.jetbrains.python.psi.impl.PyFileImpl)

Example 2 with PyFileImpl

use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.

the class PyStubsTest method testImportStatement.

public void testImportStatement() {
    final PyFileImpl file = (PyFileImpl) getTestFile();
    final List<PyFromImportStatement> fromImports = file.getFromImports();
    assertEquals(1, fromImports.size());
    final PyFromImportStatement fromImport = fromImports.get(0);
    final PyImportElement[] importElements = fromImport.getImportElements();
    assertEquals(1, importElements.length);
    assertEquals("argv", importElements[0].getVisibleName());
    assertFalse(fromImport.isStarImport());
    assertEquals(0, fromImport.getRelativeLevel());
    final QualifiedName qName = fromImport.getImportSourceQName();
    assertSameElements(qName.getComponents(), "sys");
    final List<PyImportElement> importTargets = file.getImportTargets();
    assertEquals(1, importTargets.size());
    final PyImportElement importElement = importTargets.get(0);
    final QualifiedName importQName = importElement.getImportedQName();
    assertSameElements(importQName.getComponents(), "os", "path");
    assertNotParsed(file);
}
Also used : QualifiedName(com.intellij.psi.util.QualifiedName) PyFileImpl(com.jetbrains.python.psi.impl.PyFileImpl)

Example 3 with PyFileImpl

use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.

the class PyStubsTest method testDunderAll.

public void testDunderAll() {
    final PyFileImpl file = (PyFileImpl) getTestFile();
    final List<String> all = file.getDunderAll();
    assertSameElements(all, "foo", "bar");
    assertNotParsed(file);
}
Also used : PyFileImpl(com.jetbrains.python.psi.impl.PyFileImpl)

Example 4 with PyFileImpl

use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.

the class PyStubsTest method testIfNameMain.

public void testIfNameMain() {
    // PY-4008
    final PyFileImpl file = (PyFileImpl) getTestFile();
    ensureVariableNotInIndex("xyzzy");
    assertNotParsed(file);
    // assert no error on switching from stub to AST
    file.acceptChildren(new PyRecursiveElementVisitor());
    assertNotNull(file.getTreeElement());
}
Also used : PyFileImpl(com.jetbrains.python.psi.impl.PyFileImpl)

Example 5 with PyFileImpl

use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.

the class PyStubsTest method testImportInExcept.

public void testImportInExcept() {
    final PyFileImpl file = (PyFileImpl) getTestFile();
    final PsiElement element = file.getElementNamed("tzinfo");
    assertTrue(element != null ? element.toString() : "null", element instanceof PyClass);
    assertNotParsed(file);
}
Also used : PyFileImpl(com.jetbrains.python.psi.impl.PyFileImpl)

Aggregations

PyFileImpl (com.jetbrains.python.psi.impl.PyFileImpl)17 PyImportStatementBase (com.jetbrains.python.psi.PyImportStatementBase)2 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 InspectionProfile (com.intellij.codeInspection.InspectionProfile)1 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 StubElement (com.intellij.psi.stubs.StubElement)1 QualifiedName (com.intellij.psi.util.QualifiedName)1 PyCodeStyleSettings (com.jetbrains.python.formatter.PyCodeStyleSettings)1 PyPep8Inspection (com.jetbrains.python.inspections.PyPep8Inspection)1 Nullable (org.jetbrains.annotations.Nullable)1