本文整理汇总了Java中com.intellij.psi.PsiSubstitutor.EMPTY属性的典型用法代码示例。如果您正苦于以下问题:Java PsiSubstitutor.EMPTY属性的具体用法?Java PsiSubstitutor.EMPTY怎么用?Java PsiSubstitutor.EMPTY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.psi.PsiSubstitutor
的用法示例。
在下文中一共展示了PsiSubstitutor.EMPTY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveThisExpression
@Nullable("null if ref is not actually 'this' reference")
public static GroovyResolveResult[] resolveThisExpression(@NotNull GrReferenceExpression ref) {
GrExpression qualifier = ref.getQualifier();
if (qualifier == null) {
final PsiElement parent = ref.getParent();
if (parent instanceof GrConstructorInvocation) {
return ((GrConstructorInvocation)parent).multiResolve(false);
}
else {
PsiClass aClass = PsiUtil.getContextClass(ref);
if (aClass != null) {
return new GroovyResolveResultImpl[]{new GroovyResolveResultImpl(aClass, null, null, PsiSubstitutor.EMPTY, true, true)};
}
}
}
else if (qualifier instanceof GrReferenceExpression) {
GroovyResolveResult result = ((GrReferenceExpression)qualifier).advancedResolve();
PsiElement resolved = result.getElement();
if (resolved instanceof PsiClass && PsiUtil.hasEnclosingInstanceInScope((PsiClass)resolved, ref, false)) {
return new GroovyResolveResult[]{result};
}
}
return null;
}
示例2: mirrorSubstitutor
@NotNull
private static PsiSubstitutor mirrorSubstitutor(@NotNull PsiClass from, @NotNull final PsiClass to, @NotNull PsiSubstitutor substitutor)
{
Iterator<PsiTypeParameter> baseParams = PsiUtil.typeParametersIterator(to);
Iterator<PsiTypeParameter> candidateParams = PsiUtil.typeParametersIterator(from);
PsiSubstitutor answer = PsiSubstitutor.EMPTY;
while(baseParams.hasNext())
{
// if equivalent classes "from" and "to" have different number of type parameters, then treat "to" as a raw type
if(!candidateParams.hasNext())
{
return JavaClassSupersImpl.createRawSubstitutor(to);
}
answer = answer.put(baseParams.next(), substitutor.substitute(candidateParams.next()));
}
return answer;
}
示例3: getName
private static String getName(final PsiClass psiClass, final LookupElement item, boolean diamond, @NotNull PsiSubstitutor substitutor)
{
String forced = item instanceof JavaPsiClassReferenceElement ? ((JavaPsiClassReferenceElement) item).getForcedPresentableName() : item instanceof PsiTypeLookupItem ? ((PsiTypeLookupItem)
item).getForcedPresentableName() : null;
if(forced != null)
{
return forced;
}
String name = PsiUtilCore.getName(psiClass);
if(diamond)
{
return name + "<>";
}
if(substitutor != PsiSubstitutor.EMPTY)
{
final PsiTypeParameter[] params = psiClass.getTypeParameters();
if(params.length > 0)
{
return name + formatTypeParameters(substitutor, params);
}
}
return StringUtil.notNullize(name);
}
示例4: createImplementationPrototypes
@NotNull
@Override
public PsiMethod[] createImplementationPrototypes(PsiClass inClass, PsiMethod method) throws IncorrectOperationException {
if (!(inClass instanceof GrTypeDefinition && method instanceof GrTraitMethod)) return PsiMethod.EMPTY_ARRAY;
final PsiClass containingClass = method.getContainingClass();
PsiSubstitutor substitutor = inClass.isInheritor(containingClass, true) ? TypeConversionUtil.getSuperClassSubstitutor(containingClass, inClass, PsiSubstitutor.EMPTY)
: PsiSubstitutor.EMPTY;
return new GrMethod[]{GroovyOverrideImplementUtil.generateTraitMethodPrototype((GrTypeDefinition)inClass, (GrTraitMethod)method, substitutor)};
}
示例5: GrMethodCallUsageInfo
public GrMethodCallUsageInfo(PsiElement element, boolean isToChangeArguments, boolean isToCatchExceptions, PsiMethod method) {
super(element);
final GroovyResolveResult resolveResult = resolveMethod(element);
if (resolveResult == null || resolveResult.getElement() == null) {
mySubstitutor = PsiSubstitutor.EMPTY;
}
else if (resolveResult.getElement() instanceof PsiMethod) {
PsiMethod resolved = (PsiMethod)resolveResult.getElement();
mySubstitutor = resolveResult.getSubstitutor();
if (!element.getManager().areElementsEquivalent(method, resolved)) {
final PsiClass baseClass = method.getContainingClass();
final PsiClass derivedClass = resolved.getContainingClass();
if (baseClass != null && derivedClass != null && InheritanceUtil.isInheritorOrSelf(derivedClass, baseClass, true)) {
final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, derivedClass, mySubstitutor);
final MethodSignature superMethodSignature = method.getSignature(superClassSubstitutor);
final MethodSignature methodSignature = resolved.getSignature(PsiSubstitutor.EMPTY);
final PsiSubstitutor superMethodSignatureSubstitutor =
MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature, superMethodSignature);
mySubstitutor = TypesUtil.composeSubstitutors(superMethodSignatureSubstitutor, mySubstitutor);
}
}
}
GrClosureSignature signature = GrClosureSignatureUtil.createSignature(method, mySubstitutor);
myToChangeArguments = isToChangeArguments;
myToCatchExceptions = isToCatchExceptions;
final GrCall call = GroovyRefactoringUtil.getCallExpressionByMethodReference(element);
if (call == null) {
myMapToArguments = GrClosureSignatureUtil.ArgInfo.empty_array();
}
else {
myMapToArguments = GrClosureSignatureUtil.mapParametersToArguments(signature, call.getNamedArguments(), call.getExpressionArguments(),
call.getClosureArguments(), call, false, false);
}
}
示例6: fromQName
@NotNull
private PsiType fromQName(String qName)
{
PsiClass aClass = JavaPsiFacade.getInstance(myNavTarget.getProject()).findClass(qName, myNavTarget.getResolveScope());
if(aClass == null)
{
return fromText(qName);
}
return new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY);
}
示例7: getBuilderSubstitutor
public static PsiSubstitutor getBuilderSubstitutor(@NotNull PsiTypeParameterListOwner classOrMethodToBuild, @NotNull PsiClass innerClass) {
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
if (innerClass.hasModifierProperty(PsiModifier.STATIC)) {
PsiTypeParameter[] typeParameters = classOrMethodToBuild.getTypeParameters();
PsiTypeParameter[] builderParams = innerClass.getTypeParameters();
if (typeParameters.length == builderParams.length) {
for (int i = 0; i < typeParameters.length; i++) {
PsiTypeParameter typeParameter = typeParameters[i];
substitutor = substitutor.put(typeParameter, PsiSubstitutor.EMPTY.substitute(builderParams[i]));
}
}
}
return substitutor;
}
示例8: getSuperClassSubstitutor
@Override
@Nullable
public PsiSubstitutor getSuperClassSubstitutor(@NotNull PsiClass superClass, @NotNull PsiClass derivedClass, @NotNull GlobalSearchScope scope, @NotNull PsiSubstitutor derivedSubstitutor)
{
if(InheritanceImplUtil.hasObjectQualifiedName(superClass))
{
return PsiSubstitutor.EMPTY;
}
return derivedClass instanceof PsiTypeParameter ? processTypeParameter((PsiTypeParameter) derivedClass, scope, superClass, ContainerUtil.<PsiTypeParameter>newTroveSet(),
derivedSubstitutor) : getSuperSubstitutorWithCaching(superClass, derivedClass, scope, derivedSubstitutor);
}
示例9: composeSubstitutors
@NotNull
private static PsiSubstitutor composeSubstitutors(PsiSubstitutor outer, PsiSubstitutor inner, PsiClass onClass)
{
PsiSubstitutor answer = PsiSubstitutor.EMPTY;
Map<PsiTypeParameter, PsiType> outerMap = outer.getSubstitutionMap();
Map<PsiTypeParameter, PsiType> innerMap = inner.getSubstitutionMap();
for(PsiTypeParameter parameter : PsiUtil.typeParametersIterable(onClass))
{
if(outerMap.containsKey(parameter) || innerMap.containsKey(parameter))
{
answer = answer.put(parameter, outer.substitute(inner.substitute(parameter)));
}
}
return answer;
}
示例10: renderClassItem
public static void renderClassItem(LookupElementPresentation presentation,
LookupElement item,
PsiClass psiClass,
boolean diamond,
@NotNull String locationString,
@NotNull PsiSubstitutor substitutor)
{
if(!(psiClass instanceof PsiTypeParameter))
{
presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));
}
boolean strikeout = JavaElementLookupRenderer.isToStrikeout(item);
presentation.setItemText(getName(psiClass, item, diamond, substitutor));
presentation.setStrikeout(strikeout);
String tailText = locationString;
if(item instanceof PsiTypeLookupItem)
{
if(((PsiTypeLookupItem) item).isIndicateAnonymous() && (psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) || ((PsiTypeLookupItem) item)
.isAddArrayInitializer())
{
tailText = "{...}" + tailText;
}
}
if(substitutor == PsiSubstitutor.EMPTY && !diamond && psiClass.getTypeParameters().length > 0)
{
String separator = "," + (showSpaceAfterComma(psiClass) ? " " : "");
tailText = "<" + StringUtil.join(psiClass.getTypeParameters(), PsiTypeParameter::getName, separator) + ">" + tailText;
}
presentation.setTailText(tailText, true);
}
示例11: isApplicable
@Override
protected boolean isApplicable(PsiMethod method, PsiElement place)
{
final PsiExpressionList argumentList = ((PsiMethodCallExpression) place).getArgumentList();
final MethodCandidateInfo candidateInfo = new MethodCandidateInfo(method, PsiSubstitutor.EMPTY, false, false, argumentList, null, argumentList.getExpressionTypes(), null);
PsiSubstitutor substitutorForMethod = candidateInfo.getSubstitutor();
if(PsiUtil.isApplicable(method, substitutorForMethod, argumentList))
{
final PsiType returnType = substitutorForMethod.substitute(method.getReturnType());
final PsiType expectedType = getExpectedType();
return expectedType == null || returnType == null || TypeConversionUtil.isAssignable(expectedType, returnType);
}
return false;
}
示例12: SliceUsage
private SliceUsage(@NotNull PsiElement element, @NotNull SliceAnalysisParams params)
{
super(new UsageInfo(element));
myParent = null;
this.params = params;
mySubstitutor = PsiSubstitutor.EMPTY;
indexNesting = 0;
syntheticField = "";
}
示例13: PsiElementClassMember
protected PsiElementClassMember(@NotNull T psiMember, String text) {
this(psiMember, PsiSubstitutor.EMPTY, text);
}
示例14: PsiMethodMember
public PsiMethodMember(@NotNull PsiMethod method) {
this(method, PsiSubstitutor.EMPTY);
}
示例15: JavaSliceUsage
private JavaSliceUsage(@NotNull PsiElement element, @NotNull SliceAnalysisParams params) {
super(element, params);
mySubstitutor = PsiSubstitutor.EMPTY;
indexNesting = 0;
syntheticField = "";
}