package com.karateca.ddescriber.toolWindow;

import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.karateca.ddescriber.Hierarchy;
import com.karateca.ddescriber.JasmineFinder;

/**
 * @author Andres Dominguez.
 */
public class JasminFile {

  private final VirtualFile virtualFile;
  private Hierarchy hierarchy;

  public JasminFile(VirtualFile virtualFile) {
    this.virtualFile = virtualFile;
  }

  public Hierarchy createHierarchy(Project project) {
    FileDocumentManager instance = FileDocumentManager.getInstance();
    Document document = instance.getDocument(virtualFile);

    JasmineFinder jasmineFinder = new JasmineFinder(project, document);
    jasmineFinder.findAll();
    hierarchy = new Hierarchy(document, jasmineFinder.getFindResults(), 0);

    return hierarchy;
  }

  @Override
  public String toString() {
    return virtualFile.getName();
  }

  public VirtualFile getVirtualFile() {
    return virtualFile;
  }
}

@@ -87,68 +87,8 @@
 nt;%0A
-import com.intellij.openapi.fileEditor.FileDocumentManager;%0A
 impo
@@ -128,16 +128,16 @@
 roject;%0A
+
 import c
@@ -173,16 +173,59 @@
 alFile;%0A
+import com.karateca.ddescriber.ActionUtil;%0A
 import c
@@ -342,23 +342,16 @@
 ez.%0A */%0A
-public 
 class Ja
@@ -361,16 +361,16 @@
 nFile %7B%0A
+
 %0A  priva
@@ -406,39 +406,8 @@
 ile;
-%0A  private Hierarchy hierarchy;
 %0A%0A  
@@ -550,28 +550,24 @@
 ) %7B%0A    
-File
 Document
 Manager 
@@ -562,94 +562,30 @@
 ment
-Manager instance = FileDocumentManager.getInstance();%0A    Document document = instance
+ document = ActionUtil
 .get
@@ -709,20 +709,30 @@
 dAll();%0A
-
     
+Hierarchy 
 hierarch

Use action util to get doc