本文整理汇总了Java中com.intellij.psi.PsiReference.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java PsiReference.getElement方法的具体用法?Java PsiReference.getElement怎么用?Java PsiReference.getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiReference
的用法示例。
在下文中一共展示了PsiReference.getElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareRenaming
import com.intellij.psi.PsiReference; //导入方法依赖的package包/类
@Override
public void prepareRenaming(PsiElement psiElement, String s, Map<PsiElement, String> map) {
renders.clear();
for (PsiReference reference : findReferences(psiElement)) {
final PsiElement element = reference.getElement();
if (element instanceof StringLiteralExpression) {
String fileName = ((StringLiteralExpression) element).getContents();
if (fileName.contains("/")) {
element.getParent().putUserData(RELATIVE_PATH, fileName.substring(0, fileName.lastIndexOf('/') + 1));
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
}
element.getParent().putUserData(WITH_EXT, fileName.contains("."));
String realFile = ((PsiFile) psiElement).getName();
if (realFile.contains(".")) {
element.getParent().putUserData(OLD_EXT, realFile.substring(realFile.lastIndexOf('.')));
}
renders.add(element.getParent());
}
}
}
示例2: findUsages
import com.intellij.psi.PsiReference; //导入方法依赖的package包/类
private static List<UsageInfo> findUsages( PsiElement element, PsiElement ctx )
{
// Module mod = ModuleUtilCore.findModuleForPsiElement( element );
// if( mod == null )
// {
// return Collections.emptyList();
// }
Query<PsiReference> search = ReferencesSearch.search( element, GlobalSearchScope.moduleScope( ModuleUtilCore.findModuleForPsiElement( ctx ) ) );
List<UsageInfo> usages = new ArrayList<>();
for( PsiReference ref : search.findAll() )
{
MoveRenameUsageInfo usageInfo = new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
ref.getRangeInElement().getEndOffset(), element,
ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) );
usages.add( usageInfo );
}
return usages;
}
示例3: foldRouteReferenceString
import com.intellij.psi.PsiReference; //导入方法依赖的package包/类
@Nullable
private FoldingDescriptor foldRouteReferenceString(PsiReference reference, String value, FoldingGroup group) {
PsiElement element = reference.getElement();
TextRange foldingRange = new TextRange(element.getTextRange().getStartOffset() + 1, element.getTextRange().getEndOffset() - 1);
if (!RouteIndex.hasRoute(element.getProject(), value)) {
return null;
}
Collection<RouteStub> route = RouteIndex.getRoute(element.getProject(), value);
if (route.size() == 0) {
return null;
}
RouteStub routeDef = route.iterator().next();
return new FoldingDescriptor(element.getNode(), foldingRange, group) {
@Nullable
@Override
public String getPlaceholderText() {
if (routeDef.getPath() == null) {
return routeDef.getController() + "::" + routeDef.getMethod();
}
return routeDef.getPath();
}
};
}