title: Xtext get project root directory from validator
body: <p>I need to get to validate existence of specific file in Xtext project. The file has similar path as validated object but other root directory, for example:</p>
  
  <blockquote>
    <p>$projPath/src/dir1/dir2/ValidatedFile.src</p>
    
    <p>$projPath/resources/dir1/dir2/SchoudBeExistFile.src</p>
  </blockquote>
  
  <p>In validate function I get resource only with relative path (<code>/src/dir1/dir2/ValidatedFile.src</code>). But I don't know the project path, so I can't check existence of the <code>/resources/dir1/dir2/SchoudBeExistFile.src</code>.</p>
  
  <p>Can you help me to find the absolute project path in validation function?
  <code>
      @Check
      def checkExternalFileExistance(MyType my) {
          val myTypeFullPath = ??
          val projectPath = ??
      }
  </code></p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE:</strong>
  Solved by adding <code>org.eclipse.core.resources</code> and <code>org.eclipse.core.runtime</code> plugin dependencies to xtext project via <code>plugin.xml</code> and using <a href="https://stackoverflow.com/questions/7242403/a-better-way-to-get-files-within-a-project-using-eclipse-and-xtext">this</a> solution in grammar style. No absolute path required for this.</p>
  
  <pre><code>@Check
  def checkExternalFlowDirExistance(MyType my) {
      val platformString = my.eResource.URI.toPlatformString(true);
      val myFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformString));
      val proj = myFile.getProject();
      val shouldExistsFile = proj.geFile("/resources/dir1/dir2/SchoudBeExistFile.src")
      if (!shouldExistsFile.exists) {
      // error
      }
  }
  </code></pre>