当前位置: 首页>>代码示例>>Java>>正文


Java PsiElementFactory.createTypeByFQClassName方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiElementFactory.createTypeByFQClassName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElementFactory.createTypeByFQClassName方法的具体用法?Java PsiElementFactory.createTypeByFQClassName怎么用?Java PsiElementFactory.createTypeByFQClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiElementFactory的用法示例。


在下文中一共展示了PsiElementFactory.createTypeByFQClassName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isGetByStringOrByObjectMethod

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@SuppressWarnings("HardCodedStringLiteral")
public static boolean isGetByStringOrByObjectMethod(@NotNull PsiMethod method)
{
	String methodName = method.getName();
	if(!"get".equals(methodName))
	{
		return false;
	}
	PsiParameterList parameterList = method.getParameterList();
	if(parameterList.getParametersCount() != 1)
	{
		return false;
	}
	PsiParameter parameter = parameterList.getParameters()[0];
	final PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
	PsiClassType javaLangString = factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_STRING, method.getResolveScope());
	if(parameter.getType().isAssignableFrom(javaLangString))
	{
		return true;
	}
	PsiClassType javaLangObject = factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_OBJECT, method.getResolveScope());
	return parameter.getType().isAssignableFrom(javaLangObject);
}
 
开发者ID:consulo,项目名称:consulo-apache-velocity,代码行数:24,代码来源:VelocityNamingUtil.java

示例2: getGenericCollectionClassType

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@NotNull
public static PsiClassType getGenericCollectionClassType(@NotNull PsiType psiType, @NotNull Project project, @NotNull String qualifiedName) {
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
  final GlobalSearchScope globalsearchscope = GlobalSearchScope.allScope(project);

  PsiClass genericClass = facade.findClass(qualifiedName, globalsearchscope);
  if (null != genericClass) {
    PsiSubstitutor genericSubstitutor = PsiSubstitutor.EMPTY.putAll(genericClass, new PsiType[]{psiType});
    return elementFactory.createType(genericClass, genericSubstitutor);
  }
  return elementFactory.createTypeByFQClassName(qualifiedName, globalsearchscope);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:14,代码来源:PsiTypeUtil.java

示例3: processClass

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
protected void processClass(@NotNull PsiClass psiClass) {
  final PsiElementFactory factory = JavaPsiFacade.getElementFactory(psiClass.getProject());
  final PsiClassType stringClassType = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_STRING, psiClass.getResolveScope());

  final PsiMethod toStringMethod = findPublicNonStaticMethod(psiClass, "toString", stringClassType);
  if (null != toStringMethod) {
    toStringMethod.delete();
  }
  addAnnotation(psiClass, ToString.class);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:11,代码来源:LombokToStringHandler.java

示例4: getCollectionClassType

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@NotNull
public static PsiClassType getCollectionClassType(@NotNull PsiClassType psiType, @NotNull Project project, @NotNull String qualifiedName) {
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
  final GlobalSearchScope globalsearchscope = GlobalSearchScope.allScope(project);

  PsiClass genericClass = facade.findClass(qualifiedName, globalsearchscope);
  if (null != genericClass) {
    final PsiClassType.ClassResolveResult classResolveResult = psiType.resolveGenerics();
    final PsiSubstitutor derivedSubstitutor = classResolveResult.getSubstitutor();

    final List<PsiType> typeList = new ArrayList<PsiType>(2);
    final Map<String, PsiType> nameTypeMap = new HashMap<String, PsiType>();
    for (Map.Entry<PsiTypeParameter, PsiType> entry : derivedSubstitutor.getSubstitutionMap().entrySet()) {
      final PsiType entryValue = entry.getValue();
      if (null != entryValue) {
        nameTypeMap.put(entry.getKey().getName(), entryValue);
        typeList.add(entryValue);
      }
    }

    PsiSubstitutor genericSubstitutor = PsiSubstitutor.EMPTY;
    final PsiTypeParameter[] typeParameters = genericClass.getTypeParameters();
    for (int i = 0; i < typeParameters.length; i++) {
      final PsiTypeParameter psiTypeParameter = typeParameters[i];
      PsiType mappedType = nameTypeMap.get(psiTypeParameter.getName());
      if (null == mappedType && typeList.size() > i) {
        mappedType = typeList.get(i);
      }
      if (null == mappedType) {
        mappedType = PsiType.getJavaLangObject(PsiManager.getInstance(project), globalsearchscope);
      }

      if (mappedType instanceof PsiWildcardType) {
        mappedType = ((PsiWildcardType) mappedType).getBound();
      }
      genericSubstitutor = genericSubstitutor.put(psiTypeParameter, mappedType);
    }
    return elementFactory.createType(genericClass, genericSubstitutor);
  }
  return elementFactory.createTypeByFQClassName(qualifiedName, globalsearchscope);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:43,代码来源:PsiTypeUtil.java

示例5: getParcelClassType

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@NotNull
private PsiClassType getParcelClassType(@NotNull PsiClass psiClass) {
  PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject());
  return elementFactory.createTypeByFQClassName("android.os.Parcel");
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:6,代码来源:ParcelableMethodsProcessor.java

示例6: extractTypeFromIterable

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@Nullable
private static PsiType extractTypeFromIterable(VtlExpression expr)
{
	if(expr == null)
	{
		return null;
	}
	PsiType type = expr.getPsiType();
	if(type == null)
	{
		return null;
	}
	if(type instanceof PsiArrayType)
	{
		return ((PsiArrayType) type).getComponentType();
	}
	if(!(type instanceof PsiClassType))
	{
		return null;
	}
	PsiClassType classType = (PsiClassType) type;
	PsiElementFactory factory = JavaPsiFacade.getInstance(expr.getProject()).getElementFactory();
	GlobalSearchScope scope = expr.getResolveScope();

	for(Object[] iterable : VELOCITY_ITERABLES)
	{
		PsiClassType iterableClassType = factory.createTypeByFQClassName((String) iterable[0], scope);
		if(!TypeConversionUtil.isAssignable(iterableClassType, classType))
		{
			continue;
		}
		final PsiClass iterableClass = iterableClassType.resolve();
		if(iterableClass == null)
		{
			continue;
		}
		final PsiSubstitutor substitutor = PsiUtil.getSuperClassSubstitutor(iterableClass, classType);
		PsiTypeParameter[] paremeters = iterableClass.getTypeParameters();
		int paramIndex = ((Integer) iterable[1]).intValue();
		PsiType result = paramIndex < paremeters.length ? substitutor.substitute(paremeters[paramIndex]) : null;
		return result != null ? result : factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_OBJECT, scope);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-apache-velocity,代码行数:45,代码来源:VtlLoopVariable.java

示例7: getPropertyAccessorMatchLevel

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@SuppressWarnings("HardCodedStringLiteral")
private PropertyAccessorMatchLevel getPropertyAccessorMatchLevel(PsiMethod method)
{
	String propertyName;
	String methodName = method.getName();
	if(mySetterNeeded)
	{
		if(!isPropertySetter(method))
		{
			return PropertyAccessorMatchLevel.NotAccessor;
		}
		propertyName = methodName.substring("set".length());
	}
	else
	{
		if(myReferenceNameWithoutFirstChar != null && "get".equals(methodName))
		{
			PsiParameterList parameterList = method.getParameterList();
			if(parameterList.getParametersCount() != 1)
			{
				return PropertyAccessorMatchLevel.NotAccessor;
			}
			PsiParameter parameter = parameterList.getParameters()[0];
			final PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
			PsiClassType javaLangObject = factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_OBJECT, method.getResolveScope());
			if(parameter.getType().isAssignableFrom(javaLangObject))
			{
				return PropertyAccessorMatchLevel.GetByObjectMethod;
			}
			PsiClassType javaLangString = factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_STRING, method.getResolveScope());
			if(parameter.getType().isAssignableFrom(javaLangString))
			{
				return PropertyAccessorMatchLevel.GetByStringMethod;
			}
			return PropertyAccessorMatchLevel.NotAccessor;
		}
		if(!isPropertyGetter(method))
		{
			return PropertyAccessorMatchLevel.NotAccessor;
		}
		int prefixLength = methodName.startsWith("get") ? "get".length() : "is".length();
		propertyName = methodName.substring(prefixLength);
	}

	if(myReferenceNameWithoutFirstChar != null && myReferenceNameWithoutFirstChar.equals(propertyName.substring(1)))
	{
		if(myReferenceNameFirstChar == propertyName.charAt(0))
		{
			return PropertyAccessorMatchLevel.ExactNameMatch;
		}
		else if(toLowerCase(myReferenceNameFirstChar) == toLowerCase(propertyName.charAt(0)))
		{
			return PropertyAccessorMatchLevel.OnlyFirstCharCaseMismatch;
		}
	}
	return PropertyAccessorMatchLevel.NameMismatch;
}
 
开发者ID:consulo,项目名称:consulo-apache-velocity,代码行数:58,代码来源:VelocityStylePropertyResolveHelper.java


注:本文中的com.intellij.psi.PsiElementFactory.createTypeByFQClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。