Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.TextEdit.apply()


       
        // computation of the text edits
        TextEdit edits = astRoot.rewrite(document, asyncContents.getJavaProject().getOptions(true));

        // computation of the new source code
        edits.apply(document);
        String newSource = document.get();

        // update of the compilation unit     
        clientPackage.createCompilationUnit(remoteServiceAsyncName+".java", newSource, true, monitor); //$NON-NLS-1$
       
View Full Code Here


          String cuSource = cu.getSource();
          TextEdit textEdit = formatString(CodeFormatter.K_COMPILATION_UNIT, cuSource, 0, TextUtilities.getDefaultLineDelimiter(document), getPreferences());

          TextEdit jspEdit = translationUtil.getTranslation().getJspEdit(textEdit);
          if (jspEdit != null && jspEdit.hasChildren())
            jspEdit.apply(document);
        }

      }
      catch (MalformedTreeException exception) {
        Logger.logException(exception);
View Full Code Here

            try {
              TextEdit edit = formatter.format(model, fRegion.getOffset(), fRegion.getLength());
              if (edit != null) {
                try {
                  model.aboutToChangeModel();
                  edit.apply(document);
                }
                finally {
                  model.changedModel();
                }
              }
View Full Code Here

    if(fProgressMonitor != null)
      fProgressMonitor.worked(1);
   
    try {
      structuredModel.aboutToChangeModel();
      edit.apply(structuredDocument);
      if(fProgressMonitor != null)
        fProgressMonitor.worked(1);
    }
    catch (Exception e) {
      Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
View Full Code Here

             * @throws IllegalArgumentException if offset is lower than 0, length is lower than 0 or
             * length is greater than source length.
             */
            TextEdit edit = getCodeFormatter().format(org.eclipse.wst.jsdt.core.formatter.CodeFormatter.K_JAVASCRIPT_UNIT, text, startOffset, endOffset - startOffset, 0, lineSeparator);
            if (edit != null) {
                edit.apply(doc);
            } else {
                throw new RuntimeException(
                        Notifier.FORMATTING_FAILED_PROBABLY_DUE_TO_NOT_COMPILABLE_CODE_OR_WRONG_CONFIG_FILE);
            }

View Full Code Here

             */

            TextEdit edit = getCodeFormatter().format(CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, text,
                    startOffset, endOffset - startOffset, 0, lineSeparator);
            if (edit != null) {
                edit.apply(doc);
            } else {
                throw new RuntimeException(Notifier.FORMATTING_FAILED_PROBABLY_DUE_TO_NOT_COMPILABLE_CODE_OR_WRONG_CONFIG_FILE);
            }
            return doc.get();
        } catch (BadLocationException e) {
View Full Code Here

        IDocument document = new org.eclipse.jface.text.Document(documentIJ.getText());
        Properties javaFormattingPrefs = settings.getJavaProperties().get();
        Properties properties = settings.getJSProperties().get();

        TextEdit formatEdit = JsniFormattingUtil.format(document, javaFormattingPrefs, properties, range);
        formatEdit.apply(document);
        documentIJ.setText(document.get());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

        HashMap<String, String> jsMap = TestUtils.getJSProperties();

        IDocument document = new Document(INPUT);
        TextEdit format1 = JsniFormattingUtil.format(document, partition, javaFormattingPrefs, jsMap, null);
//        TextEdit format1 = JsniFormattingUtil.format(document,javaFormattingPrefs, jsMap, null);
        format1.apply(document);
        Assert.assertEquals(FORMATTED, document.get());
        System.err.println(FORMATTED);
    }

}
View Full Code Here

      TextEdit edit = getCodeFormatter().format(
          CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, text, startOffset,
          endOffset - startOffset, 0, Settings.LINE_SEPARATOR);
      if (edit != null) {
        LOG.debug("reformatting done");
        edit.apply(doc);
      } else {
        throw new FormattingFailedException();
      }
      return doc.get();
    } catch (BadLocationException e) {
View Full Code Here

        IDocument document = new Document(createString(getTestClasses()));

        // Apply the formatting and test the result
        TextEdit formatEdit = JsniFormattingUtil.format(document, javaPrefs, javaScriptPrefs, new Range(0, document.get().length(), true));
        formatEdit.apply(document);
        Assert.assertEquals(getFormattedDocument(), document.get());
        System.err.println("---------------------------");
        System.err.println(getFormattedDocument());
        System.err.println("---------------------------");
        System.err.println(document.get());
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.