Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.IScriptProject


    super.configure();

    // enable workspace validation for this nature
    addToFrontOfBuildSpec(VALIDATION_BUILDER_ID);

    IScriptProject scriptProject = DLTKCore.create(getProject());
    LanguageModelInitializer.enableLanguageModelFor(scriptProject);

  }
View Full Code Here


  private ProjectOptions() {
  }

  private static IProject getProject(IModelElement modelElement) {
    IScriptProject scriptProject = modelElement.getScriptProject();
    if (scriptProject != null) {
      return scriptProject.getProject();
    }
    return null;
  }
View Full Code Here

   * Creates search scope
   */
  protected IDLTKSearchScope createSearchScope() {
    ISourceModule sourceModule = ((AbstractCompletionContext) context)
        .getSourceModule();
    IScriptProject scriptProject = sourceModule.getScriptProject();
    if (scriptProject != null) {
      return SearchEngine.createSearchScope(scriptProject);
    }
    IProjectFragment projectFragment = (IProjectFragment) sourceModule
        .getAncestor(IModelElement.PROJECT_FRAGMENT);
View Full Code Here

        sp);
    if (template == null) {
      return null;
    }

    IScriptProject project = sp;
    CodeTemplateContext context = new CodeTemplateContext(
        template.getContextTypeId(), project, lineDelimiter);
    context.setVariable(CodeTemplateContextType.TYPE_COMMENT,
        typeComment != null ? typeComment : ""); //$NON-NLS-1$
    context.setVariable(CodeTemplateContextType.FILE_COMMENT,
View Full Code Here

    // for some reason, when creating a dltk ruby project, the dltk script
    // builder is not added to the .project, so here we force it to be added.
    IProjectNature nature = project.getNature(RubyNature.NATURE_ID);
    nature.configure();

    IScriptProject scriptProject = DLTKCore.create(project);
    scriptProject.makeConsistent(null);
    scriptProject.save(null, false);
  }
View Full Code Here

    // This block to find the ISourceModule is mostly copied from:
    // org.eclipse.dltk.ruby.internal.debug.ui.console.RubyConsoleSourceModuleLookup
    // Is there an easier way?
    IPath path = file.getFullPath();
    IProject project = file.getProject();
    IScriptProject scriptProject = DLTKCore.create(project);
    IProjectFragment[] roots = scriptProject.getProjectFragments();
    ISourceModule module = null;
    for (int j = 0, rootCount = roots.length; j < rootCount; j++) {
      final IProjectFragment root = roots[j];
      IPath rootPath = root.getPath();
View Full Code Here

      }
    }

    String dependsString = commandLine.getValue(Options.DEPENDS_OPTION);

    IScriptProject scriptProject = DLTKCore.create(project);

    if (!project.getFile(BUILDPATH).exists()) {
      IDLTKLanguageToolkit toolkit = getLanguageToolkit(getNatureId());
      BuildpathDetector detector = new BuildpathDetector(project, toolkit);
      detector.detectBuildpath(null);
      IBuildpathEntry[] detected = detector.getBuildpath();

      // remove any entries the detector may have added that are not valid for
      // this project (currently happens on php projects with the
      // org.eclipse.dltk.launching.INTERPRETER_CONTAINER entry).
      ArrayList<IBuildpathEntry> entries = new ArrayList<IBuildpathEntry>();
      for (IBuildpathEntry entry : detected){
        IModelStatus status = BuildpathEntry
          .validateBuildpathEntry(scriptProject, entry, true);
        if(status.isOK()){
          entries.add(entry);
        }
      }
      detected = entries.toArray(new IBuildpathEntry[entries.size()]);

      IBuildpathEntry[] depends =
        createOrUpdateDependencies(scriptProject, dependsString);

      IBuildpathEntry[] buildpath = merge(
          new IBuildpathEntry[][]{detected, depends});
            //scriptProject.readRawClasspath(), detected, depends, container

      scriptProject.setRawBuildpath(buildpath, null);
    }

    if (interpreter != null){
      IBuildpathEntry[] buildpath = scriptProject.getRawBuildpath();
      int containerIndex = 0;
      for (int i = 0; i < buildpath.length; i++){
        if (buildpath[i].getEntryKind() == IBuildpathEntry.BPE_CONTAINER){
          containerIndex = i;
          break;
        }
      }

      if (containerIndex == 0){
        throw new RuntimeException("No container buildpath entry found.");
      }

      IBuildpathEntry container = buildpath[containerIndex];
      buildpath[containerIndex] = DLTKCore.newContainerEntry(
          ScriptRuntime.newInterpreterContainerPath(interpreter),
          container.getAccessRules(),
          container.getExtraAttributes(),
          container.isExported());
      scriptProject.setRawBuildpath(buildpath, null);
    }

    scriptProject.makeConsistent(null);
    scriptProject.save(null, false);
  }
View Full Code Here

  @Override
  public List<Error> update(IProject project, CommandLine commandLine)
    throws Exception
  {
    IScriptProject scriptProject = DLTKCore.create(project);
    scriptProject.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);

    // validate that .buildpath xml is well formed and valid.
    PluginResources resources = (PluginResources)
      Services.getPluginResources(PluginResources.NAME);
    List<Error> errors = XmlUtils.validateXml(
        scriptProject.getProject().getName(),
        BUILDPATH,
        resources.getResource(BUILDPATH_XSD).toString());
    if(errors.size() > 0){
      return errors;
    }

    String dotbuildpath = scriptProject.getProject().getFile(BUILDPATH)
      .getRawLocation().toOSString();

    IBuildpathEntry[] entries = scriptProject.readRawBuildpath();
    FileOffsets offsets = FileOffsets.compile(dotbuildpath);
    String buildpath = IOUtils.toString(new FileInputStream(dotbuildpath));
    errors = new ArrayList<Error>();
    for(IBuildpathEntry entry : entries){
      IModelStatus status = BuildpathEntry.validateBuildpathEntry(
          scriptProject, entry, true);
      if(!status.isOK()){
        errors.add(createErrorForEntry(
              entry, status, offsets, dotbuildpath, buildpath));
      }
    }

    // always set the buildpath anyways, so that the user can correct the file.
    //if(status.isOK() && errors.isEmpty()){
      scriptProject.setRawBuildpath(entries, null);
      scriptProject.makeConsistent(null);
    //}

    if(errors.size() > 0){
      return errors;
    }
View Full Code Here

        IProject theProject = ProjectUtils.getProject(dependPaths[ii]);
        if(!theProject.exists()){
          throw new IllegalArgumentException(Services.getMessage(
              "project.depends.not.found", dependPaths[ii]));
        }
        IScriptProject otherProject = DLTKCore.create(theProject);
        entries[ii] = DLTKCore.newProjectEntry(otherProject.getPath(), true);
      }
      return entries;
    }
    return new IBuildpathEntry[0];
  }
View Full Code Here

  public Object execute(CommandLine commandLine)
    throws Exception
  {
    String projectName = commandLine.getValue(Options.PROJECT_OPTION);
    IProject project = ProjectUtils.getProject(projectName);
    IScriptProject scriptProject = DLTKCore.create(project);

    ArrayList<String> paths = new ArrayList<String>();
    HashSet<IScriptProject> visited = new HashSet<IScriptProject>();

    collect(scriptProject, paths, visited);
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.core.IScriptProject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.