本文整理汇总了Java中org.eclipse.xtext.formatting2.regionaccess.IComment类的典型用法代码示例。如果您正苦于以下问题:Java IComment类的具体用法?Java IComment怎么用?Java IComment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IComment类属于org.eclipse.xtext.formatting2.regionaccess包,在下文中一共展示了IComment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
protected String toString(ITextSegment region) {
String result;
if (region instanceof IEObjectRegion)
result = toString((IEObjectRegion) region);
else if (region instanceof ISemanticRegion)
result = toString((ISemanticRegion) region);
else if (region instanceof IHiddenRegion)
result = toString((IHiddenRegion) region);
else if (region instanceof IWhitespace)
result = toString((IWhitespace) region);
else if (region instanceof IComment)
result = toString((IComment) region);
else if (region != null)
result = region.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(region));
else
result = "null";
if (hightlightOrigin && region == origin)
return ">>>" + result + "<<<";
return result;
}
示例2: createCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public ITextReplacer createCommentReplacer(IComment comment) {
EObject grammarElement = comment.getGrammarElement();
if (grammarElement instanceof AbstractRule) {
String ruleName = ((AbstractRule) grammarElement).getName();
if (ruleName.startsWith("ML"))
return new MultilineCommentReplacer(comment, '*');
if (ruleName.startsWith("SL")) {
if (comment.getLineRegions().get(0).getIndentation().getLength() > 0)
return new SinglelineDocCommentReplacer(comment, "//");
else
return new SinglelineCodeCommentReplacer(comment, "//");
}
}
String elementName = new GrammarElementTitleSwitch().showQualified().showRule().doSwitch(grammarElement);
throw new IllegalStateException("No " + ITextReplacer.class.getSimpleName() + " configured for " + elementName);
}
示例3: N4MultilineCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
/** @see MultilineCommentReplacer#MultilineCommentReplacer(IComment, char) */
public N4MultilineCommentReplacer(IComment comment, char prefix) {
super(comment, prefix);
this.prefix = prefix;
multiline = comment.isMultiline();
}
示例4: collectAlternatingSpaceAndComments
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
protected List<ITextSegment> collectAlternatingSpaceAndComments(boolean includeComments) {
List<IHiddenRegionPart> parts = getParts();
if (parts.isEmpty()) {
return Collections.<ITextSegment>singletonList(this);
} else {
ITextSegment lastWhitespace = null;
List<ITextSegment> result = Lists.newArrayList();
for (IHiddenRegionPart part : parts) {
if (part instanceof IWhitespace) {
if (lastWhitespace == null) {
result.add(part);
lastWhitespace = part;
} else {
int mergedLength = lastWhitespace.getLength() + part.getLength();
lastWhitespace = new TextSegment(access, lastWhitespace.getOffset(), mergedLength);
result.set(result.size() - 1, lastWhitespace);
}
} else if (part instanceof IComment) {
if (lastWhitespace == null) {
result.add(new TextSegment(access, part.getOffset(), 0));
} else {
lastWhitespace = null;
}
if (includeComments) {
result.add(part);
}
}
}
if (lastWhitespace == null) {
result.add(new TextSegment(access, getEndOffset(), 0));
}
return ImmutableList.copyOf(result);
}
}
示例5: containsComment
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
@Override
public boolean containsComment() {
for (IHiddenRegionPart hidden : hiddens)
if (hidden instanceof IComment)
return true;
return false;
}
示例6: getFirstSpace
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
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);
}
示例7: hasEmptyBody
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
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;
}
示例8: FixedMultilineCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
/** */
public FixedMultilineCommentReplacer(IComment comment) {
super(comment);
this.multiline = comment.isMultiline();
}
示例9: MultilineCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public MultilineCommentReplacer(IComment comment, char prefix) {
super(comment);
this.prefix = prefix;
this.multiline = comment.isMultiline();
}
示例10: SinglelineDocCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public SinglelineDocCommentReplacer(IComment comment, String prefix) {
super(comment, prefix);
}
示例11: SinglelineCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public SinglelineCommentReplacer(IComment comment, String prefix) {
super(comment);
this.prefix = prefix;
}
示例12: CommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public CommentReplacer(IComment comment) {
this.comment = comment;
}
示例13: getComment
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public IComment getComment() {
return comment;
}
示例14: SinglelineCodeCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
public SinglelineCodeCommentReplacer(IComment comment, String prefix) {
super(comment, prefix);
}
示例15: OffMultilineCommentReplacer
import org.eclipse.xtext.formatting2.regionaccess.IComment; //导入依赖的package包/类
/**
* Ctor for comment with indentation.
*
* @param comment
* to be processed
*/
public OffMultilineCommentReplacer(IComment comment) {
this(comment, false);
}