private IDocument getDocument() {
   IMarker marker = getMarker();
   IResource r = marker.getResource();
   if (r instanceof IFile) {
     return FileUtilsFileBuffer.getDocFromResource(r);
   } else {
     // it's an external file...
     try {
       return FileUtilsFileBuffer.getDocFromFile(
           new File((String) marker.getAttribute(PyBreakpoint.PY_BREAK_EXTERNAL_PATH_ID)));
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
   }
 }
Beispiel #2
0
  /**
   * This method creates a source module from a file.
   *
   * @return
   * @throws IOException
   * @throws MisconfigurationException
   */
  public static AbstractModule createModule(
      String name, File f, IPythonNature nature, boolean checkForPath)
      throws IOException, MisconfigurationException {
    if (PythonPathHelper.isValidFileMod(f.getName())) {
      if (PythonPathHelper.isValidSourceFile(f.getName())) {
        return createModuleFromDoc(
            name, f, FileUtilsFileBuffer.getDocFromFile(f), nature, checkForPath);

      } else { // this should be a compiled extension... we have to get completions from the python
        // shell.
        return new CompiledModule(name, nature.getAstManager().getModulesManager(), nature);
      }
    }

    // if we are here, return null...
    return null;
  }