本文整理汇总了Java中com.intellij.psi.PsiElement.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElement.getUserData方法的具体用法?Java PsiElement.getUserData怎么用?Java PsiElement.getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiElement
的用法示例。
在下文中一共展示了PsiElement.getUserData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findJavaUsages
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
static Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> findJavaUsages( PsiElement element, List<PsiElement> javaElems )
{
if( !(element instanceof PsiNamedElement) || javaElems.isEmpty() )
{
return Collections.emptyMap();
}
Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> allUsages = new HashMap<>();
for( PsiElement javaElem : javaElems )
{
if( javaElem == null )
{
continue;
}
List<UsageInfo> usages = findUsages( javaElem, element );
if( !usages.isEmpty() )
{
FeaturePath path = javaElem.getUserData( KEY_FEATURE_PATH );
allUsages.put( new Pair<>( path, javaElem ), usages );
}
}
return allUsages;
}
示例2: getPostRenameCallback
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
@Override
public Runnable getPostRenameCallback(PsiElement psiElement, String s, RefactoringElementListener refactoringElementListener) {
return () -> {
for (PsiElement render : renders) {
StringLiteralExpression element = (StringLiteralExpression) ((ParameterList) render).getParameters()[0];
final PsiElement parent = element.getParent();
String fileName = element.getContents();
if (Objects.equals(parent.getUserData(WITH_EXT), false)) {
if (Objects.equals(fileName.substring(fileName.lastIndexOf('.')), parent.getUserData(OLD_EXT))) {
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
}
}
parent.putUserData(WITH_EXT, null);
parent.putUserData(OLD_EXT, null);
if (parent.getUserData(RELATIVE_PATH) != null) {
fileName = parent.getUserData(RELATIVE_PATH) + fileName;
parent.putUserData(RELATIVE_PATH, null);
}
fileName = element.isSingleQuote() ? "'" + fileName + "'" : "\"" + fileName + "\"";
PsiElement newValue = PhpPsiElementFactory.createFromText(psiElement.getProject(), StringLiteralExpression.class, fileName);
if (newValue != null) {
element.replace(newValue);
}
}
};
}
示例3: getAugments
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public <E extends PsiElement> List<E> getAugments( Module module, PsiElement element, Class<E> cls )
{
// Module is assigned to user-data via ManTypeFinder, which loads the psiClass (element)
Module context = module != null ? module : element.getUserData( ModuleUtil.KEY_MODULE );
if( context == null )
{
return Collections.emptyList();
}
if( DumbService.getInstance( element.getProject() ).isDumb() )
{
// skip processing during index rebuild
return Collections.emptyList();
}
if( !(element instanceof PsiClass) || !element.isValid() || !PsiMethod.class.isAssignableFrom( cls ) )
{
return Collections.emptyList();
}
List<PsiElement> augFeatures = new ArrayList<>();
PsiClass psiClass = (PsiClass)element;
String className = psiClass.getQualifiedName();
if( className == null )
{
return Collections.emptyList();
}
addMethods( className, psiClass, context, augFeatures );
//noinspection unchecked
return (List<E>)augFeatures;
}