當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiField類代碼示例

本文整理匯總了Java中com.intellij.psi.PsiField的典型用法代碼示例。如果您正苦於以下問題:Java PsiField類的具體用法?Java PsiField怎麽用?Java PsiField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PsiField類屬於com.intellij.psi包,在下文中一共展示了PsiField類的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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:ConstantNamingConventionInspectionBase.java

示例2: getWritablePropertyType

import com.intellij.psi.PsiField; //導入依賴的package包/類
@Nullable
public static PsiType getWritablePropertyType(@Nullable PsiClass containingClass,
    @Nullable PsiElement declaration) {
  if (declaration instanceof PsiField) {
    return getWrappedPropertyType((PsiField) declaration, JavaFxCommonNames.ourWritableMap);
  }
  if (declaration instanceof PsiMethod) {
    final PsiMethod method = (PsiMethod) declaration;
    if (method.getParameterList().getParametersCount() != 0) {
      return getSetterArgumentType(method);
    }
    final String propertyName = PropertyUtil.getPropertyName(method);
    final PsiClass psiClass =
        containingClass != null ? containingClass : method.getContainingClass();
    if (propertyName != null && containingClass != null) {
      final PsiMethod setter = findInstancePropertySetter(psiClass, propertyName);
      if (setter != null) {
        final PsiType setterArgumentType = getSetterArgumentType(setter);
        if (setterArgumentType != null)
          return setterArgumentType;
      }
    }
    return getGetterReturnType(method);
  }
  return null;
}
 
開發者ID:1tontech,項目名稱:intellij-spring-assistant,代碼行數:27,代碼來源:PsiUtil.java

示例3: 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;

}
 
開發者ID:jessie345,項目名稱:CustomLintRules,代碼行數:17,代碼來源:Utils.java

示例4: getResolutionFrom

import com.intellij.psi.PsiField; //導入依賴的package包/類
@Nullable
Resolution getResolutionFrom(PsiField field) {
    PsiAnnotation annotation = scenarioStateProvider.getJGivenAnnotationOn(field);
    if (annotation == null) {
        return null;
    }

    PsiExpression annotationValue = annotationValueProvider.getAnnotationValue(annotation, FIELD_RESOLUTION);

    return Optional.ofNullable(annotationValue)
            .map(PsiElement::getText)
            .map(t -> {
                for (Resolution resolution : Resolution.values()) {
                    if (resolution != Resolution.AUTO && t.contains(resolution.name())) {
                        return resolution;
                    }
                }
                return getResolutionForFieldType(field);
            }).orElse(getResolutionForFieldType(field));
}
 
開發者ID:TNG,項目名稱:jgiven-intellij-plugin,代碼行數:21,代碼來源:ResolutionProvider.java

示例5: should_process_reference

import com.intellij.psi.PsiField; //導入依賴的package包/類
@Test
public void should_process_reference() throws Exception {
    // given
    PsiReference reference1 = mock(PsiReference.class);
    PsiReference reference2 = mock(PsiReference.class);

    PsiField field = mock(PsiField.class);
    ReferencesSearch.SearchParameters searchParameters = mock(ReferencesSearch.SearchParameters.class);
    when(searchParameters.getElementToSearch()).thenReturn(field);
    when(searchParameters.getEffectiveSearchScope()).thenReturn(mock(GlobalSearchScope.class));
    when(scenarioStateReferenceProvider.findReferences(field)).thenReturn(Arrays.asList(reference1, reference2));
    when(scenarioStateProvider.isJGivenScenarioState(field)).thenReturn(true);

    // when
    referenceProvider.processQuery(searchParameters, processor);

    // then
    verify(processor).process(reference1);
    verify(processor).process(reference2);
}
 
開發者ID:TNG,項目名稱:jgiven-intellij-plugin,代碼行數:21,代碼來源:ReferenceProviderTest.java

示例6: multiResolve

import com.intellij.psi.PsiField; //導入依賴的package包/類
@NotNull
@Override
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    Project project = myElement.getProject();
    final String enumLiteralJavaModelName = myElement.getText().replaceAll("\"", "").toUpperCase();

    final PsiShortNamesCache psiShortNamesCache = PsiShortNamesCache.getInstance(project);
    final PsiField[] javaEnumLiteralFields = psiShortNamesCache.getFieldsByName(
        enumLiteralJavaModelName, GlobalSearchScope.allScope(project)
    );

    final Set<PsiField> enumFields = stream(javaEnumLiteralFields)
        .filter(literal -> literal.getParent() != null)
        .filter(literal -> literal.getParent() instanceof ClsClassImpl)
        .filter(literal -> ((ClsClassImpl) literal.getParent()).isEnum())
        .collect(Collectors.toSet());

    return PsiElementResolveResult.createResults(enumFields);
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:20,代碼來源:HybrisEnumLiteralItemReference.java

示例7: extractConfigInfo

import com.intellij.psi.PsiField; //導入依賴的package包/類
private Optional<ConfigInfo> extractConfigInfo(PropertiesFile propertiesFile, CoffigResolver.Match match) {
    Optional<String> description = Optional.ofNullable(propertiesFile.findPropertyByKey(match.getUnmatchedPath())).map(IProperty::getValue);
    if (description.isPresent()) {
        // Base info
        ConfigInfo configInfo = new ConfigInfo(match.getFullPath(), description.get());

        // Extended info
        Optional.ofNullable(propertiesFile.findPropertyByKey(match.getUnmatchedPath() + ".long")).map(IProperty::getValue).ifPresent(configInfo::setLongDescription);

        // Field info
        CoffigResolver.Match resolvedMatch = match.fullyResolve();
        if (resolvedMatch.isFullyResolved()) {
            Optional<PsiField> psiField = resolvedMatch.resolveField(resolvedMatch.getUnmatchedPath());
            psiField.map(PsiVariable::getType).map(PsiType::getPresentableText).ifPresent(configInfo::setType);
        }

        return Optional.of(configInfo);
    }
    return Optional.empty();
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:21,代碼來源:CoffigDocumentationProvider.java

示例8: resolveFieldConfigType

import com.intellij.psi.PsiField; //導入依賴的package包/類
Optional<PsiClass> resolveFieldConfigType(PsiField psiField) {
    PsiType fieldType = psiField.getType();
    if (fieldType instanceof PsiClassType) {
        PsiClassType fieldClassType = ((PsiClassType) fieldType);
        if (collectionType != null && collectionType.isAssignableFrom(fieldType) && fieldClassType.getParameterCount() == 1) {
            return toPsiClass(fieldClassType.getParameters()[0]);
        } else if (mapType != null && mapType.isAssignableFrom(fieldType) && fieldClassType.getParameterCount() == 2) {
            return toPsiClass(fieldClassType.getParameters()[1]);
        } else {
            return toPsiClass(fieldType);
        }
    } else if (fieldType instanceof PsiArrayType) {
        return toPsiClass(((PsiArrayType) fieldType).getComponentType());
    } else {
        return Optional.empty();
    }
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:18,代碼來源:CoffigResolver.java

示例9: canProcessElement

import com.intellij.psi.PsiField; //導入依賴的package包/類
@Override
public boolean canProcessElement( @NotNull PsiElement elem )
{
  PsiElement[] element = new PsiElement[]{elem};
  List<PsiElement> javaElems = findJavaElements( element );
  if( javaElems.isEmpty() )
  {
    return false;
  }

  for( PsiElement javaElem : javaElems )
  {
    if( !(javaElem instanceof PsiMethod) &&
        !(javaElem instanceof PsiField) &&
        !(javaElem instanceof PsiClass) )
    {
      return false;
    }
  }

  return true;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:23,代碼來源:RenameResourceElementProcessor.java

示例10: makeSrcClass

import com.intellij.psi.PsiField; //導入依賴的package包/類
public SrcClass makeSrcClass( String fqn, PsiClass psiClass, ManModule module )
{
  SrcClass srcClass = new SrcClass( fqn, getKind( psiClass ) )
    .modifiers( getModifiers( psiClass.getModifierList() ) );
  for( PsiTypeParameter typeVar : psiClass.getTypeParameters() )
  {
    srcClass.addTypeVar( new SrcType( makeTypeVar( typeVar ) ) );
  }
  setSuperTypes( srcClass, psiClass );
  for( PsiMethod psiMethod : psiClass.getMethods() )
  {
    addMethod( srcClass, psiMethod );
  }
  for( PsiField psiField : psiClass.getFields() )
  {
    addField( srcClass, psiField );
  }
  for( PsiClass psiInnerClass : psiClass.getInnerClasses() )
  {
    addInnerClass( srcClass, psiInnerClass, module );
  }
  return srcClass;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:24,代碼來源:StubBuilder.java

示例11: init

import com.intellij.psi.PsiField; //導入依賴的package包/類
private void init(@NonNull PsiClass clazz) {
    mClass = clazz;
    mClassFields = new HashMap<>();
    mWriteFieldGroupMethods = new ArrayList<>();
    mShardWriteFieldGroupMatrix = new ArrayList<>();

    mFunctions = new ArrayList<>();
    mMethodsToSeparateByGroup = new HashMap<>();
    mMethodsToSeparateBySingle = new ArrayList<>();
    mMethodsTrySeparateByRole = new HashMap<>();

    mUnusedMethods = new HashSet<>();
    mUnusedMethods.addAll(Arrays.asList(mClass.getMethods()));
    // PsiClass#getMethods() では、コンストラクタもメソッドに含まれます。

    for (PsiField field : mClass.getFields()) {
        mClassFields.put(field.getName(), field);
    }
}
 
開發者ID:cch-robo,項目名稱:Android_Lint_SRP_Practice_Example,代碼行數:20,代碼來源:SharingGroupClassificationDetector.java

示例12: parse

import com.intellij.psi.PsiField; //導入依賴的package包/類
/**
 * 左右のメソッドが共有する変更フィールド変數(狀態)を解析
 * @return 左右のメソッドが共有する変更フィールド変數
 */
private Map<String, PsiField> parse() {
    Map<String, PsiField> leftWriteFields = mLeftMethod.provideWriteFields();
    Map<String, PsiField> rightWriteFields = mRightMethod.provideWriteFields();

    Map<String, PsiField> sharedWriteFields = new HashMap<>();
    Collection<PsiField> leftValues = leftWriteFields.values();
    Collection<PsiField> rightValues = rightWriteFields.values();
    for (PsiField field : leftValues) {
        if (rightValues.contains(field)) {
            sharedWriteFields.put(field.getName(), field);
        }
    }

    return sharedWriteFields;
}
 
開發者ID:cch-robo,項目名稱:Android_Lint_SRP_Practice_Example,代碼行數:20,代碼來源:SharingGroupClassificationDetector.java

示例13: Settings

import com.intellij.psi.PsiField; //導入依賴的package包/類
public Settings(boolean replaceUsages,
                @Nullable String classParameterName,
                @Nullable VariableData[] variableDatum,
                boolean delegate) {
  myReplaceUsages = replaceUsages;
  myDelegate = delegate;
  myMakeClassParameter = classParameterName != null;
  myClassParameterName = classParameterName;
  myMakeFieldParameters = variableDatum != null;
  myFieldToNameList = new ArrayList<FieldParameter>();
  if(myMakeFieldParameters) {
    myFieldToNameMapping = new HashMap<PsiField, String>();
    for (VariableData data : variableDatum) {
      if (data.passAsParameter) {
        myFieldToNameMapping.put((PsiField)data.variable, data.name);
        myFieldToNameList.add(new FieldParameter((PsiField)data.variable, data.name, data.type));
      }
    }
  }
  else {
    myFieldToNameMapping = null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:Settings.java

示例14: buildVisitor

import com.intellij.psi.PsiField; //導入依賴的package包/類
@Override
public BaseInspectionVisitor buildVisitor() {
  return new BaseInspectionVisitor() {
    @Override
    public void visitField(PsiField field) {
      final boolean ruleAnnotated = REPORT_RULE_PROBLEMS && AnnotationUtil.isAnnotated(field, RULE_FQN, false);
      final boolean classRuleAnnotated = REPORT_CLASS_RULE_PROBLEMS && AnnotationUtil.isAnnotated(field, CLASS_RULE_FQN, false);
      if (ruleAnnotated || classRuleAnnotated) {
        String annotation = ruleAnnotated ? RULE_FQN : CLASS_RULE_FQN;
        String errorMessage = getPublicStaticErrorMessage(field, ruleAnnotated, classRuleAnnotated);
        if (errorMessage != null) {
          registerError(field.getNameIdentifier(), InspectionGadgetsBundle.message("junit.rule.problem.descriptor", annotation, errorMessage), "Make field " + errorMessage, annotation);
        }
        if (!InheritanceUtil.isInheritor(PsiUtil.resolveClassInClassTypeOnly(field.getType()), false, "org.junit.rules.TestRule")) {
          registerError(field.getNameIdentifier(), InspectionGadgetsBundle.message("junit.rule.type.problem.descriptor"));
        }
      }
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:JUnitRuleInspection.java

示例15: 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


注:本文中的com.intellij.psi.PsiField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。