예제 #1
0
 /**
  * Checks whether all includes exists, if they are outside of the project, add a link to the file
  * to the project
  *
  * @param includes
  */
 private void processIncludes(List<OutlineNode> includes, IEditorInput input) {
   IProject project = getCurrentProject();
   if (project == null) return;
   IFile referFile = (IFile) input.getAdapter(IFile.class);
   if (referFile == null) return;
   for (OutlineNode node : includes) {
     IFile f = null;
     IFile mainTexFile = TexlipseProperties.getProjectSourceFile(project);
     if (mainTexFile != null) {
       // Includes are always relative to the main file
       f = TexProjectParser.findIFile(node.getName(), mainTexFile, project);
     }
     if (f == null) {
       // Try finding it relative to refering file
       f = TexProjectParser.findIFile(node.getName(), referFile, project);
     }
     if (f == null) {
       MarkerHandler marker = MarkerHandler.getInstance();
       String errorMsg =
           MessageFormat.format(
               TexlipsePlugin.getResourceString("parseErrorIncludeNotFound"),
               new Object[] {node.getName()});
       marker.createErrorMarker(referFile, errorMsg, node.getBeginLine());
     }
   }
 }
 /**
  * Initializes variables, which are often reused. This should be called every time there is a
  * chance that project settings have been changed.
  */
 public void init() {
   sourceDir = TexlipseProperties.getProjectSourceDir(project);
   outputDir = TexlipseProperties.getProjectOutputDir(project);
   tempDir = TexlipseProperties.getProjectTempDir(project);
   format = TexlipseProperties.getProjectProperty(project, TexlipseProperties.OUTPUT_FORMAT);
   sourceFile = TexlipseProperties.getProjectSourceFile(project);
 }
예제 #3
0
  /**
   * Updates the references and project data based on the data in the parsed document.
   *
   * @param monitor Progress monitor
   */
  private void updateReferences(IProgressMonitor monitor) {
    this.updateLabels(parser.getLabels());
    this.updateCommands(parser.getCommands());
    IProject project = getCurrentProject();
    if (project == null) return;
    IFile cFile = ((FileEditorInput) editor.getEditorInput()).getFile();
    boolean isMainFile = cFile.equals(TexlipseProperties.getProjectSourceFile(project));

    pollCancel(monitor);

    // After here we just store those fun properties...
    if (parser.isLocalBib()) {
      TexlipseProperties.setSessionProperty(
          project, TexlipseProperties.SESSION_BIBLATEXLOCALBIB_PROPERTY, new Boolean(true));
    } else {
      TexlipseProperties.setSessionProperty(
          project, TexlipseProperties.SESSION_BIBLATEXLOCALBIB_PROPERTY, null);
    }

    // Only update Preamble, Bibstyle if main Document
    if (isMainFile) {
      boolean biblatexMode = parser.isBiblatexMode();
      updateBiblatex(project, biblatexMode, parser.getBiblatexBackend(), false);

      String[] bibs = parser.getBibs();
      this.updateBibs(bibs, biblatexMode, cFile);

      pollCancel(monitor);

      String preamble = parser.getPreamble();
      if (preamble != null) {
        TexlipseProperties.setSessionProperty(
            project, TexlipseProperties.PREAMBLE_PROPERTY, preamble);
      }
      if (!biblatexMode) {
        String bibstyle = parser.getBibstyle();
        if (bibstyle != null) {
          String oldStyle =
              (String)
                  TexlipseProperties.getSessionProperty(
                      project, TexlipseProperties.BIBSTYLE_PROPERTY);

          if (oldStyle == null || !bibstyle.equals(oldStyle)) {
            TexlipseProperties.setSessionProperty(
                project, TexlipseProperties.BIBSTYLE_PROPERTY, bibstyle);

            // schedule running bibtex on the next build
            TexlipseProperties.setSessionProperty(
                project, TexlipseProperties.BIBFILES_CHANGED, new Boolean(true));
          }
        }
      }
    }
  }
예제 #4
0
  /**
   * Creates all the project data structures. These include the reference completions (BibTeX and
   * label), command completions, the preamble, the BibTeX style.
   *
   * @param project The current project
   */
  private void createProjectDatastructs(IProject project) {
    // IResource resource = ((FileEditorInput)editor.getEditorInput()).getFile();

    IResource[] files = TexlipseProperties.getAllProjectFiles(project);

    if (files != null) {
      IFile mainFile = TexlipseProperties.getProjectSourceFile(project);

      for (int i = 0; i < files.length; i++) {
        // IPath path = files[i].getFullPath();
        String ext = files[i].getFileExtension();
        // here are the file types we want to parse
        if ("tex".equals(ext) || "ltx".equals(ext) || "sty".equals(ext)) {
          try {
            String input = TexlipseProperties.getFileContents(files[i]);
            LatexRefExtractingParser lrep = new LatexRefExtractingParser();
            lrep.parse(input);
            if (lrep.isFatalErrors()) {
              MarkerHandler marker = MarkerHandler.getInstance();
              marker.addFatalError(
                  editor,
                  "The file "
                      + files[i].getFullPath()
                      + " contains fatal errors, parsing aborted.");
              continue;
            }
            List<ReferenceEntry> labels = lrep.getLabels();
            if (labels.size() > 0) {
              labelContainer.addRefSource(files[i].getProjectRelativePath().toString(), labels);
            }
            List<TexCommandEntry> commands = lrep.getCommands();
            if (commands.size() > 0) {
              commandContainer.addRefSource(files[i].getProjectRelativePath().toString(), commands);
            }
            // Only update Preamble, Bibstyle if main Document
            if (files[i].equals(mainFile)) {
              String[] bibs = lrep.getBibs();
              boolean biblatexMode = lrep.isBiblatexMode();
              String biblatexBackend = lrep.getBiblatexBackend();
              this.updateBiblatex(project, biblatexMode, biblatexBackend, true);
              this.updateBibs(bibs, biblatexMode, files[i]);

              String preamble = lrep.getPreamble();
              if (preamble != null) {
                TexlipseProperties.setSessionProperty(
                    project, TexlipseProperties.PREAMBLE_PROPERTY, preamble);
              }

              String bibstyle = lrep.getBibstyle();
              if (bibstyle != null)
                TexlipseProperties.setSessionProperty(
                    project, TexlipseProperties.BIBSTYLE_PROPERTY, bibstyle);
            }
          } catch (IOException ioe) {
            TexlipsePlugin.log(
                "Unable to open file " + files[i].getFullPath() + " for parsing", ioe);
          }
        }
      }
      // save time by doing this last
      labelContainer.organize();
      commandContainer.organize();
    }
  }