type provider for SQLAlchemy columns (PY-7243)

This commit is contained in:
Dmitry Jemerov
2012-08-20 15:04:31 +02:00
parent 080c1ef22f
commit 99d173514b
5 changed files with 47 additions and 8 deletions
@@ -7,9 +7,8 @@ import org.jetbrains.annotations.Nullable;
/**
* Something that can be called, passed parameters to, and return something back.
* <br/>
* User: dcheryasov
* Date: May 15, 2010 3:22:30 PM
* @author dcheryasov
*/
public interface Callable extends PyElement {
@@ -31,4 +30,11 @@ public interface Callable extends PyElement {
@Nullable
PyFunction asMethod();
/**
* Returns the qualified name of the function.
*
* @return the qualified name of the function, or null for a lambda expression.
*/
@Nullable
String getQualifiedName();
}
@@ -69,6 +69,8 @@ public interface PyClass extends PsiNameIdentifierOwner, PyStatement, NameDefine
PyFunction findInitOrNew(boolean inherited);
/**
* Finds a property with the specified name in the class or one of its ancestors.
*
* @param name of the property
* @return descriptor of property accessors, or null if such property does not exist.
*/
+8 -5
View File
@@ -419,6 +419,8 @@
<applicationService serviceInterface="com.jetbrains.python.packaging.PyPackageManagers"
serviceImplementation="com.jetbrains.python.packaging.PyPackageManagersImpl"/>
<qualifiedNameProvider implementation="com.jetbrains.python.actions.PyQualifiedNameProvider"/>
<!-- Cython -->
<lang.parserDefinition language="Cython" implementationClass="com.jetbrains.cython.parser.CythonParserDefinition"/>
<lang.syntaxHighlighterFactory key="Cython" implementationClass="com.jetbrains.cython.CythonSyntaxHighlighterFactory"/>
@@ -603,6 +605,9 @@
<lang.lineWrapStrategy language="DjangoTemplate" implementationClass="com.jetbrains.django.lang.template.editor.DjangoTemplateLineWrapPositionStrategy"/>
<fileBasedIndex implementation="com.jetbrains.django.lang.template.DjangoBlockInheritanceIndex"/>
<definitionsSearch implementation="com.jetbrains.django.lang.template.DjangoBlockInheritorsSearchExecutor"/>
<!-- App Engine -->
<facetType implementation="com.jetbrains.appengine.facet.AppEngineFacetType"/>
<framework.detector implementation="com.jetbrains.appengine.facet.AppEngineFrameworkDetector"/>
@@ -638,9 +643,6 @@
<projectService serviceInterface="org.jetbrains.yaml.YAMLElementGenerator"
serviceImplementation="org.jetbrains.yaml.YAMLElementGenerator"/>
<fileBasedIndex implementation="com.jetbrains.django.lang.template.DjangoBlockInheritanceIndex"/>
<definitionsSearch implementation="com.jetbrains.django.lang.template.DjangoBlockInheritorsSearchExecutor"/>
<!-- Buildout -->
<facetType implementation="com.jetbrains.python.buildout.BuildoutFacetType"/>
<framework.detector implementation="com.jetbrains.python.buildout.BuildoutFrameworkDetector"/>
@@ -660,8 +662,6 @@
<problemFileHighlightFilter implementation="com.jetbrains.python.buildout.config.BuildoutCfgProblemFileHighlightFilter"/>
<qualifiedNameProvider implementation="com.jetbrains.python.actions.PyQualifiedNameProvider"/>
<!-- Mako files -->
<multiLangCommenter implementation="com.jetbrains.python.templateLanguages.TemplatesCommentProvider"/>
<highlightErrorFilter implementation="com.jetbrains.mako.inspection.MakoErrorFilter"/>
@@ -822,6 +822,9 @@
<!-- Packaging -->
<keywordArgumentProvider implementation="com.jetbrains.python.packaging.setupPy.SetupKeywordArgumentProvider"/>
<!-- SQLAlchemy -->
<typeProvider implementation="com.jetbrains.sqlalchemy.SQLAlchemyTypeProvider"/>
</extensions>
<project-components>
@@ -24,6 +24,7 @@ import com.jetbrains.python.codeInsight.controlflow.ControlFlowCache;
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
import com.jetbrains.python.documentation.StructuredDocString;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.resolve.QualifiedNameFinder;
import com.jetbrains.python.psi.stubs.PyClassStub;
import com.jetbrains.python.psi.stubs.PyFunctionStub;
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
@@ -625,4 +626,25 @@ public class PyFunctionImpl extends PyPresentableElementImpl<PyFunctionStub> imp
}
return null;
}
@Nullable
@Override
public String getQualifiedName() {
String name = getName();
if (name == null) {
return null;
}
PyClass containingClass = getContainingClass();
if (containingClass != null) {
return containingClass.getQualifiedName() + "." + name;
}
if (PsiTreeUtil.getStubOrPsiParent(this) instanceof PyFile) {
VirtualFile virtualFile = getContainingFile().getVirtualFile();
if (virtualFile != null) {
final String packageName = QualifiedNameFinder.findShortestImportableName(this, virtualFile);
return packageName + "." + name;
}
}
return null;
}
}
@@ -58,4 +58,10 @@ public class PyLambdaExpressionImpl extends PyElementImpl implements PyLambdaExp
super.subtreeChanged();
ControlFlowCache.clear(this);
}
@Nullable
@Override
public String getQualifiedName() {
return null;
}
}