本文整理汇总了Java中com.intellij.psi.util.PropertyUtil.isSimplePropertySetter方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtil.isSimplePropertySetter方法的具体用法?Java PropertyUtil.isSimplePropertySetter怎么用?Java PropertyUtil.isSimplePropertySetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PropertyUtil
的用法示例。
在下文中一共展示了PropertyUtil.isSimplePropertySetter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExpressionAccess
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public Access getExpressionAccess(final PsiElement expression) {
if (!(expression instanceof PsiExpression)) return Access.Read;
PsiExpression expr = (PsiExpression) expression;
boolean readAccess = PsiUtil.isAccessedForReading(expr);
boolean writeAccess = PsiUtil.isAccessedForWriting(expr);
if (!writeAccess && expr instanceof PsiReferenceExpression) {
//when searching usages of fields, should show all found setters as a "only write usage"
PsiElement actualReferee = ((PsiReferenceExpression) expr).resolve();
if (actualReferee instanceof PsiMethod && PropertyUtil.isSimplePropertySetter((PsiMethod)actualReferee)) {
writeAccess = true;
readAccess = false;
}
}
if (writeAccess && readAccess) return Access.ReadWrite;
return writeAccess ? Access.Write : Access.Read;
}
示例2: addSettersAndListeners
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static void addSettersAndListeners(CompletionResultSet result, PsiClass containingClass) {
// see PyJavaType.init() in Jython source code for matching logic
for (PsiMethod method : containingClass.getAllMethods()) {
final Project project = containingClass.getProject();
if (PropertyUtil.isSimplePropertySetter(method)) {
final String propName = PropertyUtil.getPropertyName(method);
result.addElement(PyUtil.createNamedParameterLookup(propName, project));
}
else if (method.getName().startsWith("add") && method.getName().endsWith("Listener") && PsiType.VOID.equals(method.getReturnType())) {
final PsiParameter[] parameters = method.getParameterList().getParameters();
if (parameters.length == 1) {
final PsiType type = parameters[0].getType();
if (type instanceof PsiClassType) {
final PsiClass parameterClass = ((PsiClassType)type).resolve();
if (parameterClass != null) {
result.addElement(PyUtil.createNamedParameterLookup(StringUtil.decapitalize(parameterClass.getName()), project));
for (PsiMethod parameterMethod : parameterClass.getMethods()) {
result.addElement(PyUtil.createNamedParameterLookup(parameterMethod.getName(), project));
}
}
}
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PyConstructorArgumentCompletionContributor.java
示例3: isPropertyDeprecated
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public boolean isPropertyDeprecated(final Module module, final Class aClass, final String propertyName) {
// TODO[yole]: correct module-dependent caching
Set<String> deprecated = myClass2DeprecatedProperties.get(aClass.getName());
if (deprecated == null) {
deprecated = new HashSet<String>();
PsiClass componentClass =
JavaPsiFacade.getInstance(module.getProject()).findClass(aClass.getName(), module.getModuleWithDependenciesAndLibrariesScope(true));
if (componentClass != null) {
PsiMethod[] methods = componentClass.getAllMethods();
for(PsiMethod method: methods) {
if (method.isDeprecated() && PropertyUtil.isSimplePropertySetter(method)) {
deprecated.add(PropertyUtil.getPropertyNameBySetter(method));
}
}
}
myClass2DeprecatedProperties.put(aClass.getName(), deprecated);
}
return deprecated.contains(propertyName);
}
示例4: handleElementRename
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
final PsiElement resolved = resolve();
if (resolved instanceof PsiMethod) {
final PsiMethod method = (PsiMethod) resolved;
final String oldName = getElement().getName();
if (!method.getName().equals(oldName)) { //was property reference to accessor
if (PropertyUtil.isSimplePropertySetter(method)) {
final String newPropertyName = PropertyUtil.getPropertyName(newElementName);
if (newPropertyName != null) {
newElementName = newPropertyName;
}
}
}
}
return super.handleElementRename(newElementName);
}
示例5: isSimplePropertyAccessor
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSimplePropertyAccessor(PsiMethod method) {
PsiCodeBlock body = method.getBody();
if (body == null) return false;
PsiStatement[] statements = body.getStatements();
if (statements.length == 0) return false;
PsiStatement statement = statements[0];
if (PropertyUtil.isSimplePropertyGetter(method)) {
if (statement instanceof PsiReturnStatement) {
return ((PsiReturnStatement)statement).getReturnValue() instanceof PsiReferenceExpression;
}
}
else if (PropertyUtil.isSimplePropertySetter(method)) {
if (statements.length > 1 && !(statements[1] instanceof PsiReturnStatement)) return false;
if (statement instanceof PsiExpressionStatement) {
PsiExpression expr = ((PsiExpressionStatement)statement).getExpression();
if (expr instanceof PsiAssignmentExpression) {
PsiExpression lhs = ((PsiAssignmentExpression)expr).getLExpression();
PsiExpression rhs = ((PsiAssignmentExpression)expr).getRExpression();
return lhs instanceof PsiReferenceExpression && rhs instanceof PsiReferenceExpression && !((PsiReferenceExpression)rhs).isQualified();
}
}
}
return false;
}
示例6: isPropertyDeprecated
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public boolean isPropertyDeprecated(final Module module, final Class aClass, final String propertyName)
{
// TODO[yole]: correct module-dependent caching
Set<String> deprecated = myClass2DeprecatedProperties.get(aClass.getName());
if(deprecated == null)
{
deprecated = new HashSet<>();
PsiClass componentClass = JavaPsiFacade.getInstance(module.getProject()).findClass(aClass.getName(), module.getModuleWithDependenciesAndLibrariesScope(true));
if(componentClass != null)
{
PsiMethod[] methods = componentClass.getAllMethods();
for(PsiMethod method : methods)
{
if(method.isDeprecated() && PropertyUtil.isSimplePropertySetter(method))
{
deprecated.add(PropertyUtil.getPropertyNameBySetter(method));
}
}
}
myClass2DeprecatedProperties.put(aClass.getName(), deprecated);
}
return deprecated.contains(propertyName);
}
示例7: isSimplePropertyAccessor
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSimplePropertyAccessor(PsiMethod method) {
if (DumbService.isDumb(method.getProject())) return false;
PsiCodeBlock body = method.getBody();
if (body == null || body.getLBrace() == null || body.getRBrace() == null) return false;
PsiStatement[] statements = body.getStatements();
if (statements.length == 0) return false;
PsiStatement statement = statements[0];
if (PropertyUtil.isSimplePropertyGetter(method)) {
if (statement instanceof PsiReturnStatement) {
return ((PsiReturnStatement)statement).getReturnValue() instanceof PsiReferenceExpression;
}
return false;
}
// builder-style setter?
if (statements.length > 1 && !(statements[1] instanceof PsiReturnStatement)) return false;
// any setter?
if (statement instanceof PsiExpressionStatement) {
PsiExpression expr = ((PsiExpressionStatement)statement).getExpression();
if (expr instanceof PsiAssignmentExpression) {
PsiExpression lhs = ((PsiAssignmentExpression)expr).getLExpression();
PsiExpression rhs = ((PsiAssignmentExpression)expr).getRExpression();
return lhs instanceof PsiReferenceExpression &&
rhs instanceof PsiReferenceExpression &&
!((PsiReferenceExpression)rhs).isQualified() &&
PropertyUtil.isSimplePropertySetter(method); // last check because it can perform long return type resolve
}
}
return false;
}
示例8: checkElement
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity,
@NotNull AnalysisScope scope,
@NotNull InspectionManager manager,
@NotNull GlobalInspectionContext globalContext,
@NotNull ProblemDescriptionsProcessor processor) {
if (refEntity instanceof RefMethod) {
final RefMethod refMethod = (RefMethod)refEntity;
if (refMethod.isConstructor()) return null;
if (!refMethod.getSuperMethods().isEmpty()) return null;
if (refMethod.getInReferences().size() == 0) return null;
if (!refMethod.isReturnValueUsed()) {
final PsiMethod psiMethod = (PsiMethod)refMethod.getElement();
if (IGNORE_BUILDER_PATTERN && PropertyUtil.isSimplePropertySetter(psiMethod)) return null;
final boolean isNative = psiMethod.hasModifierProperty(PsiModifier.NATIVE);
if (refMethod.isExternalOverride() && !isNative) return null;
return new ProblemDescriptor[]{manager.createProblemDescriptor(psiMethod.getNavigationElement(),
InspectionsBundle
.message("inspection.unused.return.value.problem.descriptor"),
!isNative ? getFix(processor) : null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false)};
}
}
return null;
}
示例9: parseProperties
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private void parseProperties(PsiMethod method, JavaElementArrangementEntry entry) {
String propertyName = null;
boolean getter = true;
if (PropertyUtil.isSimplePropertyGetter(method)) {
entry.addModifier(GETTER);
propertyName = PropertyUtil.getPropertyNameByGetter(method);
}
else if (PropertyUtil.isSimplePropertySetter(method)) {
entry.addModifier(SETTER);
propertyName = PropertyUtil.getPropertyNameBySetter(method);
getter = false;
}
if (!myGroupingRules.contains(StdArrangementTokens.Grouping.GETTERS_AND_SETTERS) || propertyName == null) {
return;
}
PsiClass containingClass = method.getContainingClass();
String className = null;
if (containingClass != null) {
className = containingClass.getQualifiedName();
}
if (className == null) {
className = NULL_CONTENT;
}
if (getter) {
myInfo.registerGetter(propertyName, className, entry);
}
else {
myInfo.registerSetter(propertyName, className, entry);
}
}
示例10: getSetter
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
public PsiMethod getSetter() {
if (PropertyUtil.isSimplePropertySetter(myMethod)) {
return myMethod;
}
return PropertyUtil.findPropertySetter(myMethod.getContainingClass(), getName(), false, true);
}
示例11: visitParameter
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitParameter(@NotNull PsiParameter variable) {
super.visitParameter(variable);
final PsiElement declarationScope = variable.getDeclarationScope();
if (!(declarationScope instanceof PsiMethod)) {
return;
}
final PsiMethod method = (PsiMethod)declarationScope;
if (m_ignoreForConstructors && method.isConstructor()) {
return;
}
if (m_ignoreForAbstractMethods) {
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null && containingClass.isInterface()) {
return;
}
}
if (m_ignoreForPropertySetters) {
final String methodName = method.getName();
if (methodName.startsWith(HardcodedMethodConstants.SET) && PsiType.VOID.equals(method.getReturnType())) {
return;
}
if (PropertyUtil.isSimplePropertySetter(method)) {
return;
}
}
final PsiClass aClass = checkFieldName(variable, method);
if (aClass == null) {
return;
}
registerVariableError(variable, aClass);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ParameterHidingMemberVariableInspectionBase.java
示例12: getAdditionalUseScope
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
PsiClass containingClass = null;
if (element instanceof PsiField) {
containingClass = ((PsiField)element).getContainingClass();
}
else if (element instanceof PsiParameter) {
final PsiElement declarationScope = ((PsiParameter)element).getDeclarationScope();
if (declarationScope instanceof PsiMethod && PropertyUtil.isSimplePropertySetter((PsiMethod)declarationScope)) {
containingClass = ((PsiMethod)declarationScope).getContainingClass();
}
}
if (containingClass != null) {
if (element instanceof PsiField &&
!((PsiField)element).hasModifierProperty(PsiModifier.PUBLIC) &&
AnnotationUtil.isAnnotated((PsiField)element, JavaFxCommonClassNames.JAVAFX_FXML_ANNOTATION, false) || element instanceof PsiParameter) {
final Project project = element.getProject();
final String qualifiedName = containingClass.getQualifiedName();
if (qualifiedName != null && !JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName).isEmpty()) {
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
return new DelegatingGlobalSearchScope(projectScope){
@Override
public boolean contains(@NotNull VirtualFile file) {
return super.contains(file) && JavaFxFileTypeFactory.isFxml(file);
}
};
}
}
}
return null;
}
示例13: parseProperties
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private void parseProperties(PsiMethod method, JavaElementArrangementEntry entry) {
if (!myGroupingRules.contains(StdArrangementTokens.Grouping.GETTERS_AND_SETTERS)) {
return;
}
String propertyName = null;
boolean getter = true;
if (PropertyUtil.isSimplePropertyGetter(method)) {
propertyName = PropertyUtil.getPropertyNameByGetter(method);
}
else if (PropertyUtil.isSimplePropertySetter(method)) {
propertyName = PropertyUtil.getPropertyNameBySetter(method);
getter = false;
}
if (propertyName == null) {
return;
}
PsiClass containingClass = method.getContainingClass();
String className = null;
if (containingClass != null) {
className = containingClass.getQualifiedName();
}
if (className == null) {
className = NULL_CONTENT;
}
if (getter) {
myInfo.registerGetter(propertyName, className, entry);
}
else {
myInfo.registerSetter(propertyName, className, entry);
}
}
示例14: getAdditionalUseScope
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
PsiClass containingClass = null;
if (element instanceof PsiField) {
containingClass = ((PsiField)element).getContainingClass();
}
else if (element instanceof PsiParameter) {
final PsiElement declarationScope = ((PsiParameter)element).getDeclarationScope();
if (declarationScope instanceof PsiMethod && PropertyUtil.isSimplePropertySetter((PsiMethod)declarationScope)) {
containingClass = ((PsiMethod)declarationScope).getContainingClass();
}
}
if (containingClass != null) {
if (element instanceof PsiField && ((PsiField)element).hasModifierProperty(PsiModifier.PRIVATE) || element instanceof PsiParameter) {
final Project project = element.getProject();
final String qualifiedName = containingClass.getQualifiedName();
if (qualifiedName != null && !JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName).isEmpty()) {
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
return new DelegatingGlobalSearchScope(projectScope){
@Override
public boolean contains(VirtualFile file) {
return super.contains(file) && JavaFxFileTypeFactory.isFxml(file);
}
};
}
}
}
return null;
}
示例15: checkElement
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(RefEntity refEntity,
AnalysisScope scope,
InspectionManager manager,
GlobalInspectionContext globalContext,
ProblemDescriptionsProcessor processor) {
if (refEntity instanceof RefMethod) {
final RefMethod refMethod = (RefMethod)refEntity;
if (refMethod.isConstructor()) return null;
if (!refMethod.getSuperMethods().isEmpty()) return null;
if (refMethod.getInReferences().size() == 0) return null;
if (!refMethod.isReturnValueUsed()) {
final PsiMethod psiMethod = (PsiMethod)refMethod.getElement();
if (IGNORE_BUILDER_PATTERN && PropertyUtil.isSimplePropertySetter(psiMethod)) return null;
final boolean isNative = psiMethod.hasModifierProperty(PsiModifier.NATIVE);
if (refMethod.isExternalOverride() && !isNative) return null;
return new ProblemDescriptor[]{manager.createProblemDescriptor(psiMethod.getNavigationElement(),
InspectionsBundle
.message("inspection.unused.return.value.problem.descriptor"),
!isNative ? getFix(processor) : null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false)};
}
}
return null;
}