本文整理匯總了Java中com.intellij.psi.PsiField.hasModifierProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiField.hasModifierProperty方法的具體用法?Java PsiField.hasModifierProperty怎麽用?Java PsiField.hasModifierProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiField
的用法示例。
在下文中一共展示了PsiField.hasModifierProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(@NotNull PsiField field) {
super.visitField(field);
if (field instanceof PsiEnumConstant) {
return;
}
if (!field.hasModifierProperty(PsiModifier.STATIC) || !field.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
final String name = field.getName();
if (name == null) {
return;
}
final PsiType type = field.getType();
if (onlyCheckImmutables && !ClassUtils.isImmutable(type)) {
return;
}
if (isValid(name)) {
return;
}
registerFieldError(field, name);
}
示例2: hasGetAndSet
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
private static boolean hasGetAndSet(@NonNull String getPrefix, @NonNull String setPrefix, @NonNull PsiClass cls, @NonNull PsiField field) {
boolean isPublic = field.hasModifierProperty(PsiModifier.PUBLIC);
if (isPublic) return true;
String fieldName = captureName(field.getName());
String getMethodName = getPrefix + fieldName;
String setMethodName = setPrefix + fieldName;
PsiMethod[] gets = cls.findMethodsByName(getMethodName, true);
PsiMethod[] sets = cls.findMethodsByName(setMethodName, true);
boolean hasGet = gets.length > 0;
boolean hasSet = sets.length > 0;
return hasGet && hasSet;
}
示例3: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(PsiField field) {
super.visitField(field);
if (field.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
final PsiClass containingClass = field.getContainingClass();
if (containingClass == null) {
return;
}
if (!InheritanceUtil.isInheritor(containingClass,
CommonClassNames.JAVA_LANG_EXCEPTION)) {
return;
}
registerFieldError(field, field);
}
示例4: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(@NotNull PsiField field) {
super.visitField(field);
if (!field.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
if (!field.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiType type = field.getType();
if (!(type instanceof PsiArrayType)) {
return;
}
if (CollectionUtils.isConstantEmptyArray(field)) {
return;
}
registerFieldError(field);
}
示例5: ifStatementAssignsVolatileVariable
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
private boolean ifStatementAssignsVolatileVariable(
GrIfStatement statement) {
GrStatement innerThen = statement.getThenBranch();
innerThen = ControlFlowUtils.stripBraces(innerThen);
if (!(innerThen instanceof GrAssignmentExpression)) {
return false;
}
final GrAssignmentExpression assignmentExpression =
(GrAssignmentExpression) innerThen;
final GrExpression lhs =
assignmentExpression.getLValue();
if (!(lhs instanceof GrReferenceExpression)) {
return false;
}
final GrReferenceExpression referenceExpression =
(GrReferenceExpression) lhs;
final PsiElement element =
referenceExpression.resolve();
if (!(element instanceof PsiField)) {
return false;
}
final PsiField field = (PsiField) element;
return field.hasModifierProperty(PsiModifier.VOLATILE);
}
示例6: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(@NotNull PsiField field) {
//no call to super, so we don't drill into anonymous classes
if (!field.hasModifierProperty(PsiModifier.STATIC) ||
!field.hasModifierProperty(PsiModifier.PUBLIC) ||
!field.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
final PsiClass containingClass = field.getContainingClass();
if (containingClass == null) {
return;
}
if (containingClass.isInterface() ||
containingClass.isAnnotationType() ||
containingClass.isEnum()) {
return;
}
if (!containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
return;
}
registerFieldError(field);
}
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:ConstantDeclaredInAbstractClassInspection.java
示例7: visitSynchronizedStatement
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitSynchronizedStatement(GrSynchronizedStatement synchronizedStatement) {
super.visitSynchronizedStatement(synchronizedStatement);
final GrExpression lock = synchronizedStatement.getMonitor();
if (lock == null || !(lock instanceof GrReferenceExpression)) {
return;
}
final PsiElement referent = ((PsiReference) lock).resolve();
if (!(referent instanceof PsiField)) {
return;
}
final PsiField field = (PsiField) referent;
if (field.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
registerError(lock);
}
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:GroovySynchronizationOnNonFinalFieldInspection.java
示例8: shouldCheckField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
private boolean shouldCheckField(PsiField field) {
if (isIgnoredType(field.getType())) {
return false;
}
if (field.hasModifierProperty(FINAL)) {
if (field.hasModifierProperty(STATIC)) {
return reportInitializedStaticFinalFields || !hasExpressionElement(field.getChildren());
}
return reportInitializedFinalFields || !hasExpressionElement(field.getChildren());
}
return true;
}
開發者ID:stylismo,項目名稱:nullability-annotations-inspection,代碼行數:13,代碼來源:NullabilityAnnotationsInspection.java
示例9: checkTagValue
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public String checkTagValue(PsiDocTagValue value) {
boolean hasReference = (value != null && value.getFirstChild() != null);
if (hasReference) {
if (!PsiUtil.isLanguageLevel5OrHigher(value)) {
return JavaErrorMessages.message("javadoc.value.tag.jdk15.required");
}
}
if (value != null) {
PsiReference reference = value.getReference();
if (reference != null) {
PsiElement target = reference.resolve();
if (target != null) {
if (!(target instanceof PsiField)) {
return JavaErrorMessages.message("javadoc.value.field.required");
}
PsiField field = (PsiField) target;
if (!field.hasModifierProperty(PsiModifier.STATIC)) {
return JavaErrorMessages.message("javadoc.value.static.field.required");
}
if (field.getInitializer() == null ||
JavaConstantExpressionEvaluator.computeConstantExpression(field.getInitializer(), false) == null) {
return JavaErrorMessages.message("javadoc.value.field.with.initializer.required");
}
}
}
}
return null;
}
示例10: isReadOnlyProperty
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
public static boolean isReadOnlyProperty(PsiField field) {
for (GetterSetterPrototypeProvider provider : Extensions.getExtensions(EP_NAME)) {
if (provider.canGeneratePrototypeFor(field)) {
return provider.isReadOnly(field);
}
}
return field.hasModifierProperty(PsiModifier.FINAL);
}
示例11: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(@NotNull PsiField field) {
if (field.hasModifierProperty(PsiModifier.TRANSIENT) || field.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiClass aClass = field.getContainingClass();
if (aClass == null) {
return;
}
if (ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
return;
}
if (!SerializationUtils.isSerializable(aClass)) {
return;
}
if (SerializationUtils.isProbablySerializable(field.getType())) {
return;
}
final boolean hasWriteObject = SerializationUtils.hasWriteObject(aClass);
if (hasWriteObject) {
return;
}
if (isIgnoredSubclass(aClass)) {
return;
}
if (AnnotationUtil.isAnnotated(field, ignorableAnnotations)) {
return;
}
registerFieldError(field, field);
}
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:NonSerializableFieldInSerializableClassInspectionBase.java
示例12: generateSetter
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
@Nullable
public GroovyGenerationInfo<GrMethod> generateSetter() {
PsiField field = getElement();
if (field.hasModifierProperty(PsiModifier.FINAL)) {
return null;
}
final GrMethod method = createMethodIfNotExists(field, GroovyPropertyUtils.generateSetterPrototype(field));
return method == null ? null : new GroovyGenerationInfo<GrMethod>(method);
}
示例13: visitClass
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitClass(@NotNull PsiClass aClass) {
// no call to super, so it doesn't drill down
if (aClass.isInterface() || aClass.isAnnotationType()) {
return;
}
PsiField badSerialPersistentFields = null;
final PsiField[] fields = aClass.getFields();
for (final PsiField field : fields) {
if (isSerialPersistentFields(field)) {
if (!field.hasModifierProperty(PsiModifier.PRIVATE) ||
!field.hasModifierProperty(PsiModifier.STATIC) ||
!field.hasModifierProperty(PsiModifier.FINAL)) {
badSerialPersistentFields = field;
break;
}
else {
final PsiType type = field.getType();
if (!type.equalsToText("java.io.ObjectStreamField" +
"[]")) {
badSerialPersistentFields = field;
break;
}
}
}
}
if (badSerialPersistentFields == null) {
return;
}
if (!SerializationUtils.isSerializable(aClass)) {
return;
}
registerFieldError(badSerialPersistentFields);
}
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:SerialPersistentFieldsWithWrongSignatureInspection.java
示例14: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(@NotNull PsiField field) {
super.visitField(field);
if (!field.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
if (!field.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiType type = field.getType();
if (!CollectionUtils.isCollectionClassOrInterface(type)) {
return;
}
registerFieldError(field);
}
示例15: visitField
import com.intellij.psi.PsiField; //導入方法依賴的package包/類
@Override
public void visitField(@NotNull PsiField field) {
if (!field.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiType type = field.getType();
if (!CollectionUtils.isCollectionClassOrInterface(type)) {
return;
}
if (!m_ignoreWeakCollections ||
CollectionUtils.isWeakCollectionClass(type)) {
return;
}
registerFieldError(field);
}