本文整理汇总了Java中com.intellij.psi.PsiComment.getText方法的典型用法代码示例。如果您正苦于以下问题:Java PsiComment.getText方法的具体用法?Java PsiComment.getText怎么用?Java PsiComment.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiComment
的用法示例。
在下文中一共展示了PsiComment.getText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeComment
import com.intellij.psi.PsiComment; //导入方法依赖的package包/类
@Nullable
private static String getTypeComment(@NotNull PyTargetExpression target) {
final PsiElement commentContainer = PsiTreeUtil.getParentOfType(target, PyAssignmentStatement.class, PyWithStatement.class,
PyForPart.class);
if (commentContainer != null) {
final PsiComment comment = getSameLineTrailingCommentChild(commentContainer);
if (comment != null) {
final String text = comment.getText();
final Matcher m = TYPE_COMMENT_PATTERN.matcher(text);
if (m.matches()) {
return m.group(1);
}
}
}
return null;
}
示例2: getUncommentedText
import com.intellij.psi.PsiComment; //导入方法依赖的package包/类
@Nullable
private static String getUncommentedText(@NotNull final PsiComment comment) {
final PsiFile psiFile = comment.getContainingFile();
final Language language = psiFile.getViewProvider().getBaseLanguage();
final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(language);
if (commenter != null) {
String text = comment.getText();
final String prefix = commenter.getBlockCommentPrefix();
if (prefix != null && text.startsWith(prefix)) {
text = text.substring(prefix.length());
final String suffix = commenter.getBlockCommentSuffix();
if (suffix != null && text.length() > suffix.length()) {
return text.substring(0, text.length() - suffix.length()).trim();
}
}
}
return null;
}
示例3: satisfiedBy
import com.intellij.psi.PsiComment; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiComment)) {
return false;
}
if (element instanceof PsiDocComment) {
return false;
}
final PsiComment comment = (PsiComment)element;
final IElementType type = comment.getTokenType();
if (!JavaTokenType.END_OF_LINE_COMMENT.equals(type)) {
return false;
}
final String text = comment.getText();
final Matcher matcher = NO_INSPECTION_PATTERN.matcher(text);
return !matcher.matches();
}
示例4: getRangeInElement
import com.intellij.psi.PsiComment; //导入方法依赖的package包/类
@NotNull
@Override
public TextRange getRangeInElement(@NotNull final PsiComment element) {
final String text = element.getText();
if (text.startsWith("//")) return new TextRange(2, element.getTextLength());
final int length = text.length();
if (length > 4 && text.startsWith("/**") && text.endsWith("*/")) return new TextRange(3, element.getTextLength()-2);
if (length > 3 && text.startsWith("/*") && text.endsWith("*/")) return new TextRange(2, element.getTextLength()-2);
if (length > 6 && text.startsWith("<!--") && text.endsWith("-->")) return new TextRange(4, element.getTextLength()-3);
if (text.startsWith("--")) return new TextRange(2, element.getTextLength());
if (text.startsWith("#")) return new TextRange(1, element.getTextLength());
return super.getRangeInElement(element);
}
示例5: getCommentContents
import com.intellij.psi.PsiComment; //导入方法依赖的package包/类
private static String getCommentContents(PsiComment comment) {
final String text = comment.getText();
return text.substring(2);
}