本文整理汇总了Java中com.intellij.psi.PsiElement.getText方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElement.getText方法的具体用法?Java PsiElement.getText怎么用?Java PsiElement.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiElement
的用法示例。
在下文中一共展示了PsiElement.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getName
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public static String getName(TSObjectExpr obj) {
//Should be the first element after the open paren
ASTNode node = obj.getNode();
if (node == null) {
return null;
}
ASTNode openParen = node.findChildByType(TSTypes.PAREN_OPEN);
if (openParen == null) {
return null;
}
PsiElement nameNode = openParen.getPsi().getNextSibling();
if (nameNode == null) {
return null;
}
if (nameNode instanceof TSLiteralExpr) {
return ((TSLiteralExpr) nameNode).getName();
}
if (nameNode.getNode().getElementType().equals(TSTypes.ID)) {
return nameNode.getText();
}
return null;
}
示例2: calculateEndOffsetReductor
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
private static int calculateEndOffsetReductor(
@NotNull final PsiElement directive,
final boolean isDefinitivelyClosing
) {
if (!isDefinitivelyClosing) {
final PsiElement directiveWhitespace = directive.getPrevSibling();
if (directiveWhitespace instanceof LeafPsiElement) {
final String directiveWhitespaceText = directiveWhitespace.getText();
final int lastBreakline = directiveWhitespaceText.lastIndexOf('\n');
if (lastBreakline != -1) {
return directiveWhitespaceText.length() - lastBreakline;
}
}
}
return 0;
}
示例3: getArrayValueByHash
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
private String getArrayValueByHash(String hash, ArrayCreationExpression array) {
if (array == null)
return null;
for (ArrayHashElement el: array.getHashElements()) {
PsiElement key = el.getKey();
PsiElement value = el.getValue();
if (key != null && value != null && ClassUtils.removeQuotes(key.getText()).equals(hash)) {
return value.getText();
}
}
return null;
}
示例4: buildVisitor
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpArrayCreationExpression(ArrayCreationExpression expression) {
PsiDirectory dir = expression.getContainingFile().getContainingDirectory();
PhpClass phpClass = ObjectFactoryUtils.findClassByArrayCreation(expression, dir);
if (phpClass != null && !phpClass.getFQN().equals("\\" + phpClass.getName())) { // Avoid System Classes: \Closure, \ArrayAccess
for (ArrayHashElement elem: expression.getHashElements()) {
PsiElement key = elem.getKey();
if (key != null) {
String keyName = (key instanceof ClassConstantReference || key instanceof ConstantReference) ?
ClassUtils.getConstantValue(key) : key.getText();
if (keyName != null) {
keyName = ClassUtils.removeQuotes(keyName);
if (keyName != null
&& !keyName.equals("class")
&& !keyName.startsWith("as ")
&& !keyName.startsWith("on ")
&& ClassUtils.findWritableField(phpClass, keyName) == null) {
final String descriptionTemplate = "Field '" + keyName + "' not exists in referenced class " + phpClass.getFQN();
problemsHolder.registerProblem(elem, descriptionTemplate);
}
}
}
}
}
super.visitPhpArrayCreationExpression(expression);
}
};
}
示例5: getReferencesByElement
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
List<PsiReference> psiReferences = new ArrayList<>();
final Collection<PhpClassMember> members = new THashSet<>();
String origValue = element.getText();
String value = StringUtil.unquoteString(element.getText());
Matcher matcher = Pattern.compile(PhpRegex.Xml.CLASS_MEMBER_NAME).matcher(value);
if (!matcher.find()) {
return PsiReference.EMPTY_ARRAY;
}
String elementName = matcher.group(1);
String classFQN = value.substring(0, value.lastIndexOf("::"));
PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
for (final PhpClass phpClass : phpIndex.getAnyByFQN(classFQN)) {
members.addAll(phpClass.getFields());
members.addAll(phpClass.getMethods());
members.removeIf(c -> !c.getName().equals(elementName));
}
if (members.size() > 0) {
TextRange range = new TextRange(
origValue.indexOf(elementName),
origValue.indexOf(elementName) + elementName.length()
);
psiReferences.add(new PolyVariantReferenceBase(element, range, members));
}
return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
示例6: isR2Expression
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
private static boolean isR2Expression(PsiElement node) {
if (node.getParent() == null) {
return false;
}
String text = node.getText();
PsiElement parent = LintUtils.skipParentheses(node.getParent());
return (text.equals(R2) || text.contains(".R2"))
&& parent instanceof PsiExpression
&& endsWithAny(parent.getText(), SUPPORTED_TYPES);
}
示例7: parseChildren
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public String parseChildren(PsiElement element) {
PsiElement[] children = element.getChildren();
String childrenInfo = "";
childrenInfo = ">>>[";
for (PsiElement child : children) {
childrenInfo += (child.getText() + ":" + child.getClass().getSimpleName() + ", ");
}
childrenInfo += (childrenInfo.isEmpty() ? "]<<<" : "\n]<<<");
return childrenInfo;
}
示例8: getElementNamespace
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public static String getElementNamespace(PsiElement element) {
if (element.getNode().getElementType().equals(TSTypes.ID)) {
return element.getText();
}
//TODO???
return null;
}
示例9: invoke
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
String text = "{{ url(\"theme://" + element.getText() + "\") }}";
PsiElement psiElement = TwigElementFactory.createPsiElement(project, text, TwigElementTypes.PRINT_BLOCK);
if (psiElement != null)
element.replace(psiElement);
}
示例10: TemplateDefinitionReference
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public TemplateDefinitionReference(PsiElement element, TextRange textRange) {
super(element, textRange);
this.templateName = element.getText();
}
示例11: getName
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public String getName() {
PsiElement nameElement = getNameIdentifier();
return nameElement == null ? "" : nameElement.getText();
}
示例12: getNodeText
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@NotNull
@Override
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
return element.getText();
}
示例13: getName
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public String getName() {
PsiElement nameElement = getNameElement();
return nameElement == null ? "" : nameElement.getText();
}
示例14: ParameterDefinitionReference
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public ParameterDefinitionReference(PsiElement element, TextRange textRange) {
super(element, textRange);
this.parameterName = element.getText();
}
示例15: parseParent
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public String parseParent(PsiElement element) {
PsiElement parentInfo = element.getParent();
return parentInfo != null
? (">>>\n" + parentInfo.getText() + "\n<<<:" + parentInfo.getClass().getSimpleName())
: "null:null";
}