Ejemplo n.º 1
0
 /**
  * Synchronize tern script paths with JSDT "Include Path"
  *
  * @param jsProject
  * @param ternProject
  */
 private void synchTernScriptPaths(IJavaScriptProject jsProject, IIDETernProject ternProject) {
   try {
     ternProject.removeExternalScriptPaths(JSDT_EXTERNAL_LABEL);
     IIncludePathEntry[] entries = jsProject.getRawIncludepath();
     for (int i = 0; i < entries.length; i++) {
       IIncludePathEntry entry = entries[i];
       switch (entry.getEntryKind()) {
         case IIncludePathEntry.CPE_LIBRARY:
           // TODO : manage JSDT library
           // JSDT Source file => Tern script path file.
           /*IFolder libFolder = ResourcesPlugin.getWorkspace().getRoot()
           		.getFolder(entry.getPath());
           try {
           	ternProject.addExternalScriptPath(libFolder,
           			ScriptPathsType.FOLDER, JSDT_EXTERNAL_LABEL);
           } catch (IOException e) {
           	Trace.trace(Trace.SEVERE,
           			"Error while adding external tern script path for project "
           					+ ternProject.getProject().getName(), e);
           }*/
           break;
         case IIncludePathEntry.CPE_SOURCE:
           if (entry.getPath().segmentCount() == 1) {
             // It's a project
             synchTernProjectScriptPaths(ternProject, entry);
           } else {
             // It's a folder
             // JSDT Source folder => Tern script path folder.
             IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(entry.getPath());
             try {
               ternProject.addExternalScriptPath(
                   folder, ScriptPathsType.FOLDER, JSDT_EXTERNAL_LABEL);
             } catch (IOException e) {
               Trace.trace(
                   Trace.SEVERE,
                   "Error while adding external tern script path for project "
                       + ternProject.getProject().getName(),
                   e);
             }
           }
           break;
         case IIncludePathEntry.CPE_PROJECT:
           // JS file?
           synchTernProjectScriptPaths(ternProject, entry);
           break;
       }
     }
   } catch (JavaScriptModelException e) {
     Trace.trace(
         Trace.SEVERE,
         "Error while getting JSDT ClassPath for project " + ternProject.getProject().getName(),
         e);
   }
 }
Ejemplo n.º 2
0
 /**
  * Synchronize tern project script paths with JSDT "Include Path"
  *
  * @param ternProject
  * @param entry
  */
 private void synchTernProjectScriptPaths(IIDETernProject ternProject, IIncludePathEntry entry) {
   // JSDT Project => Tern script path project.
   IProject project =
       ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().lastSegment());
   try {
     ternProject.addExternalScriptPath(project, ScriptPathsType.PROJECT, JSDT_EXTERNAL_LABEL);
   } catch (IOException e) {
     Trace.trace(
         Trace.SEVERE,
         "Error while adding external tern script path for project "
             + ternProject.getProject().getName(),
         e);
   }
 }