本文整理汇总了Java中com.intellij.psi.PsiIdentifier.getText方法的典型用法代码示例。如果您正苦于以下问题:Java PsiIdentifier.getText方法的具体用法?Java PsiIdentifier.getText怎么用?Java PsiIdentifier.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiIdentifier
的用法示例。
在下文中一共展示了PsiIdentifier.getText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tokenize
import com.intellij.psi.PsiIdentifier; //导入方法依赖的package包/类
@Override
public void tokenize(@NotNull T element, TokenConsumer consumer) {
final PsiIdentifier psiIdentifier = PsiTreeUtil.getChildOfType(element, PsiIdentifier.class);
final PsiTypeElement psiType = PsiTreeUtil.getChildOfType(element, PsiTypeElement.class);
if (psiIdentifier == null) {
return;
}
final String identifier = psiIdentifier.getText();
final String type = psiType==null?null:psiType.getText();
if (identifier == null) {
return;
}
if (type == null || !type.equalsIgnoreCase(identifier)) {
myIdentifierTokenizer.tokenize(psiIdentifier, consumer);
}
if (psiType != null) {
myTypeTokenizer.tokenize(psiType, consumer);
}
}
示例2: visitContinueStatement
import com.intellij.psi.PsiIdentifier; //导入方法依赖的package包/类
@Override
public void visitContinueStatement(
@NotNull PsiContinueStatement statement) {
super.visitContinueStatement(statement);
final PsiIdentifier label = statement.getLabelIdentifier();
if (label == null) {
return;
}
final String labelText = label.getText();
if (labelText == null) {
return;
}
if (labelText.length() == 0) {
return;
}
registerStatementError(statement);
}
示例3: visitBreakStatement
import com.intellij.psi.PsiIdentifier; //导入方法依赖的package包/类
@Override
public void visitBreakStatement(@NotNull PsiBreakStatement statement) {
super.visitBreakStatement(statement);
final PsiIdentifier labelIdentifier =
statement.getLabelIdentifier();
if (labelIdentifier == null) {
return;
}
final String labelText = labelIdentifier.getText();
if (labelText == null) {
return;
}
if (labelText.length() == 0) {
return;
}
registerStatementError(statement);
}
示例4: findRouteFromElement
import com.intellij.psi.PsiIdentifier; //导入方法依赖的package包/类
/**
* Returns the Camel route from a PsiElement
*
* @param element the element
* @return the String route or null if there nothing can be found
*/
private String findRouteFromElement(PsiElement element) {
XmlTag xml = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (xml != null) {
return ((XmlTagImpl) element.getParent()).getAttributeValue("uri");
}
if (element instanceof PsiLiteralExpressionImpl) {
return ((PsiLiteralExpressionImpl) element).getValue() == null ? null : ((PsiLiteralExpressionImpl) element).getValue().toString();
}
if (element instanceof PsiIdentifier) {
PsiIdentifier id = (PsiIdentifier) element;
String text = id.getText();
if (text != null) {
return text;
}
}
// Only variables can be resolved?
Optional<PsiVariable> variable = resolvedIdentifier(element)
.filter(PsiVariable.class::isInstance)
.map(PsiVariable.class::cast);
if (variable.isPresent()) {
// Try to resolve variable and recursive search route
return variable.map(PsiVariable::getInitializer)
.map(this::findRouteFromElement)
.orElse(null);
}
return null;
}