Examples of TextChange


Examples of org.eclipse.ltk.core.refactoring.TextChange

   * {@link #createChange(IProgressMonitor)}.</p>
   *
   * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getTextChange(java.lang.Object)
   */
  public TextChange getTextChange(Object element) {
    TextChange existingChange = (TextChange)fLocalTextChanges.get(element);
    if(existingChange == null) {
      existingChange = super.getTextChange(element);
    }
   
    return existingChange;
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

   */
  private Change createChange(JavaSearchDocumentDelegate searchDoc, TextEdit edit, RefactoringParticipant participant) {
    IDocument doc = searchDoc.getJspTranslation().getJspDocument();
    String description = getDescription();
   
    TextChange existingChange = participant.getTextChange(searchDoc.getFile());
    TextChange change = null;
    if(existingChange != null) {
      try {
        existingChange.addEdit(edit);
      }catch (MalformedTreeException e) {
        Logger.logException("MalformedTreeException while adding edit " + //$NON-NLS-1$
            edit + " to existing change " + change, e); //$NON-NLS-1$
      }
     
      TextEditGroup group = new TextEditGroup(description, edit);
      existingChange.addTextEditGroup(group);
    } else {
      change = new JSPRenameChange(searchDoc.getFile(), doc, edit, searchDoc.getFile().getName());
      TextEditGroup group = new TextEditGroup(description, edit);
      change.addTextEditGroup(group);
    }
   
    return change;
  }
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

   * {@link #createChange(IProgressMonitor)}.</p>
   *
   * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getTextChange(java.lang.Object)
   */
  public TextChange getTextChange(Object element) {
    TextChange existingChange = (TextChange)fLocalTextChanges.get(element);
    if(existingChange == null) {
      existingChange = super.getTextChange(element);
    }
   
    return existingChange;
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

   * {@link #createChange(IProgressMonitor)}.</p>
   *
   * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getTextChange(java.lang.Object)
   */
  public TextChange getTextChange(Object element) {
    TextChange existingChange = (TextChange)fLocalTextChanges.get(element);
    if(existingChange == null) {
      existingChange = super.getTextChange(element);
    }
   
    return existingChange;
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

      astTextEdit = serviceUnit.rewrite(document, serviceType.getJavaProject().getOptions(true));
    }
    // merge AST edit with existing edit for service type file
    {
      IFile serviceTypeFile = (IFile) serviceType.getUnderlyingResource();
      TextChange existingTextChange = getTextChange(serviceTypeFile);
      if (existingTextChange != null) {
        existingTextChange.addEdit(astTextEdit);
        return null;
      } else {
        CompilationUnitChange serviceUnitChange =
            new CompilationUnitChange(serviceType.getFullyQualifiedName(), serviceCompilationUnit);
        serviceUnitChange.setEdit(astTextEdit);
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

    if (asyncType != null) {
      String asyncTypeName = asyncType.getFullyQualifiedName();
      // when we move service, Eclipse adds import for Async type,
      // but we don't need it, so remove this import from text change
      {
        TextChange textChange = getTextChange(m_type.getUnderlyingResource());
        if (textChange != null) {
          removeInsertEdits_forSubString(textChange.getEdit(), "import " + asyncTypeName);
          removeInsertEdits_forNewLine(textChange.getEdit());
        }
      }
      // remove Async type, our builder will regenerate it near to moved service type
      compositeChange.add(RefactoringUtils.createDeleteTypeChange(asyncType));
    }
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

  /**
   * Adds {@link TextEdit}s into existing Java file {@link Change}.
   */
  private void addHandlerMethodChanges(CompositeChange compositeChange, IProgressMonitor pm)
      throws Exception {
    TextChange change = new CompilationUnitChange("(No matter)", m_field.getCompilationUnit());
    change.setEdit(new MultiTextEdit());
    // update handler methods
    String oldMethodPrefix = "on" + StringUtils.capitalize(m_oldName);
    String newMethodPrefix = "on" + StringUtils.capitalize(m_newName);
    IType type = (IType) m_field.getParent();
    for (IMethod method : type.getMethods()) {
      // prepare @UiHandler annotation
      IAnnotation annotation = getHandlerAnnotation(method);
      if (annotation == null) {
        continue;
      }
      // update @UiHandler name
      {
        ISourceRange annoRange = annotation.getSourceRange();
        ISourceRange nameRange = annotation.getNameRange();
        int nameEnd = nameRange.getOffset() + nameRange.getLength();
        int annoEnd = annoRange.getOffset() + annoRange.getLength();
        change.addEdit(new ReplaceEdit(nameEnd, annoEnd - nameEnd, "(\"" + m_newName + "\")"));
      }
      // rename method
      String methodName = method.getElementName();
      if (methodName.startsWith(oldMethodPrefix)) {
        String newName = newMethodPrefix + StringUtils.removeStart(methodName, oldMethodPrefix);
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

  public Object getAdditionalProposalInfo(IProgressMonitor monitor) {

    final StringBuffer buf = new StringBuffer();

    try {
      final TextChange change = getTextChange();

      change.setKeepPreviewEdits(true);
      final IDocument previewContent = change.getPreviewDocument(monitor);
      final TextEdit rootEdit = change.getPreviewEdit(change.getEdit());

      class EditAnnotator extends TextEditVisitor {
        private int fWrittenToPos = 0;

        public void unchangedUntil(int pos) {
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

   *             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;
    }
    TextEdit rootEdit = new MultiTextEdit();
    change.setEdit(rootEdit);

    // initialize text change
    IDocument document = change
        .getCurrentDocument(new NullProgressMonitor());
    addEdits(document, rootEdit);
    return change;
  }
View Full Code Here

Examples of org.eclipse.ltk.core.refactoring.TextChange

     * @param status the status for the change.
     * @param fChange tho 'root' change.
     * @param editsAlreadyCreated
     */
    private void createCurrModuleChange() {
        TextChange docChange;
        if (this.currentFile != null) {
            docChange = new PyTextFileChange("Current module: " + moduleName, this.currentFile);
        } else {
            //used for tests
            docChange = PyDocumentChange.create("Current module: " + moduleName, this.currentDoc);
        }
        if (docOccurrences.size() == 0) {
            status.addFatalError("No occurrences found.");
            return;
        }

        MultiTextEdit rootEdit = new MultiTextEdit();
        docChange.setEdit(rootEdit);
        docChange.setKeepPreviewEdits(true);

        List<Tuple<TextEdit, String>> renameEdits = getAllRenameEdits(currentDoc, docOccurrences);
        fillEditsInDocChange(docChange, rootEdit, renameEdits);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.