本文整理汇总了Java中com.intellij.psi.PsiElement.findElementAt方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElement.findElementAt方法的具体用法?Java PsiElement.findElementAt怎么用?Java PsiElement.findElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiElement
的用法示例。
在下文中一共展示了PsiElement.findElementAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findElementAtOffset
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
public static PsiElement findElementAtOffset(@NotNull PsiFile file, int offset) {
final List<PsiFile> psiRoots = file.getViewProvider().getAllFiles();
for (PsiElement root : psiRoots) {
final PsiElement elementAt = root.findElementAt(offset);
if (elementAt != null) {
return elementAt;
}
}
return null;
}
示例2: findByLineAndColumn
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
private static PsiElement findByLineAndColumn(@NotNull final PsiElement file, final int line, final int column) {
final String fullText = file.getText();
int offset = StringUtil.lineColToOffset(fullText, line, column);
if (offset < 0) {
offset = StringUtil.lineColToOffset(fullText, line, 0);
}
return file.findElementAt(offset);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:11,代码来源:ValidateContextImpl.java
示例3: buildVisitor
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpMethodReference(MethodReference reference) {
if (!ViewsUtil.isValidRenderMethod(reference)) {
return;
}
if (ArrayUtil.contains(reference.getName(), ViewsUtil.renderMethods)) {
if (reference.getParameters().length > 0) {
PsiElement pathParameter = reference.getParameters()[0];
if (pathParameter instanceof StringLiteralExpression) {
String path = ((StringLiteralExpression) pathParameter).getContents();
if (path.startsWith("//") || path.startsWith("@")) {
return;
}
PhpClass clazz = ClassUtils.getPhpClassByCallChain(reference);
if (clazz != null) {
Method method = clazz.findMethodByName("getViewPath");
PhpIndex phpIndex = PhpIndex.getInstance(reference.getProject());
if (method != null) {
PhpClass containingClass = method.getContainingClass();
PhpClass controllerBaseClass = ClassUtils.getClass(phpIndex, "yii\\base\\Controller");
PhpClass widgetBaseClass = ClassUtils.getClass(phpIndex, "yii\\base\\Widget");
if (containingClass != controllerBaseClass && containingClass != widgetBaseClass) {
return;
}
}
}
PsiFile file = ViewsUtil.getViewFile(pathParameter);
if (file == null || !file.isValid()) {
final String errorViewNotFoundTemplate = "View file for \"%name%\" not found.";
final MissedViewLocalQuickFix quickFix = new MissedViewLocalQuickFix(path);
final String descriptionTemplate = errorViewNotFoundTemplate.replace("%name%", path);
final PsiElement stringPart = pathParameter.findElementAt(1);
if (stringPart != null) {
problemsHolder.registerProblem(stringPart, descriptionTemplate, quickFix);
}
}
}
}
}
}
};
}