本文整理汇总了Java中com.intellij.psi.xml.XmlToken.getText方法的典型用法代码示例。如果您正苦于以下问题:Java XmlToken.getText方法的具体用法?Java XmlToken.getText怎么用?Java XmlToken.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlToken
的用法示例。
在下文中一共展示了XmlToken.getText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerProblemStart
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
private static void registerProblemStart(@NotNull final AnnotationHolder holder,
@NotNull final XmlTag tag,
@NotNull final XmlToken start,
@NotNull final XmlToken end) {
PsiElement context = tag.getContainingFile().getContext();
if (context != null) {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
if (parserDefinition != null) {
ASTNode contextNode = context.getNode();
if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
// TODO: we should check for concatenations here
return;
}
}
}
final String tagName = tag.getName();
final String endTokenText = end.getText();
final RenameTagBeginOrEndIntentionAction renameEndAction = new RenameTagBeginOrEndIntentionAction(tagName, endTokenText, false);
final RenameTagBeginOrEndIntentionAction renameStartAction = new RenameTagBeginOrEndIntentionAction(endTokenText, tagName, true);
final Annotation annotation = holder.createErrorAnnotation(start, XmlErrorMessages.message("tag.has.wrong.closing.tag.name"));
annotation.registerFix(renameEndAction);
annotation.registerFix(renameStartAction);
}
示例2: registerProblemEnd
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
private static void registerProblemEnd(@NotNull final AnnotationHolder holder,
@NotNull final XmlTag tag,
@NotNull final XmlToken end) {
PsiElement context = tag.getContainingFile().getContext();
if (context != null) {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
if (parserDefinition != null) {
ASTNode contextNode = context.getNode();
if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
// TODO: we should check for concatenations here
return;
}
}
}
final String tagName = tag.getName();
final String endTokenText = end.getText();
final RenameTagBeginOrEndIntentionAction renameEndAction = new RenameTagBeginOrEndIntentionAction(tagName, endTokenText, false);
final RenameTagBeginOrEndIntentionAction renameStartAction = new RenameTagBeginOrEndIntentionAction(endTokenText, tagName, true);
final Annotation annotation = holder.createErrorAnnotation(end, XmlErrorMessages.message("wrong.closing.tag.name"));
annotation.registerFix(new RemoveExtraClosingTagIntentionAction());
annotation.registerFix(renameEndAction);
annotation.registerFix(renameStartAction);
}
示例3: handleContentChange
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Override
public XmlToken handleContentChange(@NotNull XmlToken xmlToken, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
String oldText = xmlToken.getText();
String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset());
IElementType tokenType = xmlToken.getTokenType();
FileElement holder = DummyHolderFactory.createHolder(xmlToken.getManager(), null).getTreeElement();
LeafElement leaf = ASTFactory.leaf(tokenType, holder.getCharTable().intern(newText));
holder.rawAddChildren(leaf);
return (XmlToken)xmlToken.replace(leaf.getPsi());
}
示例4: handleContentChange
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
public XmlToken handleContentChange(XmlToken xmlToken, TextRange range, String newContent) throws IncorrectOperationException {
String oldText = xmlToken.getText();
String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset());
IElementType tokenType = xmlToken.getTokenType();
FileElement holder = DummyHolderFactory.createHolder(xmlToken.getManager(), null).getTreeElement();
LeafElement leaf = ASTFactory.leaf(tokenType, holder.getCharTable().intern(newText));
holder.rawAddChildren(leaf);
return (XmlToken)xmlToken.replace(leaf.getPsi());
}
示例5: getReferencesByElement
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!(element instanceof XmlAttributeValue) && !(element instanceof XmlToken)) {
return PsiReference.EMPTY_ARRAY;
}
final String text;
if (element instanceof XmlAttributeValue) {
final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue) element;
text = xmlAttributeValue.getValue();
} else {
final XmlToken token = (XmlToken) element;
text = token.getText();
}
if (text == null || text.isEmpty() || text.charAt(0) != '%') {
return PsiReference.EMPTY_ARRAY;
}
final String name = text.substring(1);
final PsiFile file = element.getContainingFile();
final PsiDirectory dir = file.getParent();
if (dir == null) {
return PsiReference.EMPTY_ARRAY;
}
if (file.getVirtualFile() == null) {
return PsiReference.EMPTY_ARRAY;
}
final String namePrefix = file.getVirtualFile().getNameWithoutExtension();
final PropertiesFile pf = getPropertiesFile(dir.findFile(namePrefix + ".properties"));
if (pf == null) {
return PsiReference.EMPTY_ARRAY;
}
final IProperty property = pf.findPropertyByKey(name);
if (property == null) {
return PsiReference.EMPTY_ARRAY;
}
return new PsiReference[]{new PsiReferenceBase.Immediate<PsiElement>(element, property.getPsiElement())};
}
开发者ID:VladRassokhin,项目名称:eclipse-from-idea-development,代码行数:40,代码来源:PluginXmlPropertiesReferenceProvider.java