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


Java PsiSubstitutorImpl.createSubstitutor方法代碼示例

本文整理匯總了Java中com.intellij.psi.impl.PsiSubstitutorImpl.createSubstitutor方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiSubstitutorImpl.createSubstitutor方法的具體用法?Java PsiSubstitutorImpl.createSubstitutor怎麽用?Java PsiSubstitutorImpl.createSubstitutor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.impl.PsiSubstitutorImpl的用法示例。


在下文中一共展示了PsiSubstitutorImpl.createSubstitutor方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calcType

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@Override
protected PsiClassType calcType() {
  final PsiElement classElement = myClass.getElement();
  if (!(classElement instanceof PsiClass)) return null;
  Map<PsiTypeParameter, PsiType> resurrected = new HashMap<PsiTypeParameter, PsiType>();
  final Set<Map.Entry<SmartPsiElementPointer, SmartTypePointer>> set = myMap.entrySet();
  for (Map.Entry<SmartPsiElementPointer, SmartTypePointer> entry : set) {
    PsiElement element = entry.getKey().getElement();
    if (element instanceof PsiTypeParameter) {
      SmartTypePointer typePointer = entry.getValue();
      resurrected.put((PsiTypeParameter)element, typePointer == null ? null : typePointer.getType());
    }
  }
  for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable((PsiClass)classElement)) {
    if (!resurrected.containsKey(typeParameter)) {
      resurrected.put(typeParameter, null);
    }
  }
  final PsiSubstitutor resurrectedSubstitutor = PsiSubstitutorImpl.createSubstitutor(resurrected);
  return new PsiImmediateClassType((PsiClass)classElement, resurrectedSubstitutor);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:SmartTypePointerManagerImpl.java

示例2: findRawMethodSignatures

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@NotNull
public static MultiMap<MethodSignature, PsiMethod> findRawMethodSignatures(@NotNull PsiMethod[] methods, @NotNull PsiClass clazz) {
  Map<PsiTypeParameter, PsiType> initialMap = ContainerUtil.newHashMap();

  for (PsiTypeParameter parameter : clazz.getTypeParameters()) {
    initialMap.put(parameter, null);
  }

  final PsiSubstitutor initialSubstitutor = PsiSubstitutorImpl.createSubstitutor(initialMap);

  MultiMap<MethodSignature, PsiMethod> result = new MultiMap<MethodSignature, PsiMethod>();
  for (PsiMethod method : methods) {
    final PsiMethod actual = method instanceof GrReflectedMethod ? ((GrReflectedMethod)method).getBaseMethod() : method;

    PsiSubstitutor substitutor = calcRawSubstitutor(initialMap, initialSubstitutor, actual);
    result.putValue(method.getSignature(substitutor), actual);
  }

  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:GrClosureSignatureUtil.java

示例3: removeRawMappingsLeftFromResolve

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@NotNull
private static PsiSubstitutor removeRawMappingsLeftFromResolve(@NotNull PsiSubstitutor substitutor)
{
	Map<PsiTypeParameter, PsiType> map = null;
	for(Map.Entry<PsiTypeParameter, PsiType> entry : substitutor.getSubstitutionMap().entrySet())
	{
		if(entry.getValue() == null)
		{
			if(map == null)
			{
				map = new THashMap<PsiTypeParameter, PsiType>();
			}
			map.put(entry.getKey(), entry.getValue());
		}
	}
	if(map == null)
	{
		return substitutor;
	}
	Map<PsiTypeParameter, PsiType> newMap = new THashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
	newMap.keySet().removeAll(map.keySet());
	return PsiSubstitutorImpl.createSubstitutor(newMap);
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:24,代碼來源:SliceUtil.java

示例4: composeIfNotAssignable

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
private static PsiSubstitutor composeIfNotAssignable(PsiSubstitutor actual, PsiSubstitutor required)
{
	if(actual == PsiSubstitutor.EMPTY)
	{
		return required;
	}
	if(required == PsiSubstitutor.EMPTY)
	{
		return actual;
	}
	PsiSubstitutor result = PsiSubstitutorImpl.createSubstitutor(actual.getSubstitutionMap());
	for(Map.Entry<PsiTypeParameter, PsiType> e : required.getSubstitutionMap().entrySet())
	{
		final PsiTypeParameter typeParameter = e.getKey();
		final PsiType requiredType = e.getValue();
		final PsiType actualType = result.getSubstitutionMap().get(typeParameter);
		if(requiredType != null && (actualType == null || !TypeConversionUtil.isAssignable(actualType, requiredType)))
		{
			result = result.put(typeParameter, requiredType);
		}
	}
	return result;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:24,代碼來源:TypeMigrationStatementProcessor.java

示例5: advancedResolveImpl

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
private JavaResolveResult advancedResolveImpl(@NotNull PsiFile containingFile) {
  PsiTypeElement[] typeElements = myRefParameterList == null ? PsiTypeElement.EMPTY_ARRAY : myRefParameterList.getTypeParameterElements();
  PsiElement resolve = resolveElement(containingFile);
  if (resolve == null) return null;
  if (resolve instanceof PsiClass) {
    Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<PsiTypeParameter, PsiType>();
    int index = 0;
    for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable((PsiClass)resolve)) {
      if (index >= typeElements.length) {
        PsiTypeParameterListOwner parameterOwner = parameter.getOwner();
        if (parameterOwner == resolve) {
          substitutionMap.put(parameter, null);
        }
        else if (parameterOwner instanceof PsiClass) {
          PsiElement containingClass = myParent;
          while ((containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class, true)) != null) {
            PsiSubstitutor superClassSubstitutor =
              TypeConversionUtil.getClassSubstitutor((PsiClass)parameterOwner, (PsiClass)containingClass, PsiSubstitutor.EMPTY);
            if (superClassSubstitutor != null) {
              substitutionMap.put(parameter, superClassSubstitutor.substitute(parameter));
              break;
            }
          }
        }
      }
      else {
        substitutionMap.put(parameter, typeElements[index].getType());
      }
      index++;
    }
    collectOuterClassTypeArgs((PsiClass)resolve, myCanonicalText, substitutionMap);
    return new CandidateInfo(resolve, PsiSubstitutorImpl.createSubstitutor(substitutionMap));
  }
  else {
    return new CandidateInfo(resolve, PsiSubstitutor.EMPTY);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:38,代碼來源:ClsJavaCodeReferenceElementImpl.java

示例6: removeRawMappingsLeftFromResolve

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@NotNull
private static PsiSubstitutor removeRawMappingsLeftFromResolve(@NotNull PsiSubstitutor substitutor) {
  Map<PsiTypeParameter, PsiType> map = null;
  for (Map.Entry<PsiTypeParameter, PsiType> entry : substitutor.getSubstitutionMap().entrySet()) {
    if (entry.getValue() == null) {
      if (map == null) map = new THashMap<PsiTypeParameter, PsiType>();
      map.put(entry.getKey(), entry.getValue());
    }
  }
  if (map == null) return substitutor;
  Map<PsiTypeParameter, PsiType> newMap = new THashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
  newMap.keySet().removeAll(map.keySet());
  return PsiSubstitutorImpl.createSubstitutor(newMap);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:SliceUtil.java

示例7: calcRawSubstitutor

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@NotNull
private static PsiSubstitutor calcRawSubstitutor(@NotNull Map<PsiTypeParameter, PsiType> initialMap,
                                                 @NotNull PsiSubstitutor initialSubstitutor,
                                                 @NotNull PsiMethod actual) {
  if (actual.hasTypeParameters()) {
    final HashMap<PsiTypeParameter, PsiType> map1 = ContainerUtil.newHashMap(initialMap);
    for (PsiTypeParameter parameter : actual.getTypeParameters()) {
      map1.put(parameter, null);
    }
    return PsiSubstitutorImpl.createSubstitutor(map1);
  }
  else {
    return initialSubstitutor;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:GrClosureSignatureUtil.java

示例8: advancedResolveImpl

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
private JavaResolveResult advancedResolveImpl() {
  PsiTypeElement[] typeElements = myRefParameterList == null ? PsiTypeElement.EMPTY_ARRAY : myRefParameterList.getTypeParameterElements();
  PsiElement resolve = resolveElement();

  if (resolve instanceof PsiClass) {
    Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<PsiTypeParameter, PsiType>();
    int index = 0;
    for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable((PsiClass)resolve)) {
      if (index >= typeElements.length) {
        PsiTypeParameterListOwner parameterOwner = parameter.getOwner();
        if (parameterOwner == resolve) {
          substitutionMap.put(parameter, null);
        }
        else if (parameterOwner instanceof PsiClass) {
          PsiElement containingClass = myParent;
          while ((containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class, true)) != null) {
            PsiSubstitutor superClassSubstitutor =
              TypeConversionUtil.getClassSubstitutor((PsiClass)parameterOwner, (PsiClass)containingClass, PsiSubstitutor.EMPTY);
            if (superClassSubstitutor != null) {
              substitutionMap.put(parameter, superClassSubstitutor.substitute(parameter));
              break;
            }
          }
        }
      }
      else {
        substitutionMap.put(parameter, typeElements[index].getType());
      }
      index++;
    }
    return new CandidateInfo(resolve, PsiSubstitutorImpl.createSubstitutor(substitutionMap));
  }
  else {
    return new CandidateInfo(resolve, PsiSubstitutor.EMPTY);
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:37,代碼來源:ClsJavaCodeReferenceElementImpl.java

示例9: removeRawMappingsLeftFromResolve

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@NotNull
private static PsiSubstitutor removeRawMappingsLeftFromResolve(@NotNull PsiSubstitutor substitutor) {
  Map<PsiTypeParameter, PsiType> map = null;
  for (Map.Entry<PsiTypeParameter, PsiType> entry : substitutor.getSubstitutionMap().entrySet()) {
    if (entry.getValue() == null) {
      if (map == null) map = new THashMap<PsiTypeParameter, PsiType>();
      map.put(entry.getKey(), entry.getValue());
    }
  }
  if (map == null) return substitutor;
  Map<PsiTypeParameter, PsiType> newmap = new THashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
  newmap.keySet().removeAll(map.keySet());
  return PsiSubstitutorImpl.createSubstitutor(newmap);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:15,代碼來源:SliceUtil.java

示例10: calcType

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
@Override
protected PsiClassType calcType()
{
	final PsiElement classElement = myClass.getElement();
	if(!(classElement instanceof PsiClass))
	{
		return null;
	}
	Map<PsiTypeParameter, PsiType> resurrected = new HashMap<PsiTypeParameter, PsiType>();
	final Set<Map.Entry<SmartPsiElementPointer, SmartTypePointer>> set = myMap.entrySet();
	for(Map.Entry<SmartPsiElementPointer, SmartTypePointer> entry : set)
	{
		PsiElement element = entry.getKey().getElement();
		if(element instanceof PsiTypeParameter)
		{
			SmartTypePointer typePointer = entry.getValue();
			resurrected.put((PsiTypeParameter) element, typePointer == null ? null : typePointer.getType());
		}
	}
	for(PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable((PsiClass) classElement))
	{
		if(!resurrected.containsKey(typeParameter))
		{
			resurrected.put(typeParameter, null);
		}
	}
	final PsiSubstitutor resurrectedSubstitutor = PsiSubstitutorImpl.createSubstitutor(resurrected);
	return new PsiImmediateClassType((PsiClass) classElement, resurrectedSubstitutor);
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:30,代碼來源:SmartTypePointerManagerImpl.java

示例11: advancedResolveImpl

import com.intellij.psi.impl.PsiSubstitutorImpl; //導入方法依賴的package包/類
private JavaResolveResult advancedResolveImpl(@NotNull PsiFile containingFile)
{
	PsiTypeElement[] typeElements = myRefParameterList == null ? PsiTypeElement.EMPTY_ARRAY : myRefParameterList.getTypeParameterElements();
	PsiElement resolve = resolveElement(containingFile);
	if(resolve == null)
	{
		return null;
	}
	if(resolve instanceof PsiClass)
	{
		Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<>();
		int index = 0;
		for(PsiTypeParameter parameter : PsiUtil.typeParametersIterable((PsiClass) resolve))
		{
			if(index >= typeElements.length)
			{
				PsiTypeParameterListOwner parameterOwner = parameter.getOwner();
				if(parameterOwner == resolve)
				{
					substitutionMap.put(parameter, null);
				}
				else if(parameterOwner instanceof PsiClass)
				{
					PsiElement containingClass = myParent;
					while((containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class, true)) != null)
					{
						PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getClassSubstitutor((PsiClass) parameterOwner, (PsiClass) containingClass, PsiSubstitutor.EMPTY);
						if(superClassSubstitutor != null)
						{
							substitutionMap.put(parameter, superClassSubstitutor.substitute(parameter));
							break;
						}
					}
				}
			}
			else
			{
				substitutionMap.put(parameter, typeElements[index].getType());
			}
			index++;
		}
		collectOuterClassTypeArgs((PsiClass) resolve, myCanonicalText, substitutionMap);
		return new CandidateInfo(resolve, PsiSubstitutorImpl.createSubstitutor(substitutionMap));
	}
	else
	{
		return new CandidateInfo(resolve, PsiSubstitutor.EMPTY);
	}
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:50,代碼來源:ClsJavaCodeReferenceElementImpl.java


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