Java Code Examples for org.eclipse.xtext.formatting2.regionaccess.IComment#getTextRegionAccess()
The following examples show how to use
org.eclipse.xtext.formatting2.regionaccess.IComment#getTextRegionAccess() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SinglelineCommentReplacer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ITextSegment getFirstSpace() { IComment comment = getComment(); String text = comment.getText(); if (!text.startsWith(prefix)) return null; int start = prefix.length(); for (int i = start; i < text.length(); i++) { char charAt = text.charAt(i); if (!Character.isWhitespace(charAt) || charAt == '\r' || charAt == '\n') return new TextSegment(comment.getTextRegionAccess(), comment.getOffset() + start, i - start); } return new TextSegment(comment.getTextRegionAccess(), comment.getOffset() + start, text.length() - start); }
Example 2
Source File: BugSinglelineCommentIndentation.java From sarl with Apache License 2.0 | 5 votes |
/** Fixing the bug. * * @param context the replacement context. * @param comment the comment for which the fix must be applied. * @return the new context. */ @SuppressWarnings("static-method") public ITextReplacerContext fix(final ITextReplacerContext context, IComment comment) { final IHiddenRegion hiddenRegion = comment.getHiddenRegion(); if (detectBugSituation(hiddenRegion) && fixBug(hiddenRegion)) { // Indentation of the first comment line final ITextRegionAccess access = comment.getTextRegionAccess(); final ITextSegment target = access.regionForOffset(comment.getOffset(), 0); context.addReplacement(target.replaceWith(context.getIndentationString(1))); } return context; }
Example 3
Source File: BugMultilineCommentIndentation.java From sarl with Apache License 2.0 | 5 votes |
/** Fixing the bug. * * @param context the replacement context. * @param comment the comment for which the fix must be applied. * @return the new context. */ @SuppressWarnings("static-method") public ITextReplacerContext fix(final ITextReplacerContext context, IComment comment) { final IHiddenRegion hiddenRegion = comment.getHiddenRegion(); if (detectBugSituation(hiddenRegion) && fixBug(hiddenRegion)) { // Indentation of the first comment line final ITextRegionAccess access = comment.getTextRegionAccess(); final ITextSegment target = access.regionForOffset(comment.getOffset(), 0); context.addReplacement(target.replaceWith(context.getIndentationString(1))); // Indentation of the comment's lines return new FixedReplacementContext(context); } return context; }
Example 4
Source File: DocumentationFormatter.java From sarl with Apache License 2.0 | 4 votes |
public RegionAccessor(ITextReplacerContext context, IComment comment) { super(comment.getText(), null); this.context = context; this.comment = comment; this.access = comment.getTextRegionAccess(); }