当前位置: 首页>>代码示例>>Java>>正文


Java PsiElement.getText方法代码示例

本文整理汇总了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;
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:23,代码来源:TSPsiImplUtil.java

示例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;
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:20,代码来源:BladeFoldingBuilder.java

示例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;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:14,代码来源:MissedParamQuickFix.java

示例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);
        }
    };
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:35,代码来源:ObjectFactoryMissedFieldInspection.java

示例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()]);
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:34,代码来源:PhpClassMemberReferenceProvider.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:InvalidR2UsageDetector.java

示例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;
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:11,代码来源:PsiClassStructureDetector.java

示例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;
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:9,代码来源:TSUtil.java

示例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);
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:8,代码来源:ConvertTwigResource.java

示例10: TemplateDefinitionReference

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public TemplateDefinitionReference(PsiElement element, TextRange textRange) {
  super(element, textRange);
  this.templateName = element.getText();
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:5,代码来源:TemplateDefinitionReference.java

示例11: getName

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public String getName() {
    PsiElement nameElement = getNameIdentifier();
    return nameElement == null ? "" : nameElement.getText();
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:6,代码来源:PsiTypeNameImpl.java

示例12: getNodeText

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@NotNull
@Override
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
    return element.getText();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:6,代码来源:TSFindUsagesProvider.java

示例13: getName

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public String getName() {
    PsiElement nameElement = getNameElement();
    return nameElement == null ? "" : nameElement.getText();
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:6,代码来源:PsiTagPropertyImpl.java

示例14: ParameterDefinitionReference

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public ParameterDefinitionReference(PsiElement element, TextRange textRange) {
  super(element, textRange);

  this.parameterName = element.getText();
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:6,代码来源:ParameterDefinitionReference.java

示例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";
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:7,代码来源:PsiClassStructureDetector.java


注:本文中的com.intellij.psi.PsiElement.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。