本文整理匯總了Java中com.intellij.psi.PsiField.getModifierList方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiField.getModifierList方法的具體用法?Java PsiField.getModifierList怎麽用?Java PsiField.getModifierList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiField
的用法示例。
在下文中一共展示了PsiField.getModifierList方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildMethod
import com.intellij.psi.PsiField; //導入方法依賴的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();
}
示例2: buildMethod
import com.intellij.psi.PsiField; //導入方法依賴的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();
}
示例3: buildMethod
import com.intellij.psi.PsiField; //導入方法依賴的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();
}
示例4: markLeakSuspects
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
private void markLeakSuspects(PsiElement element, PsiElement lambdaBody, @NonNull final JavaContext context) {
if (element instanceof PsiReferenceExpression) {
PsiReferenceExpression ref = (PsiReferenceExpression) element;
if (ref.getQualifierExpression() == null) {
PsiElement res = ref.resolve();
if (!(res instanceof PsiParameter)) {
if (!(res instanceof PsiClass)) {
boolean error = false;
if (res instanceof PsiLocalVariable) {
PsiLocalVariable lVar = (PsiLocalVariable) res;
if (!isParent(lambdaBody, lVar.getParent())) {
error = true;
}
}
if (res instanceof PsiField) {
PsiField field = (PsiField) res;
final PsiModifierList modifierList = field.getModifierList();
if (modifierList == null) {
error = true;
} else if (!modifierList.hasExplicitModifier(PsiModifier.STATIC)) {
error = true;
}
}
if (error) {
context.report(ISSUE, element, context.getNameLocation(element), "Possible leak");
}
}
}
}
}
for (PsiElement psiElement : element.getChildren()) {
markLeakSuspects(psiElement, lambdaBody, context);
}
}
示例5: hasAnnotation
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
private static boolean hasAnnotation(PsiField field) {
PsiModifierList modifiers = field.getModifierList();
if (modifiers == null) {
return false;
}
return modifiers.findAnnotation(JSR_330_INJECT_ANNOTATION) != null
|| modifiers.findAnnotation(GUICE_INJECT_ANNOTATION) != null;
}