org.sonar.plugins.java.api.tree.Modifier Java Examples

The following examples show how to use org.sonar.plugins.java.api.tree.Modifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BadConstantNameCheck.java    From vjtools with Apache License 2.0 5 votes vote down vote up
private static boolean isStaticFinal(VariableTree variableTree) {
	boolean isStatic = false;
	boolean isFinal = false;
	for (ModifierKeywordTree modifierKeywordTree : variableTree.modifiers().modifiers()) {
		Modifier modifier = modifierKeywordTree.modifier();
		if (modifier == Modifier.STATIC) {
			isStatic = true;
		}
		if (modifier == Modifier.FINAL) {
			isFinal = true;
		}
	}
	return isStatic && isFinal;
}
 
Example #2
Source File: BadConstantNameCheck.java    From vjtools with Apache License 2.0 5 votes vote down vote up
private static boolean isStaticFinal(VariableTree variableTree) {
	boolean isStatic = false;
	boolean isFinal = false;
	for (ModifierKeywordTree modifierKeywordTree : variableTree.modifiers().modifiers()) {
		Modifier modifier = modifierKeywordTree.modifier();
		if (modifier == Modifier.STATIC) {
			isStatic = true;
		}
		if (modifier == Modifier.FINAL) {
			isFinal = true;
		}
	}
	return isStatic && isFinal;
}
 
Example #3
Source File: SynchronizedKeywordUsageCheck.java    From AEM-Rules-for-SonarQube with Apache License 2.0 5 votes vote down vote up
@Override
public void visitMethod(MethodTree tree) {
    List<ModifierKeywordTree> modifiers = tree.modifiers().modifiers();
    for (ModifierKeywordTree modifier : modifiers) {
        if (modifier.modifier() == Modifier.SYNCHRONIZED) {
            visitor.reportIssue(modifier, MESSAGE);
        }
    }
    super.visitMethod(tree);
}
 
Example #4
Source File: UnusedMethodParameterCheck.java    From vjtools with Apache License 2.0 4 votes vote down vote up
private static boolean isPrivateMethod(MethodTree methodTree) {
	return ModifiersUtils.hasModifier(methodTree.modifiers(), Modifier.PRIVATE);
}
 
Example #5
Source File: UnusedPrivateFieldCheck.java    From vjtools with Apache License 2.0 4 votes vote down vote up
private void checkIfNativeMethod(MethodTree method) {
	if (ModifiersUtils.hasModifier(method.modifiers(), Modifier.NATIVE)) {
		hasNativeMethod = true;
	}
}
 
Example #6
Source File: UnusedMethodParameterCheck.java    From vjtools with Apache License 2.0 4 votes vote down vote up
private static boolean isPrivateMethod(MethodTree methodTree) {
	return ModifiersUtils.hasModifier(methodTree.modifiers(), Modifier.PRIVATE);
}
 
Example #7
Source File: UnusedPrivateFieldCheck.java    From vjtools with Apache License 2.0 4 votes vote down vote up
private void checkIfNativeMethod(MethodTree method) {
	if (ModifiersUtils.hasModifier(method.modifiers(), Modifier.NATIVE)) {
		hasNativeMethod = true;
	}
}