Java Code Examples for org.eclipse.xtext.formatting2.regionaccess.IComment#getText()

The following examples show how to use org.eclipse.xtext.formatting2.regionaccess.IComment#getText() . 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 vote down vote up
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: SinglelineCommentReplacer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean hasEmptyBody() {
	IComment comment = getComment();
	String text = comment.getText();
	if (!text.startsWith(prefix))
		return false;
	int start = prefix.length();
	for (int i = start; i < text.length(); i++) {
		char charAt = text.charAt(i);
		if (!Character.isWhitespace(charAt))
			return false;
	}
	return true;
}
 
Example 3
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 4 votes vote down vote up
public RegionAccessor(ITextReplacerContext context, IComment comment) {
	super(comment.getText(), null);
	this.context = context;
	this.comment = comment;
	this.access = comment.getTextRegionAccess();
}