Package org.eclipse.xtext.ui.editor.reconciler

Examples of org.eclipse.xtext.ui.editor.reconciler.ReplaceRegion


        @Override
        public ReplaceRegion exec(XtextResource state) throws Exception {
          // No action if there are hard syntax errors
          if(!PPValidationUtils.hasSyntaxErrors(state) && process(state))
            return new ReplaceRegion(0, document.getLength(), document.get());
          return null;
          // return new ReplaceRegion(0, 0, ""); // nothing changed
        }

        public boolean process(XtextResource state) throws Exception {
View Full Code Here


        // EObject context = getContext(state.getContents().get(0));
        IDomNode root = getSerializer().serializeToDom(state.getContents().get(0), false);
        org.eclipse.xtext.util.ReplaceRegion r = getFormatter().format(
          root, new TextRegion(region.getOffset(), region.getLength()), //
          getFormattingContextFactory().create(state, FormattingOption.Format), errors);
        ReplaceRegion replaceRegion = new ReplaceRegion(r.getOffset(), r.getLength(), r.getText());
        try {
          if(replaceRegion != null) {

            String current = null;
            try {
              current = doc.get(replaceRegion.getOffset(), replaceRegion.getLength());
            }
            catch(BadLocationException e) {
              // ignore, current is null
            }
            // Optimize - if replacement is equal to current
            if(current == null || !current.equals(replaceRegion.getText()))
              doc.replace(replaceRegion.getOffset(), replaceRegion.getLength(), r.getText());
          }
        }
        catch(BadLocationException e) {
          throw new RuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.ui.editor.reconciler.ReplaceRegion

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.