Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.ISourceModule


   * @return returns the created text change.
   * @throws CoreException
   *             thrown if the creation of the text change failed.
   */
  protected TextChange createTextChange() throws CoreException {
    ISourceModule cu = getCompilationUnit();
    String name = getName();
    TextChange change;
    if (!cu.getResource().exists()) {
      String source;
      try {
        source = cu.getSource();
      } catch (ModelException e) {
        PHPUiPlugin.log(e);
        source = new String(); // empty
      }
      Document document = new Document(source);
      document.setInitialLineDelimiter(StubUtility
          .getLineDelimiterUsed(cu.getScriptProject()));
      change = new DocumentChange(name, document);
    } else {
      SourceModuleChange cuChange = new SourceModuleChange(name, cu);
      cuChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
      change = cuChange;
View Full Code Here


      return null;
    }

    final int offset = region.getOffset();

    final ISourceModule sourceModule = (ISourceModule) input;
    ModuleDeclaration moduleDeclaration = SourceParserUtil
        .getModuleDeclaration(sourceModule, null);
    if (moduleDeclaration == null) {
      return null;
    }

    IncludeHyperlinkVisitor includeVisitor = new IncludeHyperlinkVisitor(
        offset, sourceModule);
    try {
      moduleDeclaration.traverse(includeVisitor);
    } catch (Exception e) {
      PHPUiPlugin.log(e);
    }

    if (includeVisitor.getFile() != null) {
      if (!inclusive(region, includeVisitor.getSelectRegion())) {
        return null;
      }

      Set<String> set = new HashSet<String>();
      set.add(sourceModule.getResource().getLocation().toOSString());
      ISourceModule includedSourceModule = FileNetworkUtility
          .findSourceModule(sourceModule, includeVisitor.getFile(),
              set);
      if (includedSourceModule != null) {
        return new IHyperlink[] { new ModelElementHyperlink(
            includeVisitor.getSelectRegion(), includedSourceModule,
View Full Code Here

    return super.guessContextInformationPosition(context);
  }

  private void handleCodeCompletionException(ModelException e,
      ScriptContentAssistInvocationContext context) {
    ISourceModule module = context.getSourceModule();
    Shell shell = context.getViewer().getTextWidget().getShell();
    if (e.isDoesNotExist()
        && !module.getScriptProject().isOnBuildpath(module)) {
      IPreferenceStore store = DLTKUIPlugin.getDefault()
          .getPreferenceStore();
      boolean value = store
          .getBoolean(PreferenceConstants.NOTIFICATION_NOT_ON_BUILDPATH_MESSAGE);
      if (!value) {
View Full Code Here

  }

  public ISourceModule getWorkingCopy(String path, String source,
      WorkingCopyOwner owner, IProblemRequestor problemRequestor)
      throws ModelException {
    ISourceModule workingCopy = getSourceModule(path);
    if (owner != null)
      workingCopy = workingCopy
          .getWorkingCopy(/* owner, problemRequestor, */null/*
                                   * no
                                   * progress
                                   * monitor
                                   */);
    else
      workingCopy.becomeWorkingCopy(problemRequestor, null/*
                                 * no progress
                                 * monitor
                                 */);
    workingCopy.getBuffer().setContents(source);
    // if (problemRequestor instanceof ProblemRequestor)
    // ((ProblemRequestor)
    // problemRequestor).initialize(source.toCharArray());
    workingCopy.makeConsistent(null/* no progress monitor */);
    return workingCopy;
  }
View Full Code Here

    desc.setNatureIds(new String[] { PHPNature.ID });
    project.setDescription(desc, null);

    WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
      public IBuffer createBuffer(ISourceModule workingCopy) {
        ISourceModule original = workingCopy.getPrimary();
        IResource resource = original.getResource();
        if (resource != null) {
          if (resource instanceof IFile) {
            return new DocumentAdapter(workingCopy,
                (IFile) resource);
          }
View Full Code Here

              }

              protected void runTest() throws Throwable {

                IFile file = filesMap.get(pdttFile);
                ISourceModule modelElement = (ISourceModule) DLTKCore
                    .create(file);
                if (ScriptModelUtil.isPrimary(modelElement))
                  modelElement.becomeWorkingCopy(
                      new IProblemRequestor() {

                        public void acceptProblem(
                            IProblem problem) {
                          // TODO Auto-generated
View Full Code Here

  public static boolean hasCorrections(Annotation annotation) {
    if (annotation instanceof IScriptAnnotation) {
      IScriptAnnotation javaAnnotation = (IScriptAnnotation) annotation;
      if (javaAnnotation.getId() != null) {
        ISourceModule cu = javaAnnotation.getSourceModule();
        return hasCorrections(cu, javaAnnotation.getId(),
            javaAnnotation.getMarkerType());
      }

    }
View Full Code Here

      int documentOffset = quickAssistContext.getOffset();

      IEditorPart part = fAssistant.getEditor();

      ISourceModule cu = DLTKUIPlugin.getEditorInputModelElement(part
          .getEditorInput());
      IAnnotationModel model = DLTKUIPlugin.getDocumentProvider()
          .getAnnotationModel(part.getEditorInput());

      int length = viewer != null ? viewer.getSelectedRange().y : 0;
View Full Code Here

    }

    IFile file = ResourcesPlugin.getWorkspace().getRoot()
        .getFile(new Path(containerName + "/" + fileName)); //$NON-NLS-1$
    ISourceModule sourceModule = DLTKCore.createSourceModuleFrom(file);
    TemplateContextType type = contextTypeRegistry.getContextType(template
        .getContextTypeId());
    return ((ScriptTemplateContextType) type).createContext(document, 0, 0,
        sourceModule);
  }
View Full Code Here

    IMenuManager refactorSubmenu = (IMenuManager) menu.find(MENU_ID);
    if (refactorSubmenu == null)
      refactorSubmenu = new MenuManager(menuText, MENU_ID);
    if (fEditor != null) {
      ISourceModule element = SelectionConverter.getInput(fEditor);
      if (element != null && ActionUtils.isPHPSource(element)) {
        refactorSubmenu.addMenuListener(new IMenuListener() {
          public void menuAboutToShow(IMenuManager manager) {
            refactorMenuShown(manager);
          }
View Full Code Here

TOP

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

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.