Example #1
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();
    }
  }
Example #2
0
 /**
  * Updates the commands.
  *
  * @param commands
  */
 private void updateCommands(ArrayList<TexCommandEntry> commands) {
   IResource resource = getFile();
   if (resource == null) return;
   if (commandContainer.addRefSource(resource.getProjectRelativePath().toString(), commands))
     commandContainer.organize();
 }