[Pydev-cvs] org.python.pydev/src/org/python/pydev/plugin/nature PythonNature.java,1.15,1.16
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-09-18 18:13:28
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv668/src/org/python/pydev/plugin/nature Modified Files: PythonNature.java Log Message: Index: PythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNature.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PythonNature.java 13 Sep 2005 17:34:24 -0000 1.15 --- PythonNature.java 18 Sep 2005 18:13:17 -0000 1.16 *************** *** 21,24 **** --- 21,25 ---- import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectNature; + import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; *************** *** 32,35 **** --- 33,37 ---- import org.eclipse.ui.part.FileEditorInput; import org.python.pydev.builder.PyDevBuilderPrefPage; + import org.python.pydev.core.ExtensionHelper; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.REF; *************** *** 37,41 **** import org.python.pydev.editor.codecompletion.revisited.ASTManager; import org.python.pydev.editor.codecompletion.revisited.ICodeCompletionASTManager; - import org.python.pydev.extension.ExtensionHelper; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.ui.interpreters.IInterpreterObserver; --- 39,42 ---- *************** *** 408,411 **** --- 409,432 ---- } + /** + * @param resource the resource we want to get the name from + * @return the name of the module in the environment + */ + public static String getModuleNameForResource(IResource resource) { + String moduleName = null; + PythonNature nature = getPythonNature(resource.getProject()); + + if(nature != null){ + IFile f = (IFile) resource; + String file = f.getRawLocation().toOSString(); + ICodeCompletionASTManager astManager = nature.getAstManager(); + + if(astManager != null){ + moduleName = astManager.getProjectModulesManager().resolveModule(file); + } + } + return moduleName; + } + } |