mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -329,7 +329,7 @@ private layoutFull(Map args, String target, Set usedJars) {
|
||||
}
|
||||
jar("pycharm-openapi-src.zip") {
|
||||
fileset(dir: "$pythonCommunityHome/openapi/src")
|
||||
fileset(dir: "$pythonCommunityHome/python/psi-api/src")
|
||||
fileset(dir: "$pythonCommunityHome/psi-api/src")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,11 @@ private layoutFull(Map args, String target, Set usedJars) {
|
||||
}
|
||||
|
||||
dir("license") {
|
||||
fileset(dir: "$home/community/license")
|
||||
fileset(dir: "$ch/license")
|
||||
fileset(dir: "$ch") {
|
||||
include(name: "LICENSE.txt")
|
||||
include(name: "NOTICE.txt")
|
||||
}
|
||||
}
|
||||
|
||||
layoutPlugins(superLayouts)
|
||||
|
||||
@@ -15,7 +15,7 @@ private List<String> listTopLevelModules(String root) {
|
||||
|
||||
binding.setVariable("buildDebuggerEgg", {String sandbox, String pythonHome, String buildName ->
|
||||
return buildEgg(sandbox, pythonHome, buildName, "pycharm-debug", {
|
||||
ant.fileset(dir: "$pythonHome/helpers/pydev") {
|
||||
ant.fileset(dir: "$pythonHome/community/helpers/pydev") {
|
||||
include(name: "**/*.py")
|
||||
}
|
||||
})
|
||||
@@ -23,7 +23,7 @@ binding.setVariable("buildDebuggerEgg", {String sandbox, String pythonHome, Stri
|
||||
|
||||
binding.setVariable("buildDebuggerEggPy3K", {String sandbox, String pythonHome, String buildName ->
|
||||
return buildEgg(sandbox, pythonHome, buildName, "pycharm-debug-py3k") {
|
||||
ant.fileset(dir: "$pythonHome/helpers/pydev") {
|
||||
ant.fileset(dir: "$pythonHome/community/helpers/pydev") {
|
||||
include(name: "**/*.py")
|
||||
exclude(name:"**/_pydev_BaseHTTPServer.py")
|
||||
exclude(name:"**/_pydev_SimpleXMLRPCServer.py")
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
|
||||
|
||||
setProperty("projectHome", guessHome(this as Script))
|
||||
setProperty("home", projectHome)
|
||||
|
||||
includeTargets << new File("${projectHome}/community/build/scripts/utils.gant")
|
||||
includeTargets << new File("${projectHome}/python/build/python_common.gant")
|
||||
|
||||
setProperty("contribHome", "${projectHome}/contrib")
|
||||
setProperty("outDir", "${projectHome}/out/python")
|
||||
setProperty("ideaDir", "${outDir}/idea")
|
||||
setProperty("ideaDir", "${outDir}/ideaCE")
|
||||
|
||||
setProperty("ideaHome", "${ideaDir}/jdk16") //compiled idea
|
||||
|
||||
@@ -16,35 +15,25 @@ setProperty("pluginHelp", "${outDir}/help")
|
||||
setProperty("buildNumber", requireProperty("build.number", snapshot))
|
||||
setProperty("ideaBuildNumber", requireProperty("idea.build.number"))
|
||||
|
||||
setProperty("pluginHome", "${projectHome}/python")
|
||||
setProperty("pluginHome", "${projectHome}/python/community")
|
||||
setProperty("pluginRevision", "${buildNumber}")
|
||||
|
||||
setProperty("ideaLib", "${ideaHome}/lib")
|
||||
setProperty("ideaPlugins", "${ideaHome}/plugins") //compiled plugins
|
||||
|
||||
|
||||
setProperty("output", "${projectHome}/python/dist")
|
||||
setProperty("output", "${projectHome}/python/distCE")
|
||||
|
||||
setProperty("zipdir", "${output}/zip")
|
||||
setProperty("plugindir", "${zipdir}/python")
|
||||
setProperty("zipname", "python-${pluginRevision}.zip")
|
||||
setProperty("zipname", "python-community-${pluginRevision}.zip")
|
||||
|
||||
setProperty("srcDir", "${pluginHome}/src")
|
||||
setProperty("restSrcDir", "${pluginHome}/community/rest/src")
|
||||
setProperty("localizationSrcDir", "${pluginHome}/localization/src")
|
||||
|
||||
setProperty("resourcesDir", "${pluginHome}/resources")
|
||||
setProperty("restResourcesDir", "${pluginHome}/rest/resources")
|
||||
setProperty("localizationResourcesDir", "${pluginHome}/localization/resources")
|
||||
setProperty("pluginResourcesDir", "${pluginHome}/pluginResources")
|
||||
|
||||
setProperty("classesRootDir", "${outDir}/classes")
|
||||
setProperty("classesDir", "${classesRootDir}/python")
|
||||
setProperty("restClassesDir", "${classesRootDir}/rest")
|
||||
setProperty("localizationClassesDir", "${classesRootDir}/localization")
|
||||
|
||||
setProperty("restJarName", "${output}/rest-${buildNumber}.jar")
|
||||
setProperty("localizationJarName", "${output}/localization-${buildNumber}.jar")
|
||||
|
||||
//Compiler options
|
||||
setProperty("compilerDebug", "on")
|
||||
@@ -70,10 +59,6 @@ ant.patternset(id: "resources.pt") {
|
||||
exclude(name: "**/plugin.xml")
|
||||
}
|
||||
|
||||
def connectorPlugins = ["django-db-config", "python-javascript-debugger", "python-uml", "python-localization", "python-rest",
|
||||
"python-remote-interpreter"]
|
||||
def contribPlugins = ["pycharm-flask", "pycharm-numpy"]
|
||||
|
||||
target(name: "clean", description: "Cleanup output") {
|
||||
ant.echo("Cleaning ${output}")
|
||||
ant.delete(dir: "${output}", failonerror: "false")
|
||||
@@ -85,188 +70,19 @@ target(name: "clean", description: "Cleanup output") {
|
||||
|
||||
target(name: "unzip") {
|
||||
ant.mkdir(dir: "${ideaHome}")
|
||||
ant.unzip(src: "${ideaDir}/ideaIU-${ideaBuildNumber}.zip", dest: "${ideaHome}")
|
||||
ant.unzip(src: "${ideaDir}/ideaIC-${ideaBuildNumber}.win.zip", dest: "${ideaHome}")
|
||||
}
|
||||
|
||||
def patchPluginXml(path) {
|
||||
ant.replaceregexp(file: path,
|
||||
match: "since-build=\"\\d+\\.\\d+\"",
|
||||
replace: "since-build=\"${ideaBuildNumber}\"")
|
||||
ant.replaceregexp(file: path,
|
||||
match: "\\d+\\.SNAPSHOT",
|
||||
replace: "${ideaBuildNumber}")
|
||||
|
||||
}
|
||||
|
||||
target(name: "compileRest", description: "Compile module rest") {
|
||||
depends("unzip")
|
||||
ant.path(id: "classpath.lib") {
|
||||
fileset(dir: "${ideaLib}") {
|
||||
include(name: "?*.jar")
|
||||
}
|
||||
}
|
||||
|
||||
//The task requires the following libraries from IntelliJ IDEA distribution:
|
||||
//javac2.jar; jdom.jar; asm.jar; asm-commons.jar
|
||||
ant.taskdef(name: "javac2", classname: "com.intellij.ant.Javac2") {
|
||||
classpath(refid: "classpath.lib")
|
||||
}
|
||||
|
||||
ant.mkdir(dir: "${restClassesDir}")
|
||||
|
||||
//compile
|
||||
ant.javac2(destdir: "${restClassesDir}",
|
||||
debug: "${compilerDebug}",
|
||||
nowarn: "${compilerGenerateNoWarnings}",
|
||||
memorymaximumsize: "${compilerMaxMemory}",
|
||||
fork: "true") {
|
||||
compilerarg(line: "${compilerArgs}")
|
||||
classpath(refid: "classpath.lib")
|
||||
src {
|
||||
pathelement(location: "${restSrcDir}")
|
||||
}
|
||||
}
|
||||
|
||||
//copy resources
|
||||
ant.copy(todir: "${restClassesDir}") {
|
||||
fileset(dir: "${restSrcDir}") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
ant.copy(todir: "${restClassesDir}") {
|
||||
fileset(dir: "${restResourcesDir}") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
|
||||
//copy plugin.xml
|
||||
ant.mkdir(dir: "${restClassesDir}/META-INF")
|
||||
ant.copy(todir: "${restClassesDir}/META-INF") {
|
||||
fileset(dir: "${pluginHome}/rest/resources/META-INF")
|
||||
}
|
||||
|
||||
patchPluginXml("${restClassesDir}/META-INF/plugin.xml")
|
||||
}
|
||||
|
||||
target(name: "jarRest", description: "Generate jar file for ReST plugin") {
|
||||
depends("compileRest")
|
||||
ant.mkdir(dir: "${output}")
|
||||
ant.jar(destfile: "${restJarName}", basedir: "${restClassesDir}") {
|
||||
manifest() {
|
||||
attribute(name: "Revision", value: "${pluginRevision}")
|
||||
//<!--<attribute name="Build" value="${plugin.version}"/>-->
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target(name: "compileLocalization", description: "Compile module localization") {
|
||||
depends("unzip")
|
||||
ant.path(id: "classpath.lib") {
|
||||
fileset(dir: "${ideaLib}") {
|
||||
include(name: "?*.jar")
|
||||
}
|
||||
}
|
||||
|
||||
ant.path(id: "sourcepath") {
|
||||
dirset(dir: "${pluginHome}") {
|
||||
include(name: "localization/src")
|
||||
}
|
||||
}
|
||||
//The task requires the following libraries from IntelliJ IDEA distribution:
|
||||
//javac2.jar; jdom.jar; asm.jar; asm-commons.jar
|
||||
ant.taskdef(name: "javac2", classname: "com.intellij.ant.Javac2") {
|
||||
classpath(refid: "classpath.lib")
|
||||
}
|
||||
|
||||
ant.mkdir(dir: "${localizationClassesDir}")
|
||||
|
||||
//compile
|
||||
ant.javac2(destdir: "${localizationClassesDir}",
|
||||
debug: "${compilerDebug}",
|
||||
nowarn: "${compilerGenerateNoWarnings}",
|
||||
memorymaximumsize: "${compilerMaxMemory}",
|
||||
fork: "true") {
|
||||
compilerarg(line: "${compilerArgs}")
|
||||
classpath(refid: "classpath.lib")
|
||||
src {
|
||||
pathelement(location: "${localizationSrcDir}")
|
||||
}
|
||||
}
|
||||
|
||||
//copy resources
|
||||
ant.copy(todir: "${localizationClassesDir}") {
|
||||
fileset(dir: "${localizationSrcDir}") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
ant.copy(todir: "${localizationClassesDir}") {
|
||||
fileset(dir: "${localizationResourcesDir}") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
|
||||
//copy plugin.xml
|
||||
ant.mkdir(dir: "${localizationClassesDir}/META-INF")
|
||||
ant.copy(todir: "${localizationClassesDir}/META-INF") {
|
||||
fileset(dir: "${pluginHome}/localization/resources/META-INF")
|
||||
}
|
||||
|
||||
patchPluginXml("${localizationClassesDir}/META-INF/plugin.xml")
|
||||
}
|
||||
|
||||
target(name: "jarLocalization", description: "Generate jar file for localization plugin") {
|
||||
depends("compileLocalization")
|
||||
ant.mkdir(dir: "${output}")
|
||||
ant.jar(destfile: "${localizationJarName}", basedir: "${localizationClassesDir}") {
|
||||
manifest() {
|
||||
attribute(name: "Revision", value: "${pluginRevision}")
|
||||
//<!--<attribute name="Build" value="${plugin.version}"/>-->
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
target(name: "compile", description: "Compile module python") {
|
||||
depends("unzip")
|
||||
depends("jarRest")
|
||||
depends("jarLocalization")
|
||||
|
||||
ant.path(id: "classpath.lib") {
|
||||
fileset(dir: "${ideaLib}") {
|
||||
include(name: "?*.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/yaml/lib") {
|
||||
include(name: "yaml.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/coverage/lib") {
|
||||
include(name: "coverage.jar")
|
||||
include(name: "coverage-agent.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/JavaScriptDebugger/lib") {
|
||||
include(name: "JavaScriptDebugger.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/webDeployment/lib") {
|
||||
include(name: "webDeployment.jar")
|
||||
include(name: "commons-vfs*.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/uml/lib") {
|
||||
include(name: "*.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/DatabaseSupport/lib") {
|
||||
include(name: "*.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/remote-run/lib") {
|
||||
include(name: "*.jar")
|
||||
}
|
||||
fileset(dir: "${ideaPlugins}/terminal/lib") {
|
||||
include(name: "*.jar")
|
||||
}
|
||||
pathelement(location: restJarName)
|
||||
pathelement(location: localizationJarName)
|
||||
}
|
||||
|
||||
ant.path(id: "sourcepath") {
|
||||
@@ -274,19 +90,10 @@ target(name: "compile", description: "Compile module python") {
|
||||
include(name: "resources")
|
||||
include(name: "src")
|
||||
include(name: "pluginSrc")
|
||||
include(name: "community/pydevSrc")
|
||||
include(name: "community/openapi/src")
|
||||
include(name: "community/psi-api/src")
|
||||
include(name: "community/src")
|
||||
include(name: "pluginResources")
|
||||
include(name: "pydevSrc")
|
||||
include(name: "openapi/src")
|
||||
include(name: "psi-api/src")
|
||||
}
|
||||
connectorPlugins.each {
|
||||
pathelement(location: "${pluginHome}/${it}/src")
|
||||
}
|
||||
contribPlugins.each {
|
||||
pathelement(location: "${contribHome}/${it}/src")
|
||||
}
|
||||
pathelement(location: "${pluginHome}/../ultimate/ultimate-verifier/src")
|
||||
}
|
||||
//The task requires the following libraries from IntelliJ IDEA distribution:
|
||||
//javac2.jar; jdom.jar; asm.jar; asm-commons.jar
|
||||
@@ -317,46 +124,26 @@ target(name: "compile", description: "Compile module python") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
fileset(dir: "${pluginResourcesDir}") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
fileset(dir: "${pluginHome}/src") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
fileset(dir: "${pluginHome}/community/psi-api/resources") {
|
||||
fileset(dir: "${pluginHome}/psi-api/resources") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
fileset(dir: "${pluginHome}/community/src") {
|
||||
fileset(dir: "${pluginHome}/resources") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
fileset(dir: "${pluginHome}/community/resources") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
connectorPlugins.each {
|
||||
fileset(dir: "${pluginHome}/${it}/resources") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
contribPlugins.each {
|
||||
fileset(dir: "${contribHome}/${it}/resources") {
|
||||
patternset(refid: "resources.pt")
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
fileset(dir: "${pluginHome}/../community/colorSchemes/src")
|
||||
fileset(dir: "${pluginHome}/../../community/colorSchemes/src")
|
||||
}
|
||||
|
||||
//copy plugin.xml
|
||||
ant.mkdir(dir: "${classesDir}/META-INF")
|
||||
ant.copy(todir: "${classesDir}/META-INF") {
|
||||
fileset(file: "${pluginHome}/pluginSrc/META-INF/plugin.xml")
|
||||
fileset(file: "${pluginHome}/build/python-plugin-dependencies.xml")
|
||||
fileset(file: "${pluginHome}/pluginSrc/META-INF/*.xml")
|
||||
fileset(file: "${pluginHome}/pluginResources/META-INF/*.xml")
|
||||
}
|
||||
|
||||
ant.replaceregexp(file: "${classesDir}/META-INF/plugin.xml",
|
||||
@@ -367,7 +154,7 @@ target(name: "compile", description: "Compile module python") {
|
||||
target(name: "jar", description: "Generate jar file") {
|
||||
depends("compile")
|
||||
ant.mkdir(dir: "${output}")
|
||||
ant.jar(destfile: "${output}/python.jar", basedir: "${classesDir}") {
|
||||
ant.jar(destfile: "${output}/python-community.jar", basedir: "${classesDir}") {
|
||||
manifest() {
|
||||
attribute(name: "Revision", value: "${pluginRevision}")
|
||||
//<!--<attribute name="Build" value="${plugin.version}"/>-->
|
||||
@@ -382,11 +169,11 @@ target(name: "zip", description: "Generate zip plugin file") {
|
||||
|
||||
// copy plugin jar
|
||||
ant.mkdir(dir: "${plugindir}/lib")
|
||||
ant.move(file: "${output}/python.jar", todir: "${plugindir}/lib")
|
||||
ant.move(file: "${output}/python-community.jar", todir: "${plugindir}/lib")
|
||||
|
||||
ant.mkdir(dir: "${plugindir}/helpers")
|
||||
ant.copy(todir: "${plugindir}/helpers") {
|
||||
fileset(dir: "${pluginHome}/community/helpers") {
|
||||
fileset(dir: "${pluginHome}/helpers") {
|
||||
include(name: "**/*")
|
||||
}
|
||||
}
|
||||
@@ -395,19 +182,12 @@ target(name: "zip", description: "Generate zip plugin file") {
|
||||
ant.copy(file: "${pluginHelp}/pytonpluginhelp.jar", tofile: "${plugindir}/help/pythonpluginhelp.jar")
|
||||
ant.copy(file: "${pluginHelp}/pytonpluginhelp_mac.jar", tofile: "${plugindir}/help/pythonpluginhelp_mac.jar")
|
||||
|
||||
ant.move(file: "${debugEgg}", todir: "${plugindir}")
|
||||
ant.move(file: "${debugEggPy3K}", todir: "${plugindir}")
|
||||
|
||||
ant.zip(basedir: "${zipdir}", destfile: "${output}/${zipname}")
|
||||
}
|
||||
|
||||
target(name: "build") {
|
||||
depends("unzip")
|
||||
depends("compile")
|
||||
egg = buildDebuggerEgg(outDir, pluginHome, "PythonPlugin-${buildNumber}")
|
||||
setProperty("debugEgg", "$egg")
|
||||
egg = buildDebuggerEggPy3K(outDir, pluginHome, "PythonPlugin-${buildNumber}")
|
||||
setProperty("debugEggPy3K", "$egg")
|
||||
}
|
||||
|
||||
target(name: "dist", description: "main target") {
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/../../resources">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../resources" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
|
||||
+4
-3
@@ -20,6 +20,7 @@
|
||||
<module name="python-pydev"/>
|
||||
<module name="python-openapi"/>
|
||||
<module name="python-psi-api"/>
|
||||
<module name="python-community-plugin"/>
|
||||
<module name="colorSchemes"/>
|
||||
</jar>
|
||||
<jar name="resources_en.jar">
|
||||
@@ -28,10 +29,10 @@
|
||||
<fileset dir="${project.home}/python/lib" includes="*.jar"/>
|
||||
</dir>
|
||||
<dir name="helpers">
|
||||
<fileset dir="${project.home}/python/helpers" includes="**/*.py"/>
|
||||
<fileset dir="${project.home}/python/helpers" includes="**/versions.xml"/>
|
||||
<fileset dir="${project.home}/python/community/helpers" includes="**/*.py"/>
|
||||
<fileset dir="${project.home}/python/community/helpers" includes="**/versions.xml"/>
|
||||
</dir>
|
||||
</dir>
|
||||
</layout>
|
||||
</target>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<idea-plugin version="2" xmlns:xi="http://www.w3.org/2001/XInclude" url="http://confluence.jetbrains.com/display/PYH/">
|
||||
<!-- Components and extensions declared in this file work ONLY in Python plugin, not in standalone PyCharm.
|
||||
Anything related to Python/Java integration must go in this file. -->
|
||||
|
||||
<id>PythonCore</id>
|
||||
<name>Python Community Edition</name>
|
||||
<idea-version since-build="130.0" until-build="133.0"/>
|
||||
<description>Smart editing for Python scripts</description>
|
||||
<version>3.0</version>
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
|
||||
|
||||
<vendor url="http://www.jetbrains.com/pycharm/" logo="/com/jetbrains/python/python.png">JetBrains, Keith Lea</vendor>
|
||||
<xi:include href="/META-INF/python-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
<xi:include href="/META-INF/python-plugin-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
</idea-plugin>
|
||||
@@ -1,12 +1,12 @@
|
||||
<idea-plugin version="2" xmlns:xi="http://www.w3.org/2001/XInclude" url="http://confluence.jetbrains.com/display/PYH/">
|
||||
<!-- Components and extensions declared in this file work ONLY in Python plugin, not in standalone PyCharm.
|
||||
Anything related to Python/Java integration must go in this file. -->
|
||||
<!-- Components and extensions declared in this file work ONLY in Python plugin for IntelliJ IDEA Ultimate, not in standalone PyCharm.
|
||||
Anything related to Django and App Engine in IntelliJ IDEA context must go in this file. -->
|
||||
|
||||
<id>Pythonid</id>
|
||||
<name>Python</name>
|
||||
<idea-version since-build="130.0" until-build="133.0"/>
|
||||
<description>Smart editing for Python scripts</description>
|
||||
<version>2.11.2</version>
|
||||
<version>3.0</version>
|
||||
<depends>com.intellij.modules.ultimate</depends>
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
<depends>Coverage</depends>
|
||||
@@ -17,6 +17,7 @@
|
||||
<helpset file="pythonpluginhelp.jar" path="/pycharm/Help.hs"/>
|
||||
|
||||
<xi:include href="/META-INF/python-plugin-common.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
<xi:include href="/META-INF/python-plugin-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
|
||||
<!-- Two different versions of this file exist: one is used when building from sources (when auxiliary
|
||||
plugins are loaded as separate plugins) and another is used for the real release build (when auxiliary
|
||||
@@ -24,43 +25,8 @@
|
||||
<xi:include href="/META-INF/python-plugin-dependencies.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<moduleType id="PYTHON_MODULE" implementationClass="com.jetbrains.python.module.PythonModuleType"/>
|
||||
<facetType implementation="com.jetbrains.python.facet.PythonFacetType"/>
|
||||
<framework.detector implementation="com.jetbrains.python.facet.PythonFacetType$PythonFrameworkDetector"/>
|
||||
<framework.detector implementation="com.jetbrains.django.facet.DjangoFrameworkDetector"/>
|
||||
<frameworkSupport implementation="com.jetbrains.python.facet.PythonFrameworkSupportProvider"/>
|
||||
<frameworkSupport implementation="com.jetbrains.django.facet.DjangoFacetSupportProvider"/>
|
||||
<frameworkSupport implementation="com.jetbrains.appengine.facet.AppEngineFacetSupportProvider"/>
|
||||
<projectStructureDetector implementation="com.jetbrains.python.module.PyProjectStructureDetector"/>
|
||||
<moduleConfigurationEditorProvider implementation="com.jetbrains.python.module.PythonModuleConfigurationEditorProvider"/>
|
||||
<applicationService serviceInterface="com.jetbrains.python.run.PyCommonOptionsFormFactory"
|
||||
serviceImplementation="com.jetbrains.python.run.PyPluginCommonOptionsFormFactory"/>
|
||||
<completion.contributor language="Python" implementationClass="com.jetbrains.python.psi.impl.PyConstructorArgumentCompletionContributor"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="Pythonid">
|
||||
<importResolver implementation="com.jetbrains.python.psi.impl.PyJavaImportResolver"/>
|
||||
<typeProvider implementation="com.jetbrains.python.psi.impl.PyJavaTypeProvider"/>
|
||||
<pySuperMethodsSearch implementation="com.jetbrains.python.psi.impl.PyJavaSuperMethodsSearchExecutor"/>
|
||||
<importCandidateProvider implementation="com.jetbrains.python.psi.impl.PyJavaImportCandidateProvider"/>
|
||||
</extensions>
|
||||
|
||||
<application-components>
|
||||
<component>
|
||||
<implementation-class>com.jetbrains.python.facet.PythonSdkTableListener</implementation-class>
|
||||
</component>
|
||||
</application-components>
|
||||
|
||||
<module-components>
|
||||
<component>
|
||||
<implementation-class>com.jetbrains.python.facet.PythonFacetListener</implementation-class>
|
||||
</component>
|
||||
</module-components>
|
||||
|
||||
<actions>
|
||||
<action id="PyManagePackages" class="com.jetbrains.python.packaging.PyManagePackagesAction" text="Manage Python Packages...">
|
||||
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
</idea-plugin>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<idea-plugin version="2">
|
||||
<!-- Components and extensions declared in this file work in the Python plugin, both Community and full versions. -->
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<moduleType id="PYTHON_MODULE" implementationClass="com.jetbrains.python.module.PythonModuleType"/>
|
||||
<facetType implementation="com.jetbrains.python.facet.PythonFacetType"/>
|
||||
<framework.detector implementation="com.jetbrains.python.facet.PythonFacetType$PythonFrameworkDetector"/>
|
||||
<frameworkSupport implementation="com.jetbrains.python.facet.PythonFrameworkSupportProvider"/>
|
||||
<projectStructureDetector implementation="com.jetbrains.python.module.PyProjectStructureDetector"/>
|
||||
<moduleConfigurationEditorProvider implementation="com.jetbrains.python.module.PythonModuleConfigurationEditorProvider"/>
|
||||
<applicationService serviceInterface="com.jetbrains.python.run.PyCommonOptionsFormFactory"
|
||||
serviceImplementation="com.jetbrains.python.run.PyPluginCommonOptionsFormFactory"/>
|
||||
<completion.contributor language="Python" implementationClass="com.jetbrains.python.psi.impl.PyConstructorArgumentCompletionContributor"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="Pythonid">
|
||||
<importResolver implementation="com.jetbrains.python.psi.impl.PyJavaImportResolver"/>
|
||||
<typeProvider implementation="com.jetbrains.python.psi.impl.PyJavaTypeProvider"/>
|
||||
<pySuperMethodsSearch implementation="com.jetbrains.python.psi.impl.PyJavaSuperMethodsSearchExecutor"/>
|
||||
<importCandidateProvider implementation="com.jetbrains.python.psi.impl.PyJavaImportCandidateProvider"/>
|
||||
</extensions>
|
||||
|
||||
<application-components>
|
||||
<component>
|
||||
<implementation-class>com.jetbrains.python.facet.PythonSdkTableListener</implementation-class>
|
||||
</component>
|
||||
</application-components>
|
||||
|
||||
<module-components>
|
||||
<component>
|
||||
<implementation-class>com.jetbrains.python.facet.PythonFacetListener</implementation-class>
|
||||
</component>
|
||||
</module-components>
|
||||
|
||||
<actions>
|
||||
<action id="PyManagePackages" class="com.jetbrains.python.packaging.PyManagePackagesAction" text="Manage Python Packages...">
|
||||
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
</idea-plugin>
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.ide.highlighter.XmlFileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeConsumer;
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
||||
import com.intellij.ultimate.PluginVerifier;
|
||||
import com.intellij.ultimate.UltimateVerifier;
|
||||
import com.jetbrains.pyqt.QtUIFileType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Plugin version of file type factory - uses UltimateVerifier.
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public class PythonFileTypeFactory extends FileTypeFactory {
|
||||
public PythonFileTypeFactory(UltimateVerifier verifier) {
|
||||
PluginVerifier.verifyUltimatePlugin(verifier);
|
||||
}
|
||||
|
||||
public void createFileTypes(@NonNls @NotNull final FileTypeConsumer consumer) {
|
||||
consumer.consume(PythonFileType.INSTANCE, "py;pyw;");
|
||||
consumer.consume(QtUIFileType.INSTANCE, "ui");
|
||||
consumer.consume(XmlFileType.INSTANCE, "qrc");
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,12 @@
|
||||
<orderEntry type="library" name="XmlRPC" level="project" />
|
||||
<orderEntry type="module" module-name="xdebugger-api" />
|
||||
<orderEntry type="library" name="http-client-3.1" level="project" />
|
||||
<orderEntry type="module" module-name="RegExpSupport" />
|
||||
<orderEntry type="module" module-name="RegExpSupport" exported="" />
|
||||
<orderEntry type="module" module-name="testRunner" />
|
||||
<orderEntry type="module" module-name="smRunner" />
|
||||
<orderEntry type="module" module-name="spellchecker" />
|
||||
<orderEntry type="module" module-name="xdebugger-impl" />
|
||||
<orderEntry type="module" module-name="xml-psi-impl" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
<content url="file://$MODULE_DIR$/ideSrc">
|
||||
<sourceFolder url="file://$MODULE_DIR$/ideSrc" isTestSource="false" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/resources">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 640 B |
@@ -4,7 +4,7 @@
|
||||
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
|
||||
<logo url="/pycharm_core_logo.png" textcolor="ffffff" progressColor="ffaa16" progressY="230" progressTailIcon="/community_progress_tail.png"/>
|
||||
<about url="/pycharm_core_about.png" logoX="300" logoY="265" logoW="75" logoH="30" foreground="ffffff" linkColor="fca11a"/>
|
||||
<icon size32="/PyCharmCore32.png" size16="/PyCharmCore16.png" size32opaque="/PyCharmCore32.png" size12="/PyCharm_13.png" ico="PyCharmCore.ico"/>
|
||||
<icon size32="/PyCharmCore32.png" size16="/PyCharmCore16.png" size32opaque="/PyCharmCore32.png" size12="/PyCharmCore13.png" ico="PyCharmCore.ico"/>
|
||||
<package code="__PACKAGE_CODE__"/>
|
||||
<names product="PyCharm" fullname="PyCharm Community Edition" script="charm"/>
|
||||
<install-over minbuild="0" maxbuild="0" version="1.x"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<idea-plugin version="2" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<xi:include href="/META-INF/pycharm-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
<xi:include href="/META-INF/python-plugin-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
<xi:include href="/META-INF/python-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -668,6 +668,10 @@
|
||||
text="Generate Python Spellchecker Dictionaries" internal="true">
|
||||
<add-to-group group-id="Internal"/>
|
||||
</action>
|
||||
|
||||
<action id="PyInvertBooleanAction" class="com.jetbrains.python.refactoring.invertBoolean.PyInvertBooleanAction" text="Invert Boolean">
|
||||
<add-to-group group-id="RefactoringMenu" anchor="last" />
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij.spellchecker">
|
||||
@@ -1,7 +1,7 @@
|
||||
<idea-plugin version="2" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<!-- Components and extensions declared in this file work both in PyCharm and Python plugin. -->
|
||||
|
||||
<xi:include href="/META-INF/python-plugin-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
<xi:include href="/META-INF/python-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
@@ -226,6 +226,8 @@
|
||||
<defaultLiveTemplatesProvider implementation="com.jetbrains.django.DjangoDefaultLiveTemplatesProvider"/>
|
||||
<projectService serviceImplementation="com.jetbrains.django.console.DjangoConsoleOptions"/>
|
||||
|
||||
<psi.treeChangePreprocessor implementation="com.jetbrains.django.lang.template.DjangoTemplateTreeChangePreprocessor"/>
|
||||
|
||||
<!-- App Engine -->
|
||||
<facetType implementation="com.jetbrains.appengine.facet.AppEngineFacetType"/>
|
||||
<framework.detector implementation="com.jetbrains.appengine.facet.AppEngineFrameworkDetector"/>
|
||||
@@ -458,18 +460,7 @@
|
||||
<pyClassMembersProvider implementation="com.jetbrains.pyramid.codeInsight.PyramidRequestClassMembersProvider"/>
|
||||
</extensions>
|
||||
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.jetbrains.django.lang.template.DjangoTemplatePsiManager</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<actions>
|
||||
<action id="PyInvertBooleanAction" class="com.jetbrains.python.refactoring.invertBoolean.PyInvertBooleanAction" text="Invert Boolean">
|
||||
<add-to-group group-id="RefactoringMenu" anchor="last" />
|
||||
</action>
|
||||
|
||||
|
||||
<group id="PyProjectViewGroup" internal="true" class="com.intellij.ide.actions.NonEmptyActionGroup" popup="true" text="Python">
|
||||
<action id="Devmode.AnalyzeReturns" class="com.jetbrains.python.devmode.AnalyzeReturnsAction" text="Analyze return types"
|
||||
internal="true"/>
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.intellij.psi.tree.TokenSet;
|
||||
* @author vlan
|
||||
*/
|
||||
public class PythonDialectsTokenSetProvider {
|
||||
public static final PythonDialectsTokenSetProvider INSTANCE = new PythonDialectsTokenSetProvider();
|
||||
public static PythonDialectsTokenSetProvider INSTANCE = new PythonDialectsTokenSetProvider();
|
||||
|
||||
private final TokenSet myStatementTokens;
|
||||
private final TokenSet myExpressionTokens;
|
||||
@@ -104,4 +104,8 @@ public class PythonDialectsTokenSetProvider {
|
||||
public TokenSet getReferenceExpressionTokens() {
|
||||
return myReferenceExpressionTokens;
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
INSTANCE = new PythonDialectsTokenSetProvider();
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -8,8 +8,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* IDE version of file type factory - does not use UltimateVerifier.
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public class PythonFileTypeFactory extends FileTypeFactory {
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.facet.FacetType;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.ModuleTypeManager;
|
||||
import icons.PythonIcons;
|
||||
@@ -30,7 +32,14 @@ public abstract class PythonModuleTypeBase<T extends ModuleBuilder> extends Modu
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return "Python modules are used for developing <b>Python</b> applications. Supported technologies include <b>Django, Google App Engine, Mako, Jinja2</b> and others.";
|
||||
String basicDescription = "Python modules are used for developing <b>Python</b> applications.";
|
||||
FacetType[] facetTypes = Extensions.getExtensions(FacetType.EP_NAME);
|
||||
for (FacetType type : facetTypes) {
|
||||
if (type.getId().toString().equalsIgnoreCase("django")) {
|
||||
return basicDescription + " Supported technologies include <b>Django, Google App Engine, Mako, Jinja2</b> and others.";
|
||||
}
|
||||
}
|
||||
return basicDescription;
|
||||
}
|
||||
|
||||
public Icon getBigIcon() {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PyUserSkeletonsUtil {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
result.add(PathManager.getConfigPath() + File.separator + USER_SKELETONS_DIR);
|
||||
result.add(ApplicationManager.getApplication().isInternal()
|
||||
? StringUtil.join(new String[]{PathManager.getHomePath(), "python", "helpers", USER_SKELETONS_DIR}, File.separator)
|
||||
? StringUtil.join(new String[]{PathManager.getHomePath(), "python", "community", "helpers", USER_SKELETONS_DIR}, File.separator)
|
||||
: PythonHelpersLocator.getHelperPath(USER_SKELETONS_DIR));
|
||||
return result;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class PyUserSkeletonsUtil {
|
||||
public static VirtualFile getUserSkeletonsDirectory() {
|
||||
if (ourUserSkeletonsDirectory == null) {
|
||||
for (String path : getPossibleUserSkeletonsPaths()) {
|
||||
ourUserSkeletonsDirectory = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
|
||||
ourUserSkeletonsDirectory = LocalFileSystem.getInstance().findFileByPath(path);
|
||||
if (ourUserSkeletonsDirectory != null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -176,6 +176,21 @@ public class PyCallExpressionHelper {
|
||||
else if (PyNames.STATICMETHOD.equals(wrapper_name)) wrappedModifier = PyFunction.Modifier.STATICMETHOD;
|
||||
}
|
||||
}
|
||||
final List<PyExpression> qualifiers = resolveResult != null ? resolveResult.getQualifiers() : Collections.<PyExpression>emptyList();
|
||||
final TypeEvalContext context = resolveContext.getTypeEvalContext();
|
||||
if (resolved instanceof PyFunction) {
|
||||
final PyFunction function = (PyFunction)resolved;
|
||||
final Property property = function.getProperty();
|
||||
if (property != null && isQualifiedByInstance(function, qualifiers, context)) {
|
||||
final PyType type = function.getReturnType(context, null);
|
||||
if (type instanceof PyFunctionType) {
|
||||
resolved = ((PyFunctionType)type).getCallable();
|
||||
}
|
||||
else {
|
||||
resolved = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resolved instanceof Callable) {
|
||||
PyFunction.Modifier modifier = resolved instanceof PyFunction
|
||||
? ((PyFunction)resolved).getModifier()
|
||||
@@ -183,12 +198,10 @@ public class PyCallExpressionHelper {
|
||||
if (modifier == null && wrappedModifier != null) {
|
||||
modifier = wrappedModifier;
|
||||
}
|
||||
List<PyExpression> qualifiers = resolveResult != null ? resolveResult.getQualifiers() : Collections.<PyExpression>emptyList();
|
||||
boolean isByInstance = isConstructorCall ||
|
||||
isQualifiedByInstance((Callable)resolved, qualifiers, resolveContext.getTypeEvalContext())
|
||||
|| resolved instanceof PyBoundFunction;
|
||||
boolean isByInstance = isConstructorCall || isQualifiedByInstance((Callable)resolved, qualifiers, context)
|
||||
|| resolved instanceof PyBoundFunction;
|
||||
PyExpression lastQualifier = qualifiers != null && qualifiers.isEmpty() ? null : qualifiers.get(qualifiers.size()-1);
|
||||
boolean isByClass = lastQualifier == null ? false : isQualifiedByClass((Callable)resolved, lastQualifier, resolveContext.getTypeEvalContext());
|
||||
boolean isByClass = lastQualifier == null ? false : isQualifiedByClass((Callable)resolved, lastQualifier, context);
|
||||
final Callable callable = (Callable)resolved;
|
||||
|
||||
implicitOffset += getImplicitArgumentCount(callable, modifier, isConstructorCall, isByInstance, isByClass);
|
||||
@@ -408,6 +421,12 @@ public class PyCallExpressionHelper {
|
||||
if (t != null && !(t instanceof PyNoneType)) {
|
||||
return t;
|
||||
}
|
||||
if (cls != null && t == null) {
|
||||
final PyFunction newMethod = cls.findMethodByName(PyNames.NEW, true);
|
||||
if (newMethod != null && !PyBuiltinCache.getInstance(call).hasInBuiltins(newMethod)) {
|
||||
return PyUnionType.createWeakType(new PyClassTypeImpl(cls, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
return new PyClassTypeImpl(cls, false);
|
||||
|
||||
@@ -165,7 +165,26 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
|
||||
PyParameterList parameterList = (PyParameterList)parent;
|
||||
PyFunction func = parameterList.getContainingFunction();
|
||||
if (func != null) {
|
||||
final PyFunction.Modifier modifier = func.getModifier();
|
||||
PyAnnotation anno = getAnnotation();
|
||||
if (anno != null) {
|
||||
final PyClass pyClass = anno.resolveToClass();
|
||||
if (pyClass != null) {
|
||||
return new PyClassTypeImpl(pyClass, false);
|
||||
}
|
||||
}
|
||||
StructuredDocString docString = func.getStructuredDocString();
|
||||
if (PyNames.INIT.equals(func.getName()) && docString == null) {
|
||||
PyClass pyClass = func.getContainingClass();
|
||||
if (pyClass != null) {
|
||||
docString = pyClass.getStructuredDocString();
|
||||
}
|
||||
}
|
||||
if (docString != null) {
|
||||
String typeName = docString.getParamType(getName());
|
||||
if (typeName != null) {
|
||||
return PyTypeParser.getTypeByName(this, typeName);
|
||||
}
|
||||
}
|
||||
if (isSelf()) {
|
||||
// must be 'self' or 'cls'
|
||||
final PyClass containingClass = func.getContainingClass();
|
||||
@@ -190,6 +209,7 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
|
||||
if (initType != null && !(initType instanceof PyNoneType)) {
|
||||
return initType;
|
||||
}
|
||||
final PyFunction.Modifier modifier = func.getModifier();
|
||||
return new PyClassTypeImpl(containingClass, modifier == PyFunction.Modifier.CLASSMETHOD);
|
||||
}
|
||||
}
|
||||
@@ -199,27 +219,6 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
|
||||
if (isPositionalContainer()) {
|
||||
return PyBuiltinCache.getInstance(this).getTupleType();
|
||||
}
|
||||
PyAnnotation anno = getAnnotation();
|
||||
if (anno != null) {
|
||||
final PyClass pyClass = anno.resolveToClass();
|
||||
if (pyClass != null) {
|
||||
return new PyClassTypeImpl(pyClass, false);
|
||||
}
|
||||
}
|
||||
|
||||
StructuredDocString docString = func.getStructuredDocString();
|
||||
if (PyNames.INIT.equals(func.getName()) && docString == null) {
|
||||
PyClass pyClass = func.getContainingClass();
|
||||
if (pyClass != null) {
|
||||
docString = pyClass.getStructuredDocString();
|
||||
}
|
||||
}
|
||||
if (docString != null) {
|
||||
String typeName = docString.getParamType(getName());
|
||||
if (typeName != null) {
|
||||
return PyTypeParser.getTypeByName(this, typeName);
|
||||
}
|
||||
}
|
||||
for(PyTypeProvider provider: Extensions.getExtensions(PyTypeProvider.EP_NAME)) {
|
||||
PyType result = provider.getParameterType(this, func, context);
|
||||
if (result != null) return result;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class C(object):
|
||||
@property
|
||||
def f(self):
|
||||
return lambda x, y: (x, y)
|
||||
|
||||
|
||||
c = C()
|
||||
c.f(1, 2)
|
||||
c.f(<warning descr="Parameter 'x' unfilled"><warning descr="Parameter 'y' unfilled">)</warning></warning>
|
||||
c.f(1, 2, <warning descr="Unexpected argument">3</warning>)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
from b import C
|
||||
|
||||
c = C()
|
||||
c.foo()
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C(object):
|
||||
def __new__(cls):
|
||||
return D()
|
||||
|
||||
|
||||
class D(object):
|
||||
def foo(self):
|
||||
pass
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.jetbrains.python.quickFixes;
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.inspections.PyUnresolvedReferencesInspection;
|
||||
|
||||
/**
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.jetbrains.python.quickFixes;
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.inspections.PyClassHasNoInitInspection;
|
||||
import com.jetbrains.python.inspections.PyUnresolvedReferencesInspection;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.jetbrains.python.fixtures.PyResolveTestCase;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
|
||||
@@ -14,13 +15,13 @@ import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
|
||||
public class Py3ResolveTest extends PyResolveTestCase {
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return ourPy3Descriptor;
|
||||
return PyTestCase.ourPy3Descriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement doResolve() {
|
||||
myFixture.configureByFile("resolve/" + getTestName(false) + ".py");
|
||||
final PsiReference ref = findReferenceByMarker(myFixture.getFile());
|
||||
final PsiReference ref = PyResolveTestCase.findReferenceByMarker(myFixture.getFile());
|
||||
return ref.resolve();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.jetbrains.python.psi.PyAssignmentStatement;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PySubscriptionExpression;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,134 +27,134 @@ public class PyAssignmentMappingTest extends LightMarkedTestCase {
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(2, marks.size());
|
||||
Assert.assertEquals(2, marks.size());
|
||||
PsiElement src = marks.get("<src>").getParent(); // const -> expr;
|
||||
PsiElement dst = marks.get("<dst>").getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PyTargetExpression);
|
||||
Assert.assertTrue(dst instanceof PyTargetExpression);
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)dst.getParent();
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(1, mapping.size());
|
||||
Assert.assertEquals(1, mapping.size());
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(0);
|
||||
assertEquals(dst, pair.getFirst());
|
||||
assertEquals(src, pair.getSecond());
|
||||
Assert.assertEquals(dst, pair.getFirst());
|
||||
Assert.assertEquals(src, pair.getSecond());
|
||||
}
|
||||
|
||||
public void testSubscribedSource() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(2, marks.size());
|
||||
Assert.assertEquals(2, marks.size());
|
||||
PsiElement src = marks.get("<src>").getParent().getParent(); // const -> ref foo -> subscr expr;
|
||||
PsiElement dst = marks.get("<dst>").getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PyTargetExpression);
|
||||
Assert.assertTrue(dst instanceof PyTargetExpression);
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)dst.getParent();
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(1, mapping.size());
|
||||
Assert.assertEquals(1, mapping.size());
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(0);
|
||||
assertEquals(dst, pair.getFirst());
|
||||
assertEquals(src, pair.getSecond());
|
||||
Assert.assertEquals(dst, pair.getFirst());
|
||||
Assert.assertEquals(src, pair.getSecond());
|
||||
}
|
||||
|
||||
public void testSubscribedTarget() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(2, marks.size());
|
||||
Assert.assertEquals(2, marks.size());
|
||||
PsiElement src = marks.get("<src>").getParent(); // const -> expr;
|
||||
PsiElement dst = marks.get("<dst>").getParent().getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PySubscriptionExpression);
|
||||
Assert.assertTrue(dst instanceof PySubscriptionExpression);
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)src.getParent();
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(1, mapping.size());
|
||||
Assert.assertEquals(1, mapping.size());
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(0);
|
||||
assertEquals(dst, pair.getFirst());
|
||||
assertEquals(src, pair.getSecond());
|
||||
Assert.assertEquals(dst, pair.getFirst());
|
||||
Assert.assertEquals(src, pair.getSecond());
|
||||
}
|
||||
|
||||
|
||||
public void testMultiple() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
final int TARGET_NUM = 3;
|
||||
assertEquals(TARGET_NUM+1, marks.size());
|
||||
Assert.assertEquals(TARGET_NUM + 1, marks.size());
|
||||
PsiElement src = marks.get("<src>").getParent(); // const -> expr;
|
||||
PsiElement[] dsts = new PsiElement[TARGET_NUM];
|
||||
for (int i=0; i<TARGET_NUM; i+=1) {
|
||||
PsiElement dst = marks.get("<dst" + String.valueOf(i+1) +">").getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PyTargetExpression);
|
||||
Assert.assertTrue(dst instanceof PyTargetExpression);
|
||||
dsts[i] = dst;
|
||||
}
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)src.getParent();
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(TARGET_NUM, mapping.size());
|
||||
Assert.assertEquals(TARGET_NUM, mapping.size());
|
||||
for (int i=0; i<TARGET_NUM; i+=1) {
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(i);
|
||||
assertEquals(dsts[i], pair.getFirst());
|
||||
assertEquals(src, pair.getSecond());
|
||||
Assert.assertEquals(dsts[i], pair.getFirst());
|
||||
Assert.assertEquals(src, pair.getSecond());
|
||||
}
|
||||
}
|
||||
|
||||
public void testTupleMapped() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
final int PAIR_NUM = 2;
|
||||
assertEquals(PAIR_NUM*2, marks.size());
|
||||
Assert.assertEquals(PAIR_NUM * 2, marks.size());
|
||||
PsiElement[] srcs = new PsiElement[PAIR_NUM];
|
||||
PsiElement[] dsts = new PsiElement[PAIR_NUM];
|
||||
for (int i=0; i<PAIR_NUM; i+=1) {
|
||||
PsiElement dst = marks.get("<dst" + String.valueOf(i+1) +">").getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PyTargetExpression);
|
||||
Assert.assertTrue(dst instanceof PyTargetExpression);
|
||||
dsts[i] = dst;
|
||||
PsiElement src = marks.get("<src" + String.valueOf(i+1) +">").getParent(); // ident -> target expr
|
||||
assertTrue(src instanceof PyExpression);
|
||||
Assert.assertTrue(src instanceof PyExpression);
|
||||
srcs[i] = src;
|
||||
}
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)srcs[0].getParent().getParent(); // tuple expr -> assignment
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(PAIR_NUM, mapping.size());
|
||||
Assert.assertEquals(PAIR_NUM, mapping.size());
|
||||
for (int i=0; i<PAIR_NUM; i+=1) {
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(i);
|
||||
assertEquals(dsts[i], pair.getFirst());
|
||||
assertEquals(srcs[i], pair.getSecond());
|
||||
Assert.assertEquals(dsts[i], pair.getFirst());
|
||||
Assert.assertEquals(srcs[i], pair.getSecond());
|
||||
}
|
||||
}
|
||||
|
||||
public void testParenthesizedTuple() throws Exception { //PY-2648
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
final int PAIR_NUM = 2;
|
||||
assertEquals(PAIR_NUM*2, marks.size());
|
||||
Assert.assertEquals(PAIR_NUM * 2, marks.size());
|
||||
PsiElement[] srcs = new PsiElement[PAIR_NUM];
|
||||
PsiElement[] dsts = new PsiElement[PAIR_NUM];
|
||||
for (int i=0; i<PAIR_NUM; i+=1) {
|
||||
PsiElement dst = marks.get("<dst" + String.valueOf(i + 1) + ">").getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PyTargetExpression);
|
||||
Assert.assertTrue(dst instanceof PyTargetExpression);
|
||||
dsts[i] = dst;
|
||||
PsiElement src = marks.get("<src" + String.valueOf(i + 1) + ">").getParent(); // ident -> target expr
|
||||
assertTrue(src instanceof PyExpression);
|
||||
Assert.assertTrue(src instanceof PyExpression);
|
||||
srcs[i] = src;
|
||||
}
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)srcs[0].getParent().getParent().getParent(); // tuple expr -> assignment
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(PAIR_NUM, mapping.size());
|
||||
Assert.assertEquals(PAIR_NUM, mapping.size());
|
||||
for (int i=0; i<PAIR_NUM; i+=1) {
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(i);
|
||||
assertEquals(dsts[i], pair.getFirst());
|
||||
assertEquals(srcs[i], pair.getSecond());
|
||||
Assert.assertEquals(dsts[i], pair.getFirst());
|
||||
Assert.assertEquals(srcs[i], pair.getSecond());
|
||||
}
|
||||
}
|
||||
|
||||
public void testTuplePack() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
final int SRC_NUM = 2;
|
||||
assertEquals(SRC_NUM+1, marks.size());
|
||||
Assert.assertEquals(SRC_NUM + 1, marks.size());
|
||||
PsiElement[] srcs = new PsiElement[SRC_NUM];
|
||||
for (int i=0; i<SRC_NUM; i+=1) {
|
||||
PsiElement src = marks.get("<src" + String.valueOf(i+1) +">").getParent(); // ident -> target expr
|
||||
assertTrue(src instanceof PyExpression);
|
||||
Assert.assertTrue(src instanceof PyExpression);
|
||||
srcs[i] = src;
|
||||
}
|
||||
PsiElement dst = marks.get("<dst>").getParent(); // ident -> target expr
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)dst.getParent();
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(1, mapping.size());
|
||||
Assert.assertEquals(1, mapping.size());
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(0);
|
||||
assertEquals(dst, pair.getFirst());
|
||||
Assert.assertEquals(dst, pair.getFirst());
|
||||
for (PsiElement src : srcs) {
|
||||
assertEquals(src.getParent(), pair.getSecond()); // numeric expr -> tuple
|
||||
Assert.assertEquals(src.getParent(), pair.getSecond()); // numeric expr -> tuple
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,28 +162,28 @@ public class PyAssignmentMappingTest extends LightMarkedTestCase {
|
||||
public void testTupleUnpack() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
final int DST_NUM = 2;
|
||||
assertEquals(DST_NUM+3, marks.size());
|
||||
Assert.assertEquals(DST_NUM + 3, marks.size());
|
||||
PsiElement[] dsts = new PsiElement[DST_NUM];
|
||||
for (int i=0; i<DST_NUM; i+=1) {
|
||||
PsiElement dst = marks.get("<dst" + String.valueOf(i+1) +">").getParent(); // ident -> target expr
|
||||
assertTrue(dst instanceof PyTargetExpression);
|
||||
Assert.assertTrue(dst instanceof PyTargetExpression);
|
||||
dsts[i] = dst;
|
||||
}
|
||||
PsiElement[] srcs = new PsiElement[DST_NUM];
|
||||
for (int i=0; i<DST_NUM; i+=1) {
|
||||
PsiElement src = marks.get("<src" + String.valueOf(i+1) +">").getParent().getParent().getParent(); // ident -> target expr
|
||||
assertTrue(src instanceof PyExpression);
|
||||
Assert.assertTrue(src instanceof PyExpression);
|
||||
srcs[i] = src;
|
||||
}
|
||||
|
||||
PsiElement src = marks.get("<src>").getParent(); // ident -> target expr
|
||||
PyAssignmentStatement stmt = (PyAssignmentStatement)src.getParent().getParent();
|
||||
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
|
||||
assertEquals(DST_NUM, mapping.size());
|
||||
Assert.assertEquals(DST_NUM, mapping.size());
|
||||
for (int i=0; i<DST_NUM; i+=1) {
|
||||
Pair<PyExpression, PyExpression> pair = mapping.get(i);
|
||||
assertEquals(dsts[i], pair.getFirst());
|
||||
assertEquals(srcs[i].getText(), pair.getSecond().getText());
|
||||
Assert.assertEquals(dsts[i], pair.getFirst());
|
||||
Assert.assertEquals(srcs[i].getText(), pair.getSecond().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ControlFlowCache;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.fixtures.LightMarkedTestCase;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -236,10 +238,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
|
||||
for (Instruction instruction : instructions) {
|
||||
buffer.append(instruction).append("\n");
|
||||
}
|
||||
final VirtualFile vFile = getVirtualFileByName(fullPath);
|
||||
final VirtualFile vFile = PyTestCase.getVirtualFileByName(fullPath);
|
||||
try {
|
||||
final String fileText = StringUtil.convertLineSeparators(VfsUtil.loadText(vFile), "\n");
|
||||
assertEquals(fileText.trim(), buffer.toString().trim());
|
||||
Assert.assertEquals(fileText.trim(), buffer.toString().trim());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.jetbrains.python.quickFixes;
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.inspections.PyMethodMayBeStaticInspection;
|
||||
|
||||
/**
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.jetbrains.python.quickFixes;
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.inspections.PyMethodMayBeStaticInspection;
|
||||
|
||||
/**
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package com.jetbrains.python.quickFixes;
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.inspections.PyAttributeOutsideInitInspection;
|
||||
|
||||
/**
|
||||
@@ -1,20 +1,14 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.jetbrains.cython.psi.CythonFunction;
|
||||
import com.jetbrains.cython.psi.CythonVariable;
|
||||
import com.jetbrains.python.fixtures.PyResolveTestCase;
|
||||
import com.jetbrains.python.fixtures.PyMultiFileResolveTestCase;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyMultiFileResolveTest extends PyResolveTestCase {
|
||||
protected String myTestFileName;
|
||||
public class PyMultiFileResolveTest extends PyMultiFileResolveTestCase {
|
||||
|
||||
private static void checkInitPyDir(PsiElement elt, String dirname) {
|
||||
assertTrue(elt instanceof PyFile);
|
||||
@@ -266,96 +260,6 @@ public class PyMultiFileResolveTest extends PyResolveTestCase {
|
||||
myTestFileName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void testCythonFromModuleCImport() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
public void testCythonFromModuleCImportAs() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
public void testCythonFromModuleCImportStar() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
public void testCythonFromPackageCImportAttribute() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
public void testCythonFromPackageCImportModule() {
|
||||
assertResolvesTo(PyFile.class, "m1.pxd");
|
||||
}
|
||||
|
||||
public void testCythonFromPackageCImportPackage() {
|
||||
assertResolvesTo(PyFile.class, "__init__.pxd");
|
||||
}
|
||||
|
||||
public void testCythonCImportAttribute() {
|
||||
assertResolvesTo(PyFile.class, "m1.pxd");
|
||||
}
|
||||
|
||||
public void testCythonCImportPackage() {
|
||||
assertResolvesTo(PyFile.class, "__init__.pxd");
|
||||
}
|
||||
|
||||
public void testCythonCImportModule() {
|
||||
assertResolvesTo(PyFile.class, "m1.pxd");
|
||||
}
|
||||
|
||||
public void testCythonImplicitCImport() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
public void testCythonInclude() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
// PY-4843
|
||||
public void testCythonFromSubmoduleAbsoluteCImport() {
|
||||
prepareTestDirectory();
|
||||
final VirtualFile file = myFixture.findFileInTempDir("p1/m2.pyx");
|
||||
assertNotNull("Could not find test file", file);
|
||||
final PsiFile psiFile = myFixture.getPsiManager().findFile(file);
|
||||
PsiElement element = doResolve(psiFile);
|
||||
assertInstanceOf(element, CythonVariable.class);
|
||||
assertEquals("foo", ((PsiNamedElement)element).getName());
|
||||
}
|
||||
|
||||
// PY-4844
|
||||
public void testCythonFromModuleCImportExternStar() {
|
||||
assertResolvesTo(CythonVariable.class, "foo");
|
||||
}
|
||||
|
||||
public void testCythonCdefClassForwardInclude() {
|
||||
final PyTargetExpression target = assertResolvesTo(PyTargetExpression.class, "bar");
|
||||
final PyExpression value = target.findAssignedValue();
|
||||
assertNotNull(value);
|
||||
final PsiReference ref = value.getReference();
|
||||
assertNotNull(ref);
|
||||
final PsiElement field = ref.resolve();
|
||||
assertNotNull(field);
|
||||
assertInstanceOf(field, CythonVariable.class);
|
||||
assertEquals("foo", ((PsiNamedElement)field).getName());
|
||||
}
|
||||
|
||||
public void testCythonImportFromPython() {
|
||||
assertResolvesTo(CythonFunction.class, "foo");
|
||||
}
|
||||
|
||||
// PY-4946
|
||||
public void testCythonCdefClassAttributeInDefinition() {
|
||||
final PyTargetExpression target = assertResolvesTo(PyTargetExpression.class, "foo");
|
||||
final PyExpression value = target.findAssignedValue();
|
||||
assertNotNull(value);
|
||||
final PsiReference ref = value.getReference();
|
||||
assertNotNull(ref);
|
||||
final PsiElement field = ref.resolve();
|
||||
assertNotNull(field);
|
||||
assertInstanceOf(field, CythonVariable.class);
|
||||
assertEquals("x", ((PsiNamedElement)field).getName());
|
||||
}
|
||||
|
||||
// PY-2813
|
||||
public void testFromNamespacePackageImport() {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
@@ -441,70 +345,12 @@ public class PyMultiFileResolveTest extends PyResolveTestCase {
|
||||
public void testFromPackageModuleImportElementNamedAsModule() {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
final PsiManager psiManager = myFixture.getPsiManager();
|
||||
assertNotParsed((PyFile)psiManager.findFile(myFixture.findFileInTempDir("p1/__init__.py")));
|
||||
assertNotParsed((PyFile)psiManager.findFile(myFixture.findFileInTempDir("p1/foo.py")));
|
||||
PyTestCase.assertNotParsed((PyFile)psiManager.findFile(myFixture.findFileInTempDir("p1/__init__.py")));
|
||||
PyTestCase.assertNotParsed((PyFile)psiManager.findFile(myFixture.findFileInTempDir("p1/foo.py")));
|
||||
}
|
||||
|
||||
// PY-10819
|
||||
public void testFromPackageModuleImportStarElementNamedAsModule() {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
}
|
||||
|
||||
private void prepareTestDirectory() {
|
||||
final String testName = getTestName(true);
|
||||
myFixture.copyDirectoryToProject(testName, "");
|
||||
PsiDocumentManager.getInstance(myFixture.getProject()).commitAllDocuments();
|
||||
}
|
||||
|
||||
private PsiFile prepareFile() {
|
||||
prepareTestDirectory();
|
||||
VirtualFile sourceFile = null;
|
||||
for (String ext : new String[]{".py", ".pyx"}) {
|
||||
final String fileName = myTestFileName != null ? myTestFileName : getTestName(false) + ext;
|
||||
sourceFile = myFixture.findFileInTempDir(fileName);
|
||||
if (sourceFile != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull("Could not find test file", sourceFile);
|
||||
return myFixture.getPsiManager().findFile(sourceFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PythonTestUtil.getTestDataPath() + "/resolve/multiFile/";
|
||||
}
|
||||
|
||||
protected PsiElement doResolve(PsiFile psiFile) {
|
||||
final PsiPolyVariantReference ref = findReferenceByMarker(psiFile);
|
||||
final PsiManagerImpl psiManager = (PsiManagerImpl)myFixture.getPsiManager();
|
||||
psiManager.setAssertOnFileLoadingFilter(new VirtualFileFilter() {
|
||||
@Override
|
||||
public boolean accept(VirtualFile file) {
|
||||
FileType fileType = file.getFileType();
|
||||
return fileType == PythonFileType.INSTANCE;
|
||||
}
|
||||
});
|
||||
try {
|
||||
final ResolveResult[] resolveResults = ref.multiResolve(false);
|
||||
if (resolveResults.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return resolveResults[0].isValidResult() ? resolveResults[0].getElement() : null;
|
||||
}
|
||||
finally {
|
||||
psiManager.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement doResolve() {
|
||||
return doResolve(prepareFile());
|
||||
}
|
||||
|
||||
private ResolveResult[] doMultiResolve() {
|
||||
PsiFile psiFile = prepareFile();
|
||||
final PsiPolyVariantReference ref = findReferenceByMarker(psiFile);
|
||||
return ref.multiResolve(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.util.containers.HashSet;
|
||||
import com.jetbrains.python.fixtures.LightMarkedTestCase;
|
||||
import com.jetbrains.python.psi.CallArgumentsMapping;
|
||||
import com.jetbrains.python.psi.PyArgumentList;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -35,7 +36,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
|
||||
protected Map<String, PsiElement> loadTest(int expected_marks) {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals("Test data sanity", marks.size(), expected_marks);
|
||||
Assert.assertEquals("Test data sanity", marks.size(), expected_marks);
|
||||
return marks;
|
||||
}
|
||||
|
||||
@@ -402,7 +403,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
final PyArgumentList parameterOwner = handler.findElementForParameterInfo(collector);
|
||||
collector.setParameterOwner(parameterOwner); // finds arglist, sets items to show
|
||||
if (collector.getParameterOwner() != null) {
|
||||
assertEquals("Collected one analysis result", 1, collector.myItems.length);
|
||||
Assert.assertEquals("Collected one analysis result", 1, collector.myItems.length);
|
||||
handler.updateParameterInfo((PyArgumentList)collector.getParameterOwner(), collector); // moves offset to correct parameter
|
||||
handler.updateUI((CallArgumentsMapping)collector.getItemsToShow()[0], collector); // sets hint text and flags
|
||||
}
|
||||
@@ -472,7 +473,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
|
||||
@Override
|
||||
public void setParameterOwner(PsiElement o) {
|
||||
assertTrue("Found element is a python arglist", o == null || o instanceof PyArgumentList);
|
||||
Assert.assertTrue("Found element is a python arglist", o == null || o instanceof PyArgumentList);
|
||||
myParamOwner = (PyArgumentList)o;
|
||||
}
|
||||
|
||||
@@ -557,7 +558,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
* @param disabled expected disabled substrings of hint
|
||||
*/
|
||||
public void check(String text, String[] highlighted, String[] disabled) {
|
||||
assertEquals("Signature", text, StringUtil.join(myTexts, ""));
|
||||
Assert.assertEquals("Signature", text, StringUtil.join(myTexts, ""));
|
||||
StringBuilder wrongs = new StringBuilder();
|
||||
// see if highlighted matches
|
||||
Set<String> highlightSet = new HashSet<String>();
|
||||
@@ -586,7 +587,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
}
|
||||
}
|
||||
//
|
||||
if (wrongs.length() > 0) fail(wrongs.toString());
|
||||
if (wrongs.length() > 0) Assert.fail(wrongs.toString());
|
||||
}
|
||||
|
||||
public void check(String text, String[] highlighted) {
|
||||
@@ -594,7 +595,7 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
|
||||
}
|
||||
|
||||
public void assertNotFound() {
|
||||
assertNull(myParamOwner);
|
||||
Assert.assertNull(myParamOwner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.testFramework.TestDataFile;
|
||||
import com.jetbrains.python.documentation.PythonDocumentationProvider;
|
||||
import com.jetbrains.python.fixtures.LightMarkedTestCase;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -27,14 +29,14 @@ public class PyQuickDocTest extends LightMarkedTestCase {
|
||||
}
|
||||
|
||||
private void checkByHTML(String text) {
|
||||
assertNotNull(text);
|
||||
Assert.assertNotNull(text);
|
||||
checkByHTML(text, "/quickdoc/" + getTestName(false) + ".html");
|
||||
}
|
||||
|
||||
private void checkByHTML(String text, @TestDataFile String filePath) {
|
||||
final String fullPath = getTestDataPath() + filePath;
|
||||
final VirtualFile vFile = getVirtualFileByName(fullPath);
|
||||
assertNotNull("file " + fullPath + " not found", vFile);
|
||||
final VirtualFile vFile = PyTestCase.getVirtualFileByName(fullPath);
|
||||
Assert.assertNotNull("file " + fullPath + " not found", vFile);
|
||||
|
||||
String loadedText;
|
||||
try {
|
||||
@@ -44,7 +46,7 @@ public class PyQuickDocTest extends LightMarkedTestCase {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String fileText = StringUtil.convertLineSeparators(loadedText, "\n");
|
||||
assertEquals(fileText.trim(), text.trim());
|
||||
Assert.assertEquals(fileText.trim(), text.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,16 +56,16 @@ public class PyQuickDocTest extends LightMarkedTestCase {
|
||||
|
||||
private void checkRefDocPair() {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(2, marks.size());
|
||||
Assert.assertEquals(2, marks.size());
|
||||
final PsiElement original_elt = marks.get("<the_doc>");
|
||||
PsiElement doc_elt = original_elt.getParent(); // ident -> expr
|
||||
assertTrue(doc_elt instanceof PyStringLiteralExpression);
|
||||
Assert.assertTrue(doc_elt instanceof PyStringLiteralExpression);
|
||||
String doc_text = ((PyStringLiteralExpression)doc_elt).getStringValue();
|
||||
assertNotNull(doc_text);
|
||||
Assert.assertNotNull(doc_text);
|
||||
|
||||
PsiElement ref_elt = marks.get("<the_ref>").getParent(); // ident -> expr
|
||||
final PyDocStringOwner doc_owner = (PyDocStringOwner)((PyReferenceExpression)ref_elt).getReference().resolve();
|
||||
assertEquals(doc_elt, doc_owner.getDocStringExpression());
|
||||
Assert.assertEquals(doc_elt, doc_owner.getDocStringExpression());
|
||||
|
||||
checkByHTML(myProvider.generateDoc(doc_owner, original_elt));
|
||||
}
|
||||
@@ -127,15 +129,15 @@ public class PyQuickDocTest extends LightMarkedTestCase {
|
||||
|
||||
public void testInheritedMethod() {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(2, marks.size());
|
||||
Assert.assertEquals(2, marks.size());
|
||||
PsiElement doc_elt = marks.get("<the_doc>").getParent(); // ident -> expr
|
||||
assertTrue(doc_elt instanceof PyStringLiteralExpression);
|
||||
Assert.assertTrue(doc_elt instanceof PyStringLiteralExpression);
|
||||
String doc_text = ((PyStringLiteralExpression)doc_elt).getStringValue();
|
||||
assertNotNull(doc_text);
|
||||
Assert.assertNotNull(doc_text);
|
||||
|
||||
PsiElement ref_elt = marks.get("<the_ref>").getParent(); // ident -> expr
|
||||
final PyDocStringOwner doc_owner = (PyDocStringOwner)((PyReferenceExpression)ref_elt).getReference().resolve();
|
||||
assertNull(doc_owner.getDocStringExpression()); // no direct doc!
|
||||
Assert.assertNull(doc_owner.getDocStringExpression()); // no direct doc!
|
||||
|
||||
checkByHTML(myProvider.generateDoc(doc_owner, null));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.jetbrains.python.quickFixes;
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
@@ -5,6 +5,7 @@ import com.intellij.psi.PsiPolyVariantReference;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.ResolveResult;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
|
||||
import com.jetbrains.python.fixtures.PyResolveTestCase;
|
||||
@@ -12,6 +13,7 @@ import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
|
||||
import com.jetbrains.python.psi.resolve.ImportedResolveResult;
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class PyResolveTest extends PyResolveTestCase {
|
||||
@Override
|
||||
@@ -22,7 +24,7 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
private PsiReference findReferenceByMarker() {
|
||||
myFixture.configureByFile("resolve/" + getTestName(false) + ".py");
|
||||
return findReferenceByMarker(myFixture.getFile());
|
||||
return PyResolveTestCase.findReferenceByMarker(myFixture.getFile());
|
||||
}
|
||||
|
||||
protected PsiElement resolve() {
|
||||
@@ -33,7 +35,7 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
private ResolveResult[] multiResolve() {
|
||||
PsiReference ref = findReferenceByMarker();
|
||||
assertTrue(ref instanceof PsiPolyVariantReference);
|
||||
Assert.assertTrue(ref instanceof PsiPolyVariantReference);
|
||||
return ((PsiPolyVariantReference)ref).multiResolve(false);
|
||||
}
|
||||
|
||||
@@ -43,227 +45,227 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testFunc() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyFunction);
|
||||
Assert.assertTrue(targetElement instanceof PyFunction);
|
||||
}
|
||||
|
||||
public void testToConstructor() {
|
||||
PsiElement target = resolve();
|
||||
assertTrue(target instanceof PyFunction);
|
||||
assertEquals(PyNames.INIT, ((PyFunction)target).getName());
|
||||
Assert.assertTrue(target instanceof PyFunction);
|
||||
Assert.assertEquals(PyNames.INIT, ((PyFunction)target).getName());
|
||||
}
|
||||
|
||||
public void testToConstructorInherited() {
|
||||
ResolveResult[] targets = multiResolve();
|
||||
assertEquals(2, targets.length); // to class, to init
|
||||
Assert.assertEquals(2, targets.length); // to class, to init
|
||||
PsiElement elt;
|
||||
// class
|
||||
elt = targets[0].getElement();
|
||||
assertTrue(elt instanceof PyClass);
|
||||
assertEquals("Bar", ((PyClass)elt).getName());
|
||||
Assert.assertTrue(elt instanceof PyClass);
|
||||
Assert.assertEquals("Bar", ((PyClass)elt).getName());
|
||||
// init
|
||||
elt = targets[1].getElement();
|
||||
assertTrue(elt instanceof PyFunction);
|
||||
Assert.assertTrue(elt instanceof PyFunction);
|
||||
PyFunction fun = (PyFunction)elt;
|
||||
assertEquals(PyNames.INIT, fun.getName());
|
||||
Assert.assertEquals(PyNames.INIT, fun.getName());
|
||||
PyClass cls = fun.getContainingClass();
|
||||
assertNotNull(cls);
|
||||
assertEquals("Foo", cls.getName());
|
||||
Assert.assertNotNull(cls);
|
||||
Assert.assertEquals("Foo", cls.getName());
|
||||
}
|
||||
|
||||
// NOTE: maybe this test does not belong exactly here; still it's the best place currently.
|
||||
public void testComplexCallee() {
|
||||
PsiElement targetElement = resolve();
|
||||
PyExpression assigned = ((PyAssignmentStatement)targetElement.getContext()).getAssignedValue();
|
||||
assertTrue(assigned instanceof PyCallExpression);
|
||||
Assert.assertTrue(assigned instanceof PyCallExpression);
|
||||
PsiElement callee = ((PyCallExpression)assigned).getCallee();
|
||||
assertTrue(callee instanceof PySubscriptionExpression);
|
||||
Assert.assertTrue(callee instanceof PySubscriptionExpression);
|
||||
}
|
||||
|
||||
public void testVar() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testDefaultInClass() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNotNull(targetElement);
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertEquals("FOO", ((PyTargetExpression)targetElement).getName());
|
||||
Assert.assertNotNull(targetElement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertEquals("FOO", ((PyTargetExpression)targetElement).getName());
|
||||
}
|
||||
|
||||
public void testQualifiedFunc() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyFunction);
|
||||
Assert.assertTrue(targetElement instanceof PyFunction);
|
||||
}
|
||||
|
||||
public void testQualifiedVar() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testQualifiedTarget() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testQualifiedFalseTarget() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNull(targetElement);
|
||||
Assert.assertNull(targetElement);
|
||||
}
|
||||
|
||||
public void testInnerFuncVar() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testTupleInComprh() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testForStatement() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testExceptClause() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testLookAhead() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testLookAheadCapped() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testTryExceptElse() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testGlobal() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testGlobalDefinedLocally() {
|
||||
final PsiElement element = resolve();
|
||||
assertInstanceOf(element, PyTargetExpression.class);
|
||||
UsefulTestCase.assertInstanceOf(element, PyTargetExpression.class);
|
||||
final PsiElement parent = element.getParent();
|
||||
assertInstanceOf(parent, PyAssignmentStatement.class);
|
||||
UsefulTestCase.assertInstanceOf(parent, PyAssignmentStatement.class);
|
||||
}
|
||||
|
||||
public void testLambda() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyNamedParameter);
|
||||
Assert.assertTrue(targetElement instanceof PyNamedParameter);
|
||||
}
|
||||
|
||||
public void testLambdaParameterOutside() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testSuperField() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testFieldInCondition() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testMultipleFields() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testClassPeerMembers() {
|
||||
PsiElement target = resolve();
|
||||
assertTrue(target instanceof PyFunction);
|
||||
Assert.assertTrue(target instanceof PyFunction);
|
||||
}
|
||||
|
||||
public void testTuple() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testMultiTarget() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testMultiTargetTuple() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertNotNull(PsiTreeUtil.getParentOfType(targetElement, PyAssignmentStatement.class)); // it's deep in a tuple
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertNotNull(PsiTreeUtil.getParentOfType(targetElement, PyAssignmentStatement.class)); // it's deep in a tuple
|
||||
}
|
||||
|
||||
public void testWithStatement() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyWithItem);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyWithItem);
|
||||
}
|
||||
|
||||
public void testTupleInExcept() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(PsiTreeUtil.getParentOfType(targetElement, PyExceptPart.class) != null);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(PsiTreeUtil.getParentOfType(targetElement, PyExceptPart.class) != null);
|
||||
}
|
||||
|
||||
|
||||
public void testDocStringClass() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyStringLiteralExpression);
|
||||
assertEquals("Docstring of class Foo", ((PyStringLiteralExpression)targetElement).getStringValue());
|
||||
Assert.assertTrue(targetElement instanceof PyStringLiteralExpression);
|
||||
Assert.assertEquals("Docstring of class Foo", ((PyStringLiteralExpression)targetElement).getStringValue());
|
||||
}
|
||||
|
||||
public void testDocStringInstance() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyStringLiteralExpression);
|
||||
assertEquals("Docstring of class Foo", ((PyStringLiteralExpression)targetElement).getStringValue());
|
||||
Assert.assertTrue(targetElement instanceof PyStringLiteralExpression);
|
||||
Assert.assertEquals("Docstring of class Foo", ((PyStringLiteralExpression)targetElement).getStringValue());
|
||||
}
|
||||
|
||||
public void testDocStringFunction() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyStringLiteralExpression);
|
||||
assertEquals("Docstring of function bar", ((PyStringLiteralExpression)targetElement).getStringValue());
|
||||
Assert.assertTrue(targetElement instanceof PyStringLiteralExpression);
|
||||
Assert.assertEquals("Docstring of function bar", ((PyStringLiteralExpression)targetElement).getStringValue());
|
||||
}
|
||||
|
||||
public void testDocStringInvalid() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNull(targetElement);
|
||||
Assert.assertNull(targetElement);
|
||||
}
|
||||
|
||||
public void testFieldNotInInit() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testClassIsNotMemberOfItself() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNull(targetElement);
|
||||
Assert.assertNull(targetElement);
|
||||
}
|
||||
|
||||
public void testSuper() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyFunction);
|
||||
assertEquals("A", ((PyFunction) targetElement).getContainingClass().getName());
|
||||
Assert.assertTrue(targetElement instanceof PyFunction);
|
||||
Assert.assertEquals("A", ((PyFunction)targetElement).getContainingClass().getName());
|
||||
}
|
||||
|
||||
public void testSuperPy3k() { // PY-1330
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON30);
|
||||
try {
|
||||
final PyFunction pyFunction = assertResolvesTo(PyFunction.class, "foo");
|
||||
assertEquals("A", pyFunction.getContainingClass().getName());
|
||||
Assert.assertEquals("A", pyFunction.getContainingClass().getName());
|
||||
}
|
||||
finally {
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null);
|
||||
@@ -272,81 +274,81 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testStackOverflow() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNull(targetElement);
|
||||
Assert.assertNull(targetElement);
|
||||
}
|
||||
|
||||
public void testProperty() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyFunction);
|
||||
assertEquals("set_full_name", ((PyFunction)targetElement).getName());
|
||||
Assert.assertTrue(targetElement instanceof PyFunction);
|
||||
Assert.assertEquals("set_full_name", ((PyFunction)targetElement).getName());
|
||||
}
|
||||
|
||||
public void testLambdaWithParens() { // PY-882
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyParameter);
|
||||
Assert.assertTrue(targetElement instanceof PyParameter);
|
||||
}
|
||||
|
||||
public void testTextBasedResolve() {
|
||||
ResolveResult[] resolveResults = multiResolve();
|
||||
assertEquals(1, resolveResults.length);
|
||||
assertTrue(resolveResults [0].getElement() instanceof PyFunction);
|
||||
Assert.assertEquals(1, resolveResults.length);
|
||||
Assert.assertTrue(resolveResults[0].getElement() instanceof PyFunction);
|
||||
}
|
||||
|
||||
public void testClassPrivateInClass() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testClassPrivateInMethod() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testClassPrivateInMethodNested() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testClassPrivateInherited() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
Assert.assertTrue(targetElement instanceof PyTargetExpression);
|
||||
Assert.assertTrue(targetElement.getParent() instanceof PyAssignmentStatement);
|
||||
}
|
||||
|
||||
public void testClassPrivateOutsideClass() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNull(targetElement);
|
||||
Assert.assertNull(targetElement);
|
||||
}
|
||||
|
||||
public void testClassPrivateOutsideInstance() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertNull(targetElement);
|
||||
Assert.assertNull(targetElement);
|
||||
}
|
||||
|
||||
public void testClassNameEqualsMethodName() {
|
||||
PsiElement targetElement = resolve();
|
||||
assertInstanceOf(targetElement, PyFunction.class);
|
||||
UsefulTestCase.assertInstanceOf(targetElement, PyFunction.class);
|
||||
}
|
||||
|
||||
public void testUnresolvedImport() {
|
||||
final ResolveResult[] results = multiResolve();
|
||||
assertEquals(1, results.length);
|
||||
assertInstanceOf(results [0], ImportedResolveResult.class);
|
||||
Assert.assertEquals(1, results.length);
|
||||
UsefulTestCase.assertInstanceOf(results[0], ImportedResolveResult.class);
|
||||
ImportedResolveResult result = (ImportedResolveResult) results [0];
|
||||
assertNull(result.getElement());
|
||||
Assert.assertNull(result.getElement());
|
||||
}
|
||||
|
||||
public void testIsInstance() { // PY-1133
|
||||
PsiElement targetElement = resolve();
|
||||
assertInstanceOf(targetElement, PyNamedParameter.class);
|
||||
UsefulTestCase.assertInstanceOf(targetElement, PyNamedParameter.class);
|
||||
}
|
||||
|
||||
public void testListComprehension() { // PY-1143
|
||||
PsiElement targetElement = resolve();
|
||||
assertInstanceOf(targetElement, PyTargetExpression.class);
|
||||
UsefulTestCase.assertInstanceOf(targetElement, PyTargetExpression.class);
|
||||
}
|
||||
|
||||
public void testSuperMetaClass() {
|
||||
@@ -359,18 +361,18 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testSuperTwoClasses() { // PY-2133
|
||||
final PyFunction pyFunction = assertResolvesTo(PyFunction.class, "my_call");
|
||||
assertEquals("Base2", pyFunction.getContainingClass().getName());
|
||||
Assert.assertEquals("Base2", pyFunction.getContainingClass().getName());
|
||||
}
|
||||
|
||||
public void testLambdaDefaultParameter() {
|
||||
final PsiElement element = doResolve();
|
||||
assertInstanceOf(element, PyTargetExpression.class);
|
||||
assertTrue(element.getParent() instanceof PySetCompExpression);
|
||||
UsefulTestCase.assertInstanceOf(element, PyTargetExpression.class);
|
||||
Assert.assertTrue(element.getParent() instanceof PySetCompExpression);
|
||||
}
|
||||
|
||||
public void testListAssignment() {
|
||||
final PsiElement element = doResolve();
|
||||
assertInstanceOf(element, PyTargetExpression.class);
|
||||
UsefulTestCase.assertInstanceOf(element, PyTargetExpression.class);
|
||||
}
|
||||
|
||||
public void testStarUnpacking() { // PY-1459
|
||||
@@ -383,7 +385,7 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testBuiltinVsClassMember() { // PY-1654
|
||||
final PyFunction pyFunction = assertResolvesTo(PyFunction.class, "eval");
|
||||
assertEquals("__builtin__.py", pyFunction.getContainingFile().getName());
|
||||
Assert.assertEquals("__builtin__.py", pyFunction.getContainingFile().getName());
|
||||
}
|
||||
|
||||
public void testLambdaToClass() { // PY-2182
|
||||
@@ -396,7 +398,7 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testModuleToBuiltins() {
|
||||
final PsiElement element = doResolve();
|
||||
assertNull(element);
|
||||
Assert.assertNull(element);
|
||||
}
|
||||
|
||||
public void testWithParentheses() {
|
||||
@@ -413,7 +415,7 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testNoResolveIntoGenerator() { // PY-3030
|
||||
PyTargetExpression expr = assertResolvesTo(PyTargetExpression.class, "foo");
|
||||
assertEquals("foo = 1", expr.getParent().getText());
|
||||
Assert.assertEquals("foo = 1", expr.getParent().getText());
|
||||
}
|
||||
|
||||
public void testResolveInGenerator() {
|
||||
@@ -438,9 +440,9 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testImplicitResolveInstanceAttribute() {
|
||||
ResolveResult[] resolveResults = multiResolve();
|
||||
assertEquals(1, resolveResults.length);
|
||||
Assert.assertEquals(1, resolveResults.length);
|
||||
final PsiElement psiElement = resolveResults[0].getElement();
|
||||
assertTrue(psiElement instanceof PyTargetExpression && "xyzzy".equals(((PyTargetExpression)psiElement).getName()));
|
||||
Assert.assertTrue(psiElement instanceof PyTargetExpression && "xyzzy".equals(((PyTargetExpression)psiElement).getName()));
|
||||
}
|
||||
|
||||
public void testAttributeAssignedNearby() {
|
||||
@@ -449,15 +451,15 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
|
||||
public void testPreviousTarget() {
|
||||
PsiElement resolved = resolve();
|
||||
assertInstanceOf(resolved, PyTargetExpression.class);
|
||||
UsefulTestCase.assertInstanceOf(resolved, PyTargetExpression.class);
|
||||
PyTargetExpression target = (PyTargetExpression)resolved;
|
||||
PyExpression value = target.findAssignedValue();
|
||||
assertInstanceOf(value, PyNumericLiteralExpression.class);
|
||||
UsefulTestCase.assertInstanceOf(value, PyNumericLiteralExpression.class);
|
||||
}
|
||||
|
||||
public void testMetaclass() {
|
||||
final PyFunction function = assertResolvesTo(PyFunction.class, "getStore");
|
||||
assertEquals("PluginMetaclass", function.getContainingClass().getName());
|
||||
Assert.assertEquals("PluginMetaclass", function.getContainingClass().getName());
|
||||
}
|
||||
|
||||
// PY-6083
|
||||
@@ -492,9 +494,9 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
final PsiReference ref = findReferenceByMarker();
|
||||
final PsiElement source = ref.getElement();
|
||||
final PsiElement target = ref.resolve();
|
||||
assertNotNull(target);
|
||||
assertTrue(source != target);
|
||||
assertTrue(PyPsiUtils.isBefore(target, source));
|
||||
Assert.assertNotNull(target);
|
||||
Assert.assertTrue(source != target);
|
||||
Assert.assertTrue(PyPsiUtils.isBefore(target, source));
|
||||
}
|
||||
|
||||
// PY-7541
|
||||
@@ -502,8 +504,8 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
final PsiReference ref = findReferenceByMarker();
|
||||
final PsiElement source = ref.getElement();
|
||||
final PsiElement target = ref.resolve();
|
||||
assertNotNull(target);
|
||||
assertTrue(source == target);
|
||||
Assert.assertNotNull(target);
|
||||
Assert.assertTrue(source == target);
|
||||
}
|
||||
|
||||
// PY-7970
|
||||
@@ -516,12 +518,12 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
final PsiReference ref = findReferenceByMarker();
|
||||
final PsiElement source = ref.getElement();
|
||||
final PsiElement resolved = ref.resolve();
|
||||
assertInstanceOf(resolved, PyReferenceExpression.class);
|
||||
assertNotSame(resolved, source);
|
||||
UsefulTestCase.assertInstanceOf(resolved, PyReferenceExpression.class);
|
||||
Assert.assertNotSame(resolved, source);
|
||||
final PyReferenceExpression res = (PyReferenceExpression)resolved;
|
||||
assertNotNull(res);
|
||||
assertEquals("foo", res.getName());
|
||||
assertInstanceOf(res.getParent(), PyAugAssignmentStatement.class);
|
||||
Assert.assertNotNull(res);
|
||||
Assert.assertEquals("foo", res.getName());
|
||||
UsefulTestCase.assertInstanceOf(res.getParent(), PyAugAssignmentStatement.class);
|
||||
}
|
||||
|
||||
public void testGeneratorShadowing() { // PY-8725
|
||||
@@ -531,12 +533,12 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
// PY-6805
|
||||
public void testAttributeDefinedInNew() {
|
||||
final PsiElement resolved = resolve();
|
||||
assertInstanceOf(resolved, PyTargetExpression.class);
|
||||
UsefulTestCase.assertInstanceOf(resolved, PyTargetExpression.class);
|
||||
final PyTargetExpression target = (PyTargetExpression)resolved;
|
||||
assertEquals("foo", target.getName());
|
||||
Assert.assertEquals("foo", target.getName());
|
||||
final ScopeOwner owner = ScopeUtil.getScopeOwner(target);
|
||||
assertNotNull(owner);
|
||||
assertInstanceOf(owner, PyFunction.class);
|
||||
assertEquals("__new__", owner.getName());
|
||||
Assert.assertNotNull(owner);
|
||||
UsefulTestCase.assertInstanceOf(owner, PyFunction.class);
|
||||
Assert.assertEquals("__new__", owner.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jetbrains.python;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.fixtures.LightMarkedTestCase;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,141 +21,141 @@ public class PyStatementPartsTest extends LightMarkedTestCase {
|
||||
|
||||
public void testIf() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(2, marks.size());
|
||||
Assert.assertEquals(2, marks.size());
|
||||
PsiElement elt = marks.get("<the_if>").getParent().getParent(); // if_keyword -> if_part -> if_stmt
|
||||
assertTrue(elt instanceof PyIfStatement);
|
||||
Assert.assertTrue(elt instanceof PyIfStatement);
|
||||
PyIfStatement if_stmt = (PyIfStatement)elt;
|
||||
PyIfPart if_part = if_stmt.getIfPart();
|
||||
assertFalse(if_part.isElif());
|
||||
Assert.assertFalse(if_part.isElif());
|
||||
PyExpression if_cond = if_part.getCondition();
|
||||
assertEquals(marks.get("<the_cond>").getParent(), if_cond);
|
||||
Assert.assertEquals(marks.get("<the_cond>").getParent(), if_cond);
|
||||
}
|
||||
|
||||
public void testIfElse() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(4, marks.size());
|
||||
Assert.assertEquals(4, marks.size());
|
||||
PsiElement elt = marks.get("<the_if>").getParent().getParent(); // if_keyword -> if_part -> if_stmt
|
||||
assertTrue(elt instanceof PyIfStatement);
|
||||
Assert.assertTrue(elt instanceof PyIfStatement);
|
||||
PyIfStatement if_stmt = (PyIfStatement)elt;
|
||||
|
||||
PyIfPart if_part = if_stmt.getIfPart();
|
||||
assertFalse(if_part.isElif());
|
||||
Assert.assertFalse(if_part.isElif());
|
||||
PyExpression if_cond = if_part.getCondition();
|
||||
assertEquals(marks.get("<the_cond>").getParent(), if_cond);
|
||||
Assert.assertEquals(marks.get("<the_cond>").getParent(), if_cond);
|
||||
|
||||
PyStatementList stmt_list = if_part.getStatementList();
|
||||
assertNotNull(stmt_list);
|
||||
assertEquals(marks.get("<then_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
Assert.assertNotNull(stmt_list);
|
||||
Assert.assertEquals(marks.get("<then_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
|
||||
PyElsePart else_part = if_stmt.getElsePart();
|
||||
assertNotNull(else_part);
|
||||
Assert.assertNotNull(else_part);
|
||||
|
||||
stmt_list = else_part.getStatementList();
|
||||
assertNotNull(stmt_list);
|
||||
assertEquals(marks.get("<else_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
Assert.assertNotNull(stmt_list);
|
||||
Assert.assertEquals(marks.get("<else_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
|
||||
}
|
||||
|
||||
public void testIfElifElse() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(6, marks.size());
|
||||
Assert.assertEquals(6, marks.size());
|
||||
PsiElement elt = marks.get("<the_if>").getParent().getParent(); // if_keyword -> if_part -> if_stmt
|
||||
assertTrue(elt instanceof PyIfStatement);
|
||||
Assert.assertTrue(elt instanceof PyIfStatement);
|
||||
PyIfStatement if_stmt = (PyIfStatement)elt;
|
||||
|
||||
PyIfPart if_part = if_stmt.getIfPart();
|
||||
assertFalse(if_part.isElif());
|
||||
Assert.assertFalse(if_part.isElif());
|
||||
PyExpression if_cond = if_part.getCondition();
|
||||
assertEquals(marks.get("<the_cond>").getParent(), if_cond);
|
||||
Assert.assertEquals(marks.get("<the_cond>").getParent(), if_cond);
|
||||
|
||||
PyStatementList stmt_list = if_part.getStatementList();
|
||||
assertNotNull(stmt_list);
|
||||
assertEquals(marks.get("<then_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
Assert.assertNotNull(stmt_list);
|
||||
Assert.assertEquals(marks.get("<then_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
|
||||
PyElsePart else_part = if_stmt.getElsePart();
|
||||
assertNotNull(else_part);
|
||||
Assert.assertNotNull(else_part);
|
||||
|
||||
stmt_list = else_part.getStatementList();
|
||||
assertNotNull(stmt_list);
|
||||
assertEquals(marks.get("<else_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
Assert.assertNotNull(stmt_list);
|
||||
Assert.assertEquals(marks.get("<else_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
|
||||
PyIfPart elif_part = if_stmt.getElifParts()[0];
|
||||
assertTrue(elif_part.isElif());
|
||||
Assert.assertTrue(elif_part.isElif());
|
||||
if_cond = elif_part.getCondition();
|
||||
assertEquals(marks.get("<elif_cond>").getParent(), if_cond);
|
||||
Assert.assertEquals(marks.get("<elif_cond>").getParent(), if_cond);
|
||||
|
||||
stmt_list = elif_part.getStatementList();
|
||||
assertNotNull(stmt_list);
|
||||
assertEquals(marks.get("<elif_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
Assert.assertNotNull(stmt_list);
|
||||
Assert.assertEquals(marks.get("<elif_stmt>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
|
||||
}
|
||||
|
||||
public void testWhile() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(3, marks.size());
|
||||
Assert.assertEquals(3, marks.size());
|
||||
|
||||
PsiElement elt = marks.get("<stmt>").getParent().getParent(); // keyword -> part -> stmt
|
||||
assertTrue(elt instanceof PyWhileStatement);
|
||||
Assert.assertTrue(elt instanceof PyWhileStatement);
|
||||
PyWhileStatement while_stmt = (PyWhileStatement)elt;
|
||||
|
||||
PyWhilePart while_part = while_stmt.getWhilePart();
|
||||
|
||||
PyExpression cond = while_part.getCondition();
|
||||
assertEquals(marks.get("<cond>").getParent(), cond);
|
||||
Assert.assertEquals(marks.get("<cond>").getParent(), cond);
|
||||
|
||||
elt = marks.get("<else>").getParent(); // keyword -> part
|
||||
assertTrue(elt instanceof PyElsePart);
|
||||
assertEquals(while_stmt.getElsePart(), elt);
|
||||
Assert.assertTrue(elt instanceof PyElsePart);
|
||||
Assert.assertEquals(while_stmt.getElsePart(), elt);
|
||||
}
|
||||
|
||||
public void testFor() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(4, marks.size());
|
||||
Assert.assertEquals(4, marks.size());
|
||||
|
||||
PsiElement elt = marks.get("<stmt>").getParent().getParent(); // keyword -> part -> stmt
|
||||
assertTrue(elt instanceof PyForStatement);
|
||||
Assert.assertTrue(elt instanceof PyForStatement);
|
||||
PyForStatement stmt = (PyForStatement)elt;
|
||||
|
||||
PyForPart for_part = stmt.getForPart();
|
||||
|
||||
PyExpression target = for_part.getTarget();
|
||||
assertEquals(marks.get("<target>").getParent(), target); // ident -> expr
|
||||
Assert.assertEquals(marks.get("<target>").getParent(), target); // ident -> expr
|
||||
|
||||
PyExpression source = for_part.getSource();
|
||||
assertEquals(marks.get("<source>").getParent(), source); // ident -> expr
|
||||
Assert.assertEquals(marks.get("<source>").getParent(), source); // ident -> expr
|
||||
|
||||
elt = marks.get("<else>").getParent(); // keyword -> part
|
||||
assertTrue(elt instanceof PyElsePart);
|
||||
assertEquals(stmt.getElsePart(), elt);
|
||||
Assert.assertTrue(elt instanceof PyElsePart);
|
||||
Assert.assertEquals(stmt.getElsePart(), elt);
|
||||
}
|
||||
|
||||
public void testTry() throws Exception {
|
||||
Map<String, PsiElement> marks = loadTest();
|
||||
assertEquals(6, marks.size());
|
||||
Assert.assertEquals(6, marks.size());
|
||||
|
||||
PsiElement elt = marks.get("<stmt>").getParent().getParent(); // keyword -> part -> stmt
|
||||
assertTrue(elt instanceof PyTryExceptStatement);
|
||||
Assert.assertTrue(elt instanceof PyTryExceptStatement);
|
||||
PyTryExceptStatement stmt = (PyTryExceptStatement)elt;
|
||||
|
||||
PyTryPart try_part = stmt.getTryPart();
|
||||
PyStatementList stmt_list = try_part.getStatementList();
|
||||
assertNotNull(stmt_list);
|
||||
assertEquals(marks.get("<body>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
Assert.assertNotNull(stmt_list);
|
||||
Assert.assertEquals(marks.get("<body>").getParent().getParent(), stmt_list); // keyword -> stmt -> stmt_list
|
||||
|
||||
PyExceptPart exc_part = stmt.getExceptParts()[0];
|
||||
assertEquals("ArithmeticError", exc_part.getExceptClass().getText());
|
||||
assertEquals(marks.get("<ex1>").getParent(), exc_part);
|
||||
Assert.assertEquals("ArithmeticError", exc_part.getExceptClass().getText());
|
||||
Assert.assertEquals(marks.get("<ex1>").getParent(), exc_part);
|
||||
|
||||
exc_part = (PyExceptPart)marks.get("<ex2>").getParent(); // keyword -> part
|
||||
assertEquals(stmt.getExceptParts()[1], exc_part);
|
||||
assertNull(exc_part.getExceptClass());
|
||||
Assert.assertEquals(stmt.getExceptParts()[1], exc_part);
|
||||
Assert.assertNull(exc_part.getExceptClass());
|
||||
|
||||
elt = marks.get("<else>").getParent(); // keyword -> part
|
||||
assertTrue(elt instanceof PyElsePart);
|
||||
assertEquals(stmt.getElsePart(), elt);
|
||||
Assert.assertTrue(elt instanceof PyElsePart);
|
||||
Assert.assertEquals(stmt.getElsePart(), elt);
|
||||
|
||||
elt = marks.get("<finally>").getParent(); // keyword -> part
|
||||
assertTrue(elt instanceof PyFinallyPart);
|
||||
assertEquals(stmt.getFinallyPart(), elt);
|
||||
Assert.assertTrue(elt instanceof PyFinallyPart);
|
||||
Assert.assertEquals(stmt.getFinallyPart(), elt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.jetbrains.python.lexer.PyStringLiteralLexer;
|
||||
*/
|
||||
public class PyStringLiteralLexerTest extends PyLexerTestCase {
|
||||
public void testBackslashN() { // PY-1313
|
||||
doLexerTest("u\"\\N{LATIN SMALL LETTER B}\"", new PyStringLiteralLexer(PyTokenTypes.SINGLE_QUOTED_UNICODE),
|
||||
"Py:SINGLE_QUOTED_UNICODE", "VALID_STRING_ESCAPE_TOKEN", "Py:SINGLE_QUOTED_UNICODE");
|
||||
PyLexerTestCase.doLexerTest("u\"\\N{LATIN SMALL LETTER B}\"", new PyStringLiteralLexer(PyTokenTypes.SINGLE_QUOTED_UNICODE),
|
||||
"Py:SINGLE_QUOTED_UNICODE", "VALID_STRING_ESCAPE_TOKEN", "Py:SINGLE_QUOTED_UNICODE");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,6 +760,30 @@ public class PyTypeTest extends PyTestCase {
|
||||
" print(expr)\n");
|
||||
}
|
||||
|
||||
// PY-8953
|
||||
public void testSelfInDocString() {
|
||||
doTest("int",
|
||||
"class C(object):\n" +
|
||||
" def foo(self):\n" +
|
||||
" '''\n" +
|
||||
" :type self: int\n" +
|
||||
" '''\n" +
|
||||
" expr = self\n");
|
||||
}
|
||||
|
||||
// PY-9605
|
||||
public void testPropertyReturnsCallable() {
|
||||
doTest("() -> int",
|
||||
"class C(object):\n" +
|
||||
" @property\n" +
|
||||
" def foo(self):\n" +
|
||||
" return lambda: 0\n" +
|
||||
"\n" +
|
||||
|
||||
"c = C()\n" +
|
||||
"expr = c.foo\n");
|
||||
}
|
||||
|
||||
private static TypeEvalContext getTypeEvalContext(@NotNull PyExpression element) {
|
||||
return TypeEvalContext.userInitiated(element.getContainingFile()).withTracing();
|
||||
}
|
||||
|
||||
@@ -156,6 +156,6 @@ public class PythonHighlightingLexerTest extends PyLexerTestCase {
|
||||
}
|
||||
|
||||
private static void doTest(LanguageLevel languageLevel, String text, String... expectedTokens) {
|
||||
doLexerTest(text, new PythonHighlightingLexer(languageLevel), expectedTokens);
|
||||
PyLexerTestCase.doLexerTest(text, new PythonHighlightingLexer(languageLevel), expectedTokens);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,6 +301,6 @@ public class PythonLexerTest extends PyLexerTestCase {
|
||||
}
|
||||
|
||||
private static void doTest(String text, String... expectedTokens) {
|
||||
doLexerTest(text, new PythonIndentingLexer(), expectedTokens);
|
||||
PyLexerTestCase.doLexerTest(text, new PythonIndentingLexer(), expectedTokens);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.jetbrains.python;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.ParsingTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.jetbrains.cython.CythonTokenSetContributor;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
|
||||
@@ -24,7 +23,6 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
PyTestCase.initPlatformPrefix();
|
||||
registerExtensionPoint(PythonDialectsTokenSetContributor.EP_NAME, PythonDialectsTokenSetContributor.class);
|
||||
registerExtension(PythonDialectsTokenSetContributor.EP_NAME, new PythonTokenSetContributor());
|
||||
registerExtension(PythonDialectsTokenSetContributor.EP_NAME, new CythonTokenSetContributor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.jetbrains.python.run.PythonConfigurationType;
|
||||
import com.jetbrains.python.run.PythonRunConfiguration;
|
||||
import com.jetbrains.python.testing.PythonTestConfigurationType;
|
||||
import com.jetbrains.python.testing.unittest.PythonUnitTestRunConfiguration;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,8 +20,8 @@ public class PythonRunConfigurationTest extends PyCommandLineTestCase {
|
||||
PythonUnitTestRunConfiguration.class);
|
||||
configuration.setScriptName(PY_SCRIPT);
|
||||
final List<String> params = buildRunCommandLine(configuration);
|
||||
assertTrue(params.get(0).endsWith("utrunner.py"));
|
||||
assertTrue(params.get(1).equals(PY_SCRIPT));
|
||||
Assert.assertTrue(params.get(0).endsWith("utrunner.py"));
|
||||
Assert.assertTrue(params.get(1).equals(PY_SCRIPT));
|
||||
}
|
||||
|
||||
public void testDebugCommandLine() {
|
||||
@@ -28,7 +29,7 @@ public class PythonRunConfigurationTest extends PyCommandLineTestCase {
|
||||
PythonRunConfiguration.class);
|
||||
configuration.setScriptName(PY_SCRIPT);
|
||||
final List<String> params = buildDebugCommandLine(configuration);
|
||||
final int index = verifyPyDevDParameters(params);
|
||||
assertEquals(PY_SCRIPT, params.get(index));
|
||||
final int index = PyCommandLineTestCase.verifyPyDevDParameters(params);
|
||||
Assert.assertEquals(PY_SCRIPT, params.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.jetbrains.python.fixtures;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.testFramework.PlatformLiteFixture;
|
||||
import com.jetbrains.cython.CythonTokenSetContributor;
|
||||
import com.jetbrains.python.PythonDialectsTokenSetContributor;
|
||||
import com.jetbrains.python.PythonDialectsTokenSetProvider;
|
||||
import com.jetbrains.python.PythonTokenSetContributor;
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ public abstract class PyLexerTestCase extends PlatformLiteFixture {
|
||||
PyTestCase.initPlatformPrefix();
|
||||
registerExtensionPoint(PythonDialectsTokenSetContributor.EP_NAME, PythonDialectsTokenSetContributor.class);
|
||||
registerExtension(PythonDialectsTokenSetContributor.EP_NAME, new PythonTokenSetContributor());
|
||||
registerExtension(PythonDialectsTokenSetContributor.EP_NAME, new CythonTokenSetContributor());
|
||||
PythonDialectsTokenSetProvider.reset();
|
||||
}
|
||||
|
||||
public static void doLexerTest(String text, Lexer lexer, String... expectedTokens) {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.jetbrains.python.fixtures;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public abstract class PyMultiFileResolveTestCase extends PyResolveTestCase {
|
||||
protected String myTestFileName;
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PythonTestUtil.getTestDataPath() + "/resolve/multiFile/";
|
||||
}
|
||||
|
||||
protected PsiElement doResolve(PsiFile psiFile) {
|
||||
final PsiPolyVariantReference ref = PyResolveTestCase.findReferenceByMarker(psiFile);
|
||||
final PsiManagerImpl psiManager = (PsiManagerImpl)myFixture.getPsiManager();
|
||||
psiManager.setAssertOnFileLoadingFilter(new VirtualFileFilter() {
|
||||
@Override
|
||||
public boolean accept(VirtualFile file) {
|
||||
FileType fileType = file.getFileType();
|
||||
return fileType == PythonFileType.INSTANCE;
|
||||
}
|
||||
});
|
||||
try {
|
||||
final ResolveResult[] resolveResults = ref.multiResolve(false);
|
||||
if (resolveResults.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return resolveResults[0].isValidResult() ? resolveResults[0].getElement() : null;
|
||||
}
|
||||
finally {
|
||||
psiManager.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void prepareTestDirectory() {
|
||||
final String testName = getTestName(true);
|
||||
myFixture.copyDirectoryToProject(testName, "");
|
||||
PsiDocumentManager.getInstance(myFixture.getProject()).commitAllDocuments();
|
||||
}
|
||||
|
||||
private PsiFile prepareFile() {
|
||||
prepareTestDirectory();
|
||||
VirtualFile sourceFile = null;
|
||||
for (String ext : new String[]{".py", ".pyx"}) {
|
||||
final String fileName = myTestFileName != null ? myTestFileName : getTestName(false) + ext;
|
||||
sourceFile = myFixture.findFileInTempDir(fileName);
|
||||
if (sourceFile != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertNotNull("Could not find test file", sourceFile);
|
||||
return myFixture.getPsiManager().findFile(sourceFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement doResolve() {
|
||||
return doResolve(prepareFile());
|
||||
}
|
||||
|
||||
protected ResolveResult[] doMultiResolve() {
|
||||
PsiFile psiFile = prepareFile();
|
||||
final PsiPolyVariantReference ref = PyResolveTestCase.findReferenceByMarker(psiFile);
|
||||
return ref.multiResolve(false);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.testFramework.fixtures.TestFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.jetbrains.python.PythonMockSdk;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
@@ -147,6 +146,10 @@ public abstract class PyTestCase extends UsefulTestCase {
|
||||
}
|
||||
|
||||
public static void initPlatformPrefix() {
|
||||
PlatformTestCase.initPlatformPrefix(UsefulTestCase.IDEA_MARKER_CLASS, PlatformUtils.PYCHARM_PREFIX);
|
||||
PlatformTestCase.autodetectPlatformPrefix();
|
||||
}
|
||||
|
||||
public static String getHelpersPath() {
|
||||
return new File(PathManager.getHomePath(), "python/community/helpers").getPath();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,4 +138,9 @@ public class PyArgumentListInspectionTest extends PyTestCase {
|
||||
public void testDecoratedChangedParameters() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-9605
|
||||
public void testPropertyReturnsCallable() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -298,6 +298,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
|
||||
// PY-10893
|
||||
public void testCustomNewReturnInAnotherModule() {
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.jetbrains.python.testRunner;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.process.ProcessOutput;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -67,12 +66,12 @@ public class PyDocTestRunnerTest extends LightPlatformTestCase {
|
||||
}
|
||||
|
||||
private static String[] runUTRunner(String workDir, String... args) throws ExecutionException {
|
||||
File helpersDir = new File(PathManager.getHomePath(), "python/helpers");
|
||||
File utRunner = new File(helpersDir, "pycharm/docrunner.py");
|
||||
String helpersPath = PyTestCase.getHelpersPath();
|
||||
File utRunner = new File(helpersPath, "pycharm/docrunner.py");
|
||||
List<String> allArgs = new ArrayList<String>();
|
||||
allArgs.add(utRunner.getPath());
|
||||
Collections.addAll(allArgs, args);
|
||||
final ProcessOutput output = JythonUnitTestUtil.runJython(workDir, helpersDir.getPath(), ArrayUtil.toStringArray(allArgs));
|
||||
final ProcessOutput output = JythonUnitTestUtil.runJython(workDir, helpersPath, ArrayUtil.toStringArray(allArgs));
|
||||
assertEquals(output.getStderr(), 0, splitLines(output.getStderr()).length);
|
||||
return splitLines(output.getStdout());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PyTestRunnerTest extends LightPlatformTestCase {
|
||||
}
|
||||
|
||||
private static String[] runUTRunner(String workDir, String... args) throws ExecutionException {
|
||||
File helpersDir = new File(PathManager.getHomePath(), "python/helpers");
|
||||
File helpersDir = new File(PyTestCase.getHelpersPath());
|
||||
File utRunner = new File(helpersDir, "pycharm/utrunner.py");
|
||||
List<String> allArgs = new ArrayList<String>();
|
||||
allArgs.add(utRunner.getPath());
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
<orderEntry type="module" module-name="testFramework" />
|
||||
<orderEntry type="module" module-name="python-psi-api" scope="TEST" />
|
||||
<orderEntry type="module" module-name="python-community" scope="TEST" />
|
||||
<orderEntry type="module" module-name="xdebugger-api" scope="TEST" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="module" module-name="spellchecker" scope="TEST" />
|
||||
<orderEntry type="module" module-name="python-ide-community" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user