本文整理汇总了Java中com.intellij.xml.util.XmlUtil.getCommentText方法的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil.getCommentText方法的具体用法?Java XmlUtil.getCommentText怎么用?Java XmlUtil.getCommentText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.xml.util.XmlUtil
的用法示例。
在下文中一共展示了XmlUtil.getCommentText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseDocComment
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static void parseDocComment(XmlTag tag, AttributeDefinition def, @Nullable String styleable) {
PsiElement comment = XmlDocumentationProvider.findPreviousComment(tag);
if (comment != null) {
String docValue = XmlUtil.getCommentText((XmlComment)comment);
if (docValue != null && !StringUtil.isEmpty(docValue)) {
def.addDocValue(docValue, styleable);
}
}
}
示例2: parseAndAddValues
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private void parseAndAddValues(AttributeDefinition def, XmlTag[] values) {
for (XmlTag value : values) {
final String valueName = value.getAttributeValue(ATTR_NAME);
if (valueName == null) {
LOG.info("Unknown value for tag: " + value.getText());
}
else {
def.addValue(valueName);
PsiElement comment = XmlDocumentationProvider.findPreviousComment(value);
if (comment != null) {
String docValue = XmlUtil.getCommentText((XmlComment)comment);
if (!StringUtil.isEmpty(docValue)) {
def.addValueDoc(valueName, docValue);
}
}
final String strIntValue = value.getAttributeValue(ATTR_VALUE);
if (strIntValue != null) {
try {
// Integer.decode cannot handle "ffffffff", see JDK issue 6624867
int intValue = (int) (long) Long.decode(strIntValue);
Map<String, Integer> value2Int = myEnumMap.get(def.getName());
if (value2Int == null) {
value2Int = new HashMap<String, Integer>();
myEnumMap.put(def.getName(), value2Int);
}
value2Int.put(valueName, intValue);
}
catch (NumberFormatException ignored) {
}
}
}
}
}
示例3: isSuppressedAt
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static boolean isSuppressedAt(PsiElement anchor, LocalInspectionTool tool) {
if (anchor == null) return false;
PsiElement prevSibling;
if (!(anchor instanceof XmlComment)) {
prevSibling = anchor.getPrevSibling();
while (prevSibling instanceof PsiWhiteSpace || prevSibling instanceof XmlText) {
prevSibling = prevSibling.getPrevSibling();
}
} else {
prevSibling = anchor;
}
if (prevSibling instanceof XmlProlog) {
if (prevSibling.getTextLength() > 0 && !"\n".equals(prevSibling.getText())) {
return isSuppressedAt(prevSibling.getLastChild(), tool);
} else {
return isSuppressedAt(prevSibling, tool);
}
}
if (prevSibling instanceof XmlComment) {
final XmlComment comment = (XmlComment)prevSibling;
final String text = XmlUtil.getCommentText(comment);
if (text != null) {
final Matcher matcher = SUPPRESSION_PATTERN.matcher(text);
if (matcher.matches()) {
final String[] strings = matcher.group(1).split(",");
final String toolId = tool.getID();
for (String s : strings) {
if (s.trim().equals(toolId) || ALL_ID.equals(s.trim())) return true;
}
}
}
}
return false;
}
示例4: invoke
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
final XmlTag anchor = getAnchor(element);
if (anchor == null) return;
PsiElement prevSibling = anchor.getPrevSibling();
while (prevSibling instanceof PsiWhiteSpace || prevSibling instanceof XmlText) {
prevSibling = prevSibling.getPrevSibling();
}
if (prevSibling instanceof XmlProlog) {
prevSibling = prevSibling.getLastChild();
if (prevSibling != null && !(prevSibling instanceof XmlComment)) {
prevSibling = PsiTreeUtil.getPrevSiblingOfType(prevSibling, XmlComment.class);
}
}
if (prevSibling instanceof XmlComment) {
final XmlComment comment = (XmlComment)prevSibling;
final String text = XmlUtil.getCommentText(comment);
if (text != null && InspectionUtil.SUPPRESSION_PATTERN.matcher(text).matches()) {
final String s = text.trim() + ", " + myToolId;
final XmlComment newComment = createComment(project, s);
CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(comment.replace(newComment));
} else {
addNoinspectionComment(project, anchor);
}
} else {
addNoinspectionComment(project, anchor);
}
}
示例5: generateDoc
import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Nullable
public String generateDoc(PsiElement psiElement, PsiElement psiElement1) {
if (psiElement instanceof DocElement) {
final DocElement element = (DocElement)psiElement;
return getDocumentation(element.getName(), element.getCategory());
}
if (psiElement instanceof XsltElement) {
final XmlTag t = ((XsltElement)psiElement).getTag();
PsiElement p = t.getPrevSibling();
while (p instanceof PsiWhiteSpace || p instanceof XmlText) {
p = p.getPrevSibling();
}
if (p instanceof XmlComment) {
final String commentText = XmlUtil.getCommentText((XmlComment)p);
return commentText != null ? commentText.replaceAll("&", "&").replaceAll("<", "<") : null;
} else {
return null;
}
}
final String name = getTagName(psiElement);
if (name != null) {
return getDocumentation(name, "element");
} else if (psiElement instanceof XPathFunction) {
return getDocumentation(((XPathFunction)psiElement).getName(), "function");
}
return null;
}