本文整理汇总了Java中com.intellij.psi.PsiElement.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElement.isValid方法的具体用法?Java PsiElement.isValid怎么用?Java PsiElement.isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiElement
的用法示例。
在下文中一共展示了PsiElement.isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findProject
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public static Project findProject(PsiElement element) {
PsiFile containingFile = element.getContainingFile();
if (containingFile == null) {
if (!element.isValid()) {
return null;
}
} else if (!containingFile.isValid()) {
return null;
}
return (containingFile == null ? element : containingFile).getProject();
}
示例2: processQuery
import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public void processQuery(
@NotNull final ReferencesSearch.SearchParameters queryParameters,
@NotNull final Processor<PsiReference> consumer
) {
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (!elementToSearch.isValid()) {
return;
}
final SearchScope scope = queryParameters.getEffectiveSearchScope();
if (!(scope instanceof GlobalSearchScope)) {
return;
}
// search macros usage references
if (isMacroUsage(elementToSearch) || isMacroNameDeclaration(elementToSearch)) {
final PsiFile file = elementToSearch.getContainingFile();
final PsiElement[] results = PsiTreeUtil.collectElements(
file,
element -> isMacroUsage(element) && element.textMatches(elementToSearch)
);
stream(results)
.map(ImpexMacrosReferenceBase::new)
.forEach(consumer::process);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:28,代码来源:ImpexReferenceSearcher.java
示例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;
}