本文整理匯總了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);
}
}
}
}
}
}
};
}