From 0ad756b9359859bbb3dc9fa5f9dc337bfed4224f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 25 Dec 2009 17:59:38 +0300 Subject: [PATCH] tests for forthcoming functionality, cleanup and refactoring --- python/src/com/jetbrains/python/psi/PyFile.java | 5 ++++- .../src/com/jetbrains/python/psi/impl/PyFileImpl.java | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/psi/PyFile.java b/python/src/com/jetbrains/python/psi/PyFile.java index 6c23bf92b131..db339e85e158 100644 --- a/python/src/com/jetbrains/python/psi/PyFile.java +++ b/python/src/com/jetbrains/python/psi/PyFile.java @@ -36,5 +36,8 @@ public interface PyFile extends PyElement, PsiFile, PyDocStringOwner { @return an URL of file, maybe bogus if virtual file is not present. */ @NotNull - String getUrl(); + String getUrl(); + + @Nullable + PyFunction findTopLevelFunction(String name); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java index 3fef824a0d00..c76eeeb5230c 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java @@ -68,6 +68,16 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return fname; } + public PyFunction findTopLevelFunction(String name) { + final List functions = getTopLevelFunctions(); + for (PyFunction function : functions) { + if (name.equals(function.getName())) { + return function; + } + } + return null; + } + public Icon getIcon(int flags) { return PythonFileType.INSTANCE.getIcon(); }