public static String[] parseJarEntryFileInput(IStorageEditorInput input) {
   IStorage storage = null;
   try {
     storage = input.getStorage();
   } catch (CoreException e) {
     // ignore
   }
   return storage == null ? null : parseJarEntryFile(storage);
 }
  public static boolean isCljFile(IEditorPart editorPart) {
    IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
    if (resource != null && resource.getFileExtension().equals("clj")) {
      return true;
    }

    if (editorPart.getEditorInput() instanceof IStorageEditorInput) {
      try {
        IStorageEditorInput input = (IStorageEditorInput) editorPart.getEditorInput();
        if (input.getStorage().getName().endsWith(".clj")) {
          return true;
        }
      } catch (CoreException e) {
        // Nothing more to do :-(
      }
    }

    return false;
  }
  public static boolean isCljFile(IEditorPart editorPart) {
    IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
    if (resource != null && isCljExtension(resource.getFileExtension())) {
      return true;
    }

    if (editorPart.getEditorInput() instanceof IStorageEditorInput) {
      try {
        IStorageEditorInput input = (IStorageEditorInput) editorPart.getEditorInput();
        final String name = input.getStorage().getName();
        final int extDotIdx = name.lastIndexOf('.');
        final String ext = (extDotIdx < 0) ? "" : name.substring(extDotIdx + 1);
        if (isCljExtension(ext)) {
          return true;
        }
      } catch (CoreException e) {
        // Nothing more to do :-(
      }
    }

    return false;
  }
 private void initializeResourceObjectFromStorage(IStorageEditorInput input) {
   URI uri = null;
   try {
     IStorage storage = input.getStorage();
     InputStream inputStream = storage.getContents();
     uri = URI.createURI(storage.getName(), true);
     ResourceSet resourceSet = getResourceSet();
     com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource resource =
         (com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource)
             resourceSet.createResource(uri);
     resource.load(inputStream, null);
     setResource(resource);
   } catch (CoreException e) {
     com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.ui.RezeptUIPlugin.logError(
         "Exception while loading resource (" + uri + ") in " + getClass().getSimpleName() + ".",
         e);
   } catch (IOException e) {
     com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.ui.RezeptUIPlugin.logError(
         "Exception while loading resource (" + uri + ") in " + getClass().getSimpleName() + ".",
         e);
   }
 }
  @Override
  public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
      throws CoreException {
    TextSelection textSelection = (TextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();

    if (part instanceof IEditorPart) {
      IEditorPart editor = (IEditorPart) part;
      IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);

      if (resource != null) {
        for (int i = 0; i < breakpoints.length; i++) {
          IBreakpoint breakpoint = breakpoints[i];
          if (resource.equals(breakpoint.getMarker().getResource())) {
            if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
              breakpoint.delete();
              return;
            }
          }
        }
        String path = ClojureCore.getAsRootClasspathRelativePath((IFile) resource).substring(1);
        JDIDebugModel.createStratumBreakpoint(
            resource,
            "Clojure",
            resource.getName(),
            path,
            null,
            lineNumber + 1,
            -1,
            -1,
            0,
            true,
            null);
      } else {
        // Do it "the hard way" by using the WorkspaceRoot as the host for our breakpoint
        // ... quick analysis seems to indicate it's done this way by the JDT "itself" !
        IStorageEditorInput input = (IStorageEditorInput) editor.getEditorInput();
        IStorage storage = input.getStorage();

        for (int i = 0; i < breakpoints.length; i++) {
          IBreakpoint breakpoint = breakpoints[i];
          if (breakpoint instanceof IJavaStratumLineBreakpoint) {
            IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) breakpoint;
            if (storage
                .getFullPath()
                .toPortableString()
                .equals(stratumBreakpoint.getSourcePath())) {
              if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                breakpoint.delete();
                return;
              }
            }
          }
        }
        Map attributes = new HashMap();
        StorageMarkerAnnotationModel.addAttribute(attributes, storage);
        System.out.println("not editor part resource");
        JDIDebugModel.createStratumBreakpoint(
            ResourcesPlugin.getWorkspace().getRoot(),
            "Clojure",
            storage.getName(),
            storage.getFullPath().toPortableString(),
            null,
            lineNumber + 1,
            -1,
            -1,
            0,
            true,
            attributes);
      }
    }
  }
  /**
   * Reads in the saved document into <code>fReference</code>.
   *
   * @param monitor a progress monitor, or <code>null</code>
   * @param force <code>true</code> if the reference document should also be read if the current
   *     document is <code>null</code>,<code>false</code> if it should only be updated if it already
   *     existed.
   */
  private void readDocument(IProgressMonitor monitor, boolean force) {

    // protect against concurrent disposal
    IDocumentProvider prov = fDocumentProvider;
    IEditorInput inp = fEditorInput;
    SymbolisedDocument doc = fReference;
    ITextEditor editor = fEditor;

    if (prov instanceof IStorageDocumentProvider && inp instanceof IStorageEditorInput) {

      IStorageEditorInput input = (IStorageEditorInput) inp;
      IStorageDocumentProvider provider = (IStorageDocumentProvider) prov;

      if (doc == null) {
        if (force || fDocumentRead) doc = new SymbolisedDocument();
        else return;
      } else {
        doc.syncSymbolSupport();
      }

      IJobManager jobMgr = Job.getJobManager(); // Platform.getJobManager();

      try {
        IStorage storage = input.getStorage();
        // check for null for backward compatibility (we used to check before...)
        if (storage == null) return;
        fProgressMonitor = monitor;
        ISchedulingRule rule = getSchedulingRule(storage);

        // this protects others from not being able to delete the file,
        // and protects ourselves from concurrent access to fReference
        // (in the case there already is a valid fReference)

        // one might argue that this rule should already be in the Job
        // description we're running in, however:
        // 1) we don't mind waiting for someone else here
        // 2) we do not take long, or require other locks etc. -> short
        // delay for any other job requiring the lock on file
        try {
          lockDocument(monitor, jobMgr, rule);

          String encoding;
          if (storage instanceof IEncodedStorage)
            encoding = ((IEncodedStorage) storage).getCharset();
          else encoding = null;

          LastSaveReferenceProvider.setDocumentContent(doc, storage, encoding, monitor);
        } finally {
          unlockDocument(jobMgr, rule);
          fProgressMonitor = null;
        }

      } catch (CoreException e) {
        return;
      }

      if (monitor != null && monitor.isCanceled()) return;

      // update state
      synchronized (fLock) {
        if (fDocumentProvider == provider && fEditorInput == input) {
          // only update state if our provider / input pair has not
          // been updated in between (dispose or setActiveEditor)
          fReference = doc;
          fDocumentRead = true;
          addElementStateListener(editor, prov);
        }
      }
    }
  }