本文整理汇总了Java中com.intellij.psi.PsiClass.getFields方法的典型用法代码示例。如果您正苦于以下问题:Java PsiClass.getFields方法的具体用法?Java PsiClass.getFields怎么用?Java PsiClass.getFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiClass
的用法示例。
在下文中一共展示了PsiClass.getFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeSrcClass
import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
public SrcClass makeSrcClass( String fqn, PsiClass psiClass, ManModule module )
{
SrcClass srcClass = new SrcClass( fqn, getKind( psiClass ) )
.modifiers( getModifiers( psiClass.getModifierList() ) );
for( PsiTypeParameter typeVar : psiClass.getTypeParameters() )
{
srcClass.addTypeVar( new SrcType( makeTypeVar( typeVar ) ) );
}
setSuperTypes( srcClass, psiClass );
for( PsiMethod psiMethod : psiClass.getMethods() )
{
addMethod( srcClass, psiMethod );
}
for( PsiField psiField : psiClass.getFields() )
{
addField( srcClass, psiField );
}
for( PsiClass psiInnerClass : psiClass.getInnerClasses() )
{
addInnerClass( srcClass, psiInnerClass, module );
}
return srcClass;
}
示例2: buildMethod
import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
@Override
protected String buildMethod(PsiClass psiClass, boolean isOverride, boolean needAll) {
StringBuilder sb = new StringBuilder();
sb.append("public ").append(getMethodType()).append(mMethodName).append("(){");
PsiField[] fields;
if (isOverride && !needAll) {
sb.append(getMethodType()).append(mFieldName).append("=super.").append(mMethodName).append("();");
fields = psiClass.getFields();
} else {
sb.append(getMethodType()).append(mFieldName).append("=new ").append(getParamsType()).append("();");
fields = psiClass.getAllFields();
}
for (PsiField field : fields) {
PsiModifierList modifiers = field.getModifierList();
if (!findIgnore(modifiers)) {
if (findPostFiles(modifiers)) {
sb.append("if (").append(field.getName()).append("!=null&&").append(field.getName()).append(".size()>0){");
sb.append("for (FileInput file : ").append(field.getName()).append(") {");
sb.append(mFieldName).append(".put(file.key + \"\\\"; filename=\\\"\" + file.filename,")
.append(getValueType()).append(".create(").append(getMediaType()).append(".parse(guessMimeType(file.filename)), file.file));}}");
} else if (findPostFile(modifiers)) {
sb.append("if (").append(field.getName()).append("!=null){");
sb.append(mFieldName).append(".put(").append(field.getName()).append(".key + \"\\\"; filename=\\\"\" + ").append(field.getName())
.append(".filename, ").append(getValueType()).append(".create(").append(getMediaType()).append(".parse(guessMimeType(")
.append(field.getName()).append(".filename)),").append(field.getName()).append(".file));}");
} else {
sb.append(mFieldName).append(".put(").append("\"").append(field.getName()).append("\", ").append(getValueType())
.append(".create(").append(getMediaType()).append(".parse(\"text/plain\"), String.valueOf(").append(field.getName()).append(")));");
}
}
}
sb.append("return ").append(mFieldName).append(";}");
return sb.toString();
}
示例3: buildMethod
import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
@Override
protected String buildMethod(PsiClass psiClass, boolean isOverride, boolean needAll) {
StringBuilder sb = new StringBuilder();
sb.append("public ").append(getMethodType()).append(mMethodName).append("(){");
PsiField[] fields;
if (isOverride && !needAll) {
sb.append(getMethodType()).append(mFieldName).append("=super.").append(mMethodName).append("();");
fields = psiClass.getFields();
} else {
sb.append(getMethodType()).append(mFieldName).append("=new ").append(getMethodType()).append("().setType(MultipartBody.FORM);");
fields = psiClass.getAllFields();
}
for (PsiField field : fields) {
PsiModifierList modifiers = field.getModifierList();
if (!findIgnore(modifiers)) {
if (findPostFiles(modifiers)) {
sb.append("if (").append(field.getName()).append("!=null&&").append(field.getName()).append(".size()>0){");
sb.append("for (FileInput file : ").append(field.getName()).append(") {");
sb.append(mFieldName).append(".addFormDataPart(file.key, file.filename, ")
.append(getValueType()).append(".create(").append(getMediaType()).append(".parse(guessMimeType(file.filename)), file.file));}}");
} else if (findPostFile(modifiers)) {
sb.append("if (").append(field.getName()).append("!=null){");
sb.append(mFieldName).append(".addFormDataPart(").append(field.getName()).append(".key,")
.append(field.getName()).append(".filename,").append(getValueType()).append(".create(").append(getMediaType()).append(".parse(guessMimeType(")
.append(field.getName()).append(".filename)),").append(field.getName()).append(".file));}");
} else {
sb.append(mFieldName).append(".addFormDataPart(\"").append(field.getName()).append("\", String.valueOf(").append(field.getName()).append("));");
}
}
}
sb.append("return ").append(mFieldName).append(";}");
return sb.toString();
}
示例4: buildMethod
import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
@Override
protected String buildMethod(PsiClass psiClass, boolean isOverride, boolean needAll) {
StringBuilder sb = new StringBuilder();
sb.append("public ").append(getMethodType()).append(mMethodName).append("(){");
PsiField[] fields;
if (isOverride && !needAll) {
sb.append(getMethodType()).append(mFieldName).append("=super.").append(mMethodName).append("();");
fields = psiClass.getFields();
} else {
sb.append(getMethodType()).append(mFieldName).append("=new ").append(getParamsType()).append("();");
fields = psiClass.getAllFields();
}
for (PsiField field : fields) {
PsiModifierList modifiers = field.getModifierList();
if (!findIgnore(modifiers)) {
if (findPostFiles(modifiers)) {
sb.append("if (").append(field.getName()).append("!=null&&").append(field.getName()).append(".size()>0){");
sb.append("for (FileInput file : ").append(field.getName()).append(") {");
sb.append(mFieldName).append(".add(").append(getValueType()).append(".createFormData(file.key, file.filename, ")
.append(getRequestBody()).append(".create(").append(getMediaType()).append(".parse(guessMimeType(file.filename)), file.file)));}}");
} else if (findPostFile(modifiers)) {
sb.append("if (").append(field.getName()).append("!=null){");
sb.append(mFieldName).append(".add(").append(getValueType()).append(".createFormData(").append(field.getName()).append(".key,")
.append(field.getName()).append(".filename,").append(getRequestBody()).append(".create(").append(getMediaType()).append(".parse(guessMimeType(")
.append(field.getName()).append(".filename)),").append(field.getName()).append(".file)));}");
} else {
sb.append(mFieldName).append(".add(").append(getValueType()).append(".createFormData(\"").append(field.getName()).append("\", String.valueOf(").append(field.getName()).append(")));");
}
}
}
sb.append("return ").append(mFieldName).append(";}");
return sb.toString();
}
示例5: findFeatureElement
import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
private PsiNamedElement findFeatureElement( PsiClass psiClass, FeaturePath child )
{
if( child == null )
{
return psiClass;
}
PsiNamedElement result = null;
switch( child.getFeatureType() )
{
case Class:
{
PsiClass[] innerClasses = psiClass.getInnerClasses();
if( innerClasses.length == child.getCount() )
{
result = findFeatureElement( innerClasses[child.getIndex()], child.getChild() );
}
break;
}
case Method:
{
PsiMethod[] methods = psiClass.getMethods();
if( methods.length == child.getCount() )
{
result = methods[child.getIndex()];
}
break;
}
case Field:
PsiField[] fields = psiClass.getFields();
if( fields.length == child.getCount() )
{
result = fields[child.getIndex()];
}
break;
default:
throw new IllegalStateException( "Unhandled feature type: " + child.getFeatureType() );
}
return result;
}
示例6: findJavaElementsFor
import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
private static List<PsiElement> findJavaElementsFor( PsiClass psiClass, PsiElement element, FeaturePath parent )
{
List<PsiElement> result = new ArrayList<>();
if( isJavaElementFor( psiClass, element ) )
{
result.add( psiClass );
psiClass.putUserData( KEY_FEATURE_PATH, FeaturePath.make( parent, FeaturePath.FeatureType.Class, 0, 1 ) );
}
PsiMethod[] methods = psiClass.getMethods();
for( int i = 0; i < methods.length; i++ )
{
PsiMethod method = methods[i];
if( isJavaElementFor( method, element ) ||
element instanceof PsiClass && isJavaElementForType( method, (PsiClass)element ) )
{
result.add( method );
method.putUserData( KEY_FEATURE_PATH, FeaturePath.make( parent, FeaturePath.FeatureType.Method, i, methods.length ) );
}
}
PsiField[] fields = psiClass.getFields();
for( int i = 0; i < fields.length; i++ )
{
PsiField field = fields[i];
if( isJavaElementFor( field, element ) ||
element instanceof PsiClass && isJavaElementForType( field, (PsiClass)element ) )
{
result.add( field );
field.putUserData( KEY_FEATURE_PATH, FeaturePath.make( parent, FeaturePath.FeatureType.Field, i, fields.length ) );
}
}
PsiClass[] inners = psiClass.getInnerClasses();
for( int i = 0; i < inners.length; i++ )
{
PsiClass inner = inners[i];
if( isJavaElementFor( inner, element ) ||
element instanceof PsiClass && isJavaElementForType( inner, (PsiClass)element ) )
{
result.add( inner );
inner.putUserData( KEY_FEATURE_PATH, FeaturePath.make( parent, FeaturePath.FeatureType.Class, i, inners.length ) );
}
result.addAll( findJavaElementsFor( inner, element, new FeaturePath( parent, FeaturePath.FeatureType.Class, i, inners.length ) ) );
}
return result;
}