本文整理汇总了Java中com.intellij.psi.PsiModifierList.hasModifierProperty方法的典型用法代码示例。如果您正苦于以下问题:Java PsiModifierList.hasModifierProperty方法的具体用法?Java PsiModifierList.hasModifierProperty怎么用?Java PsiModifierList.hasModifierProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiModifierList
的用法示例。
在下文中一共展示了PsiModifierList.hasModifierProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFix
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
final PsiMethod method = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethod.class);
if (method != null) {
final PsiModifierList modifierList = method.getModifierList();
if (!modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
modifierList.setModifierProperty(PsiModifier.PUBLIC, true);
}
if (!modifierList.hasModifierProperty(PsiModifier.STATIC)) {
modifierList.setModifierProperty(PsiModifier.STATIC, true);
}
if (method.getReturnType() != PsiType.VOID) {
ChangeSignatureProcessor csp =
new ChangeSignatureProcessor(project, method, false, PsiModifier.PUBLIC, method.getName(), PsiType.VOID,
new ParameterInfoImpl[0]);
csp.run();
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection.java
示例2: visitAnnotation
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public void visitAnnotation(GrAnnotation annotation) {
super.visitAnnotation(annotation);
PsiElement parent = annotation.getParent().getParent();
if (parent == null || !(parent instanceof GrTypeDefinition)) return;
if (SINGLETON.equals(annotation.getQualifiedName())) {
GrTypeDefinition typeDefinition = (GrTypeDefinition)parent;
PsiMethod[] methods = typeDefinition.getMethods();
for (PsiMethod method : methods) {
if (method.isConstructor()) {
PsiModifierList modifierList = method.getModifierList();
if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
registerClassError(typeDefinition);
}
}
}
}
}
示例3: writeModifiers
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static boolean writeModifiers(StringBuilder builder, PsiModifierList modifierList, String[] modifiers, boolean writeAnnotations) {
boolean wasAddedModifiers = false;
if (writeAnnotations && modifierList instanceof GrModifierList) {
GrAnnotation[] annotations = ((GrModifierList)modifierList).getAnnotations();
AnnotationGenerator annotationGenerator = new AnnotationGenerator(builder, new ExpressionContext(modifierList.getProject(), GroovyFile.EMPTY_ARRAY));
wasAddedModifiers = annotations.length > 0;
for (GrAnnotation annotation : annotations) {
annotation.accept(annotationGenerator);
builder.append(' ');
}
}
for (String modifierType : modifiers) {
if (modifierList.hasModifierProperty(modifierType)) {
builder.append(modifierType);
builder.append(' ');
wasAddedModifiers = true;
}
}
return wasAddedModifiers;
}
示例4: isPublicNullaryConstructor
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
/** Checks if the supplied method is a public constructor with no parameters. */
public static boolean isPublicNullaryConstructor(PsiMethod method) {
if (!method.isConstructor()) {
return false;
}
if (method.getParameterList().getParametersCount() > 0) {
return false;
}
PsiModifierList modifierList = method.getModifierList();
if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
return true;
}
return false;
}
示例5: visitAnnotation
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public void visitAnnotation(GrAnnotation annotation) {
super.visitAnnotation(annotation);
PsiElement parent = annotation.getParent().getParent();
if (parent == null || !(parent instanceof GrTypeDefinition)) return;
if (SINGLETON.equals(annotation.getQualifiedName())) {
GrTypeDefinition typeDefinition = (GrTypeDefinition)parent;
PsiMethod[] methods = typeDefinition.getMethods();
for (PsiMethod method : methods) {
if (method.isConstructor()) {
PsiModifierList modifierList = method.getModifierList();
if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
registerClassError(typeDefinition);
}
}
}
}
}
示例6: getWitherFields
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@NotNull
private Collection<PsiField> getWitherFields(@NotNull PsiClass psiClass) {
Collection<PsiField> witherFields = new ArrayList<PsiField>();
for (PsiField psiField : psiClass.getFields()) {
boolean createWither = true;
PsiModifierList modifierList = psiField.getModifierList();
if (null != modifierList) {
// Skip static fields.
createWither = !modifierList.hasModifierProperty(PsiModifier.STATIC);
// Skip final fields
createWither &= !(modifierList.hasModifierProperty(PsiModifier.FINAL) && psiField.hasInitializer());
// Skip fields that start with $
createWither &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER);
// Skip fields having Wither annotation already
createWither &= !PsiAnnotationSearchUtil.isAnnotatedWith(psiField, Wither.class);
}
if (createWither) {
witherFields.add(psiField);
}
}
return witherFields;
}
示例7: getAllNotInitializedAndNotStaticFields
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@NotNull
@SuppressWarnings("deprecation")
protected Collection<PsiField> getAllNotInitializedAndNotStaticFields(@NotNull PsiClass psiClass) {
Collection<PsiField> allNotInitializedNotStaticFields = new ArrayList<PsiField>();
final boolean classAnnotatedWithValue = PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, Value.class, lombok.experimental.Value.class);
for (PsiField psiField : psiClass.getFields()) {
// skip fields named $
boolean addField = !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER);
final PsiModifierList modifierList = psiField.getModifierList();
if (null != modifierList) {
// skip static fields
addField &= !modifierList.hasModifierProperty(PsiModifier.STATIC);
boolean isFinal = isFieldFinal(psiField, modifierList, classAnnotatedWithValue);
// skip initialized final fields
addField &= (!isFinal || null == psiField.getInitializer());
}
if (addField) {
allNotInitializedNotStaticFields.add(psiField);
}
}
return allNotInitializedNotStaticFields;
}
示例8: compareModifiers
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
private void compareModifiers(PsiModifierList beforeModifierList, PsiModifierList afterModifierList) {
assertNotNull(beforeModifierList);
assertNotNull(afterModifierList);
if (shouldCompareModifiers()) {
for (String modifier : PsiModifier.MODIFIERS) {
boolean haveSameModifiers = afterModifierList.hasModifierProperty(modifier) == beforeModifierList.hasModifierProperty(modifier);
final PsiMethod afterModifierListParent = PsiTreeUtil.getParentOfType(afterModifierList, PsiMethod.class);
assertTrue(modifier + " Modifier is not equal for " + (null == afterModifierListParent ? "..." : afterModifierListParent.getText()), haveSameModifiers);
}
}
if (shouldCompareAnnotations()) {
Collection<String> beforeAnnotations = Lists.newArrayList(Collections2.transform(Arrays.asList(beforeModifierList.getAnnotations()), new QualifiedNameFunction()));
Collection<String> afterAnnotations = Lists.newArrayList(Collections2.transform(Arrays.asList(afterModifierList.getAnnotations()), new QualifiedNameFunction()));
Iterables.removeIf(beforeAnnotations, Predicates.containsPattern("lombok.*"));
assertThat("Annotations are different", beforeAnnotations, equalTo(afterAnnotations));
}
}
示例9: getVisibilityModifier
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@PsiModifier.ModifierConstant
public static String getVisibilityModifier(PsiModifierList list)
{
if(list == null)
{
return PsiModifier.PACKAGE_LOCAL;
}
for(@PsiModifier.ModifierConstant String modifier : visibilityModifiers)
{
if(list.hasModifierProperty(modifier))
{
return modifier;
}
}
return PsiModifier.PACKAGE_LOCAL;
}
示例10: report
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public void report(PsiModifierList list) {
for(String modifier : PsiModifier.MODIFIERS){
if (list.hasExplicitModifier(modifier) || list.hasModifierProperty(modifier)) {
System.out.println(" PsiModifier -> "+modifier);
}
}
}
示例11: hasModifierProperty
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public boolean hasModifierProperty(@NotNull final String name) {
for (PsiModifierList sublist : mySublists) {
if (sublist.hasModifierProperty(name)) return true;
}
return false;
}
示例12: isValidServiceAnnotationDeclaration
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
/**
* Validates whether the variable has {@code @Service} annotation declared correctly.
*
* @param variable variable to check.
* @return Look at {@link ServiceAnnotationDeclarationValidationResult}.
* @since 0.1
*/
@NotNull
public static ServiceAnnotationDeclarationValidationResult isValidServiceAnnotationDeclaration(
@NotNull PsiVariable variable )
{
PsiAnnotation serviceAnnotation = getServiceAnnotation( variable );
if( serviceAnnotation == null )
{
return invalidServiceAnnotationNotDeclared;
}
PsiModifierList modifierList = variable.getModifierList();
if( modifierList != null )
{
if( modifierList.hasModifierProperty( STATIC ) )
{
return invalidDeclaredOnStaticVariable;
}
}
// Can't be type that is injected by @Structure
if( isInjecteableByStructureAnnotation( variable ) )
{
return invalidTypeIsInjectedViaStructureAnnotation;
}
return valid;
}
示例13: checkField
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public final ProblemDescriptor[] checkField( @NotNull PsiField field,
@NotNull InspectionManager manager,
boolean isOnTheFly )
{
PsiAnnotation annotationToCheck = getAnnotationToCheck( field );
if( annotationToCheck == null )
{
return null;
}
PsiModifierList modifierList = field.getModifierList();
if( modifierList != null )
{
if( modifierList.hasModifierProperty( com.intellij.psi.PsiModifier.STATIC ) )
{
String message = getInjectionAnnotationValidDeclarationMessage();
AbstractFix removeAnnotationFix = createRemoveAnnotationFix( annotationToCheck );
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
annotationToCheck, message, removeAnnotationFix, com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING
);
return new ProblemDescriptor[]{ problemDescriptor };
}
}
return verifyAnnotationDeclaredCorrectly( field, annotationToCheck, manager );
}
开发者ID:apache,项目名称:polygene-java,代码行数:29,代码来源:AbstractInjectionAnnotationDeclarationOnFieldInspection.java
示例14: isApiMethod
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
/**
* Returns true is a method is public but not static. Returns false otherwise.
*
* @param psiMethod PsiMethod to be parsed.
* @return Returns true is a method is public but not static. Returns false otherwise.
*/
public static boolean isApiMethod(@NonNls PsiMethod psiMethod) {
PsiModifierList psiModifierList = psiMethod.getModifierList();
if (psiModifierList.hasModifierProperty(PsiModifier.PUBLIC)
&& !psiModifierList.hasModifierProperty(PsiModifier.STATIC)) {
return true;
}
return false;
}
示例15: filterSetterFields
import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@NotNull
private Collection<PsiField> filterSetterFields(@NotNull PsiClass psiClass) {
final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass);
filterToleratedElements(classMethods);
final Collection<PsiField> setterFields = new ArrayList<PsiField>();
for (PsiField psiField : psiClass.getFields()) {
boolean createSetter = true;
PsiModifierList modifierList = psiField.getModifierList();
if (null != modifierList) {
//Skip final fields.
createSetter = !modifierList.hasModifierProperty(PsiModifier.FINAL);
//Skip static fields.
createSetter &= !modifierList.hasModifierProperty(PsiModifier.STATIC);
//Skip fields having Setter annotation already
createSetter &= PsiAnnotationSearchUtil.isNotAnnotatedWith(psiField, fieldProcessor.getSupportedAnnotationClasses());
//Skip fields that start with $
createSetter &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER);
//Skip fields if a method with same name already exists
final Collection<String> methodNames = fieldProcessor.getAllSetterNames(psiField, PsiType.BOOLEAN.equals(psiField.getType()));
for (String methodName : methodNames) {
createSetter &= !PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 1);
}
}
if (createSetter) {
setterFields.add(psiField);
}
}
return setterFields;
}