當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiReference.getElement方法代碼示例

本文整理匯總了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());
        }
    }
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:23,代碼來源:RenameViewProcessor.java

示例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;
  }
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:20,代碼來源:RenameResourceElementProcessor.java

示例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();
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:29,代碼來源:RouteFoldingBuilder.java


注:本文中的com.intellij.psi.PsiReference.getElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。