Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
12,700
|
String () { return value; }
|
getValue
|
12,701
|
boolean () { return stopBubbling; }
|
isStopBubbling
|
12,702
|
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ConfigValue that = (ConfigValue) o; if (stopBubbling != that.stopBubbling) return false; return value != null ? value.equals(that.value) : that.value == null; }
|
equals
|
12,703
|
int () { int result = value != null ? value.hashCode() : 0; result = 31 * result + (stopBubbling ? 1 : 0); return result; }
|
hashCode
|
12,704
|
String () { return "ConfigValue {" + value + ", " + stopBubbling + "}"; }
|
toString
|
12,705
|
String () { return configKey; }
|
getConfigKey
|
12,706
|
String () { return configDefaultValue; }
|
getConfigDefaultValue
|
12,707
|
ConfigKey (String configStringKey) { for (ConfigKey keys : values()) { if (keys.getConfigKey().equalsIgnoreCase(configStringKey)) { return keys; } } return null; }
|
fromConfigStringKey
|
12,708
|
String () { return key; }
|
getKey
|
12,709
|
String () { return nonNullAnnotation; }
|
getNonNullAnnotation
|
12,710
|
String () { return nullableAnnotation; }
|
getNullableAnnotation
|
12,711
|
boolean () { return typeUse; }
|
isTypeUse
|
12,712
|
void (@NotNull List<? extends @NotNull VFileEvent> events) { for (VFileEvent event : events) { VirtualFile eventFile = event.getFile(); if (null != eventFile) { final CharSequence nameSequence = eventFile.getNameSequence(); if (Strings.endsWith(nameSequence, "lombok.config")) { final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(nameSequence); if (LombokConfigFileType.INSTANCE.equals(fileType)) { CONFIG_CHANGE_COUNTER.incrementAndGet(); break; } } } } }
|
before
|
12,713
|
ConfigDiscovery () { return ApplicationManager.getApplication().getService(ConfigDiscovery.class); }
|
getInstance
|
12,714
|
LombokNullAnnotationLibrary (@NotNull PsiClass psiClass) { final String configProperty = getStringLombokConfigProperty(ConfigKey.ADD_NULL_ANNOTATIONS, psiClass); if (StringUtil.isNotEmpty(configProperty)) { for (LombokNullAnnotationLibraryDefned library : LombokNullAnnotationLibraryDefned.values()) { if (library.getKey().equalsIgnoreCase(configProperty)) { return library; } } final LombokNullAnnotationLibrary parsedCustom = LombokNullAnnotationLibraryCustom.parseCustom(configProperty); if (null != parsedCustom) { return parsedCustom; } } return LombokNullAnnotationLibraryDefned.NONE; }
|
getAddNullAnnotationLombokConfigProperty
|
12,715
|
Collection<String> (@NotNull ConfigKey configKey, @NotNull PsiClass psiClass) { return getConfigProperty(configKey, psiClass); }
|
getMultipleValueLombokConfigProperty
|
12,716
|
String (@NotNull ConfigKey configKey, @NotNull PsiClass psiClass) { Collection<String> result = getConfigProperty(configKey, psiClass); if (!result.isEmpty()) { return result.iterator().next(); } return configKey.getConfigDefaultValue(); }
|
getStringLombokConfigProperty
|
12,717
|
boolean (@NotNull ConfigKey configKey, @NotNull PsiClass psiClass) { final String configProperty = getStringLombokConfigProperty(configKey, psiClass); return Boolean.parseBoolean(configProperty); }
|
getBooleanLombokConfigProperty
|
12,718
|
Collection<String> (@NotNull ConfigKey configKey, @NotNull PsiClass psiClass) { @Nullable PsiFile psiFile = calculatePsiFile(psiClass); if (psiFile != null) { return discoverPropertyWithCache(configKey, psiFile); } return Collections.singletonList(configKey.getConfigDefaultValue()); }
|
getConfigProperty
|
12,719
|
PsiFile (@NotNull PsiClass psiClass) { PsiFile psiFile = psiClass.getContainingFile(); if (psiFile != null) { psiFile = psiFile.getOriginalFile(); } return psiFile; }
|
calculatePsiFile
|
12,720
|
Collection<String> (@NotNull ConfigKey configKey, @NotNull PsiFile psiFile) { return CachedValuesManager.getCachedValue(psiFile, () -> { Map<ConfigKey, Collection<String>> result = ConcurrentFactoryMap.createMap(configKeyInner -> discoverProperty(configKeyInner, psiFile)); return CachedValueProvider.Result.create(result, LombokConfigChangeListener.CONFIG_CHANGE_TRACKER); }).get(configKey); }
|
discoverPropertyWithCache
|
12,721
|
Collection<String> (@NotNull ConfigKey configKey, @NotNull PsiFile psiFile) { if (configKey.isConfigScalarValue()) { return discoverScalarProperty(configKey, psiFile); } return discoverCollectionProperty(configKey, psiFile); }
|
discoverProperty
|
12,722
|
Collection<String> (@NotNull ConfigKey configKey, @NotNull PsiFile psiFile) { @Nullable VirtualFile currentFile = psiFile.getVirtualFile(); while (currentFile != null) { ConfigValue configValue = readProperty(configKey, psiFile.getProject(), currentFile); if (null != configValue) { if (null == configValue.getValue()) { if (configValue.isStopBubbling()) { break; } } else { return Collections.singletonList(configValue.getValue()); } } currentFile = currentFile.getParent(); } return Collections.singletonList(configKey.getConfigDefaultValue()); }
|
discoverScalarProperty
|
12,723
|
FileBasedIndex () { return FileBasedIndex.getInstance(); }
|
getFileBasedIndex
|
12,724
|
ConfigValue (@NotNull ConfigKey configKey, @NotNull Project project, @NotNull VirtualFile directory) { GlobalSearchScope directoryScope = GlobalSearchScopes.directoryScope(project, directory, false); List<ConfigValue> values = getFileBasedIndex().getValues(LombokConfigIndex.NAME, configKey, directoryScope); if (!values.isEmpty()) { return values.iterator().next(); } return null; }
|
readProperty
|
12,725
|
Collection<String> (@NotNull ConfigKey configKey, @NotNull PsiFile file) { List<String> properties = new ArrayList<>(); final Project project = file.getProject(); @Nullable VirtualFile currentFile = file.getVirtualFile(); while (currentFile != null) { final ConfigValue configValue = readProperty(configKey, project, currentFile); if (null != configValue) { if (null == configValue.getValue()) { if (configValue.isStopBubbling()) { break; } } else { properties.add(configValue.getValue()); } } currentFile = currentFile.getParent(); } Collections.reverse(properties); Set<String> result = new HashSet<>(); for (String configProperty : properties) { if (StringUtil.isNotEmpty(configProperty)) { final String[] values = configProperty.split(";"); for (String value : values) { if (value.startsWith("+")) { result.add(value.substring(1)); } else if (value.startsWith("-")) { result.remove(value.substring(1)); } } } } return result; }
|
discoverCollectionProperty
|
12,726
|
KeyDescriptor<ConfigKey> () { return new EnumDataDescriptor<>(ConfigKey.class); }
|
getKeyDescriptor
|
12,727
|
DataExternalizer<ConfigValue> () { return new DataExternalizer<>() { @Override public void save(@NotNull DataOutput out, ConfigValue configValue) throws IOException { var isNotNullValue = configValue.getValue() != null; out.writeBoolean(isNotNullValue); if (isNotNullValue) { EnumeratorStringDescriptor.INSTANCE.save(out, configValue.getValue()); } out.writeBoolean(configValue.isStopBubbling()); } @Override public ConfigValue read(@NotNull DataInput in) throws IOException { var isNotNullValue = in.readBoolean(); return new ConfigValue(isNotNullValue ? EnumeratorStringDescriptor.INSTANCE.read(in) : null, in.readBoolean()); } }; }
|
getValueExternalizer
|
12,728
|
boolean () { return true; }
|
dependsOnFileContent
|
12,729
|
int () { return 14; }
|
getVersion
|
12,730
|
String () { return nonNullAnnotation; }
|
getNonNullAnnotation
|
12,731
|
String () { return nullableAnnotation; }
|
getNullableAnnotation
|
12,732
|
boolean () { return typeUse; }
|
isTypeUse
|
12,733
|
LombokNullAnnotationLibrary (String value) { if (StringUtil.toLowerCase(value).startsWith("custom:")) { String customConfigValue = value.substring("custom:".length()); final boolean useType = StringUtil.toLowerCase(customConfigValue).startsWith("type_use:"); if (useType) { customConfigValue = customConfigValue.substring("type_use:".length()); } String nonNullAnnotation, nullableAnnotation = null; final int splitIndex = customConfigValue.indexOf(':'); if (splitIndex == -1) { nonNullAnnotation = customConfigValue; } else { nonNullAnnotation = customConfigValue.substring(0, splitIndex); nullableAnnotation = customConfigValue.substring(splitIndex + 1); } if (verifyTypeName(nonNullAnnotation) && (null == nullableAnnotation || verifyTypeName(nullableAnnotation))) { return new LombokNullAnnotationLibraryCustom(nonNullAnnotation, nullableAnnotation, useType); } } return null; }
|
parseCustom
|
12,734
|
boolean (String fqn) { boolean atStart = true; for (int i = 0; i < fqn.length(); i++) { char c = fqn.charAt(i); if (Character.isJavaIdentifierStart(c)) { atStart = false; continue; } if (atStart) return false; if (c == '.') { atStart = true; continue; } if (Character.isJavaIdentifierPart(c)) continue; return false; } return !atStart; }
|
verifyTypeName
|
12,735
|
void (@NotNull ActionContext context, @NotNull PsiClass psiClass, @NotNull ModPsiUpdater updater) { final PsiModifierList modifiers = psiClass.getModifierList(); if (modifiers != null) { modifiers.setModifierProperty(PsiModifier.ABSTRACT, true); modifiers.setModifierProperty(PsiModifier.STATIC, true); } }
|
invoke
|
12,736
|
String () { return LombokBundle.message("make.abstract.and.static.modifier.quickfix.family.name"); }
|
getFamilyName
|
12,737
|
void (@NotNull ActionContext context, @NotNull PsiClass element, @NotNull ModPsiUpdater updater) { final PsiField field = elementToRemove.getElement(); if (field != null) { final Collection<PsiReference> all = ReferencesSearch.search(field).findAll(); List<PsiElement> refs = ContainerUtil.map(all, ref -> updater.getWritable(ref.getElement())); PsiField writableField = updater.getWritable(field); final String loggerName = getLoggerName(element); for (PsiElement refElement : refs) { PsiReference ref = refElement.getReference(); if (ref != null) { ref.handleElementRename(loggerName); } } writableField.delete(); JavaCodeStyleManager.getInstance(context.project()).removeRedundantImports((PsiJavaFile)element.getContainingFile()); } JavaCodeStyleManager.getInstance(context.project()) .shortenClassReferences(Objects.requireNonNull(element.getModifierList()).addAnnotation(LombokClassNames.SLF_4_J)); }
|
invoke
|
12,738
|
String () { return LombokBundle.message("intention.family.name.slf4j.annotation"); }
|
getFamilyName
|
12,739
|
String () { return LombokBundle.message("intention.name.create.new.field.s", myName); }
|
getFamilyName
|
12,740
|
void (@NotNull ActionContext context, @NotNull PsiClass myClass, @NotNull ModPsiUpdater updater) { PsiElement lBrace = myClass.getLBrace(); if (lBrace == null) return; final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(context.project()); final PsiField psiField = psiElementFactory.createField(myName, myType); final PsiModifierList modifierList = psiField.getModifierList(); if (modifierList != null) { for (String modifier : myModifiers) { modifierList.setModifierProperty(modifier, true); } } if (myInitializerText != null) { PsiExpression psiInitializer = psiElementFactory.createExpressionFromText(myInitializerText, psiField); psiField.setInitializer(psiInitializer); } final List<PsiGenerationInfo<PsiField>> generationInfos = GenerateMembersUtil.insertMembersAtOffset( myClass.getContainingFile(), lBrace.getTextRange().getEndOffset(), List.of(new PsiGenerationInfo<>(psiField))); if (!generationInfos.isEmpty()) { PsiField psiMember = Objects.requireNonNull(generationInfos.iterator().next().getPsiMember()); updater.moveTo(psiMember.getTextRange().getEndOffset()); } }
|
invoke
|
12,741
|
LocalQuickFix (@NotNull PsiClass psiClass, @NotNull String annotationFQN, @Nullable String annotationParam) { PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject()); PsiAnnotation newAnnotation = elementFactory.createAnnotationFromText("@" + annotationFQN + "(" + StringUtil.notNullize(annotationParam) + ")", psiClass); final PsiNameValuePair[] attributes = newAnnotation.getParameterList().getAttributes(); return new AddAnnotationFix(annotationFQN, psiClass, attributes); }
|
createAddAnnotationQuickFix
|
12,742
|
LocalQuickFix (@NotNull PsiModifierListOwner owner, @NotNull String modifier, boolean shouldHave, final boolean showContainingClass) { return LocalQuickFix.from(new ModifierFix(owner, modifier, shouldHave, showContainingClass)); }
|
createModifierListFix
|
12,743
|
LocalQuickFix (@NotNull PsiClass psiClass, @NotNull String name, @NotNull PsiType psiType, @Nullable String initializerText, String... modifiers) { return LocalQuickFix.from(new CreateFieldQuickFix(psiClass, name, psiType, initializerText, modifiers)); }
|
createNewFieldFix
|
12,744
|
LocalQuickFix (@NotNull PsiAnnotation psiAnnotation, @NotNull String name, @Nullable String newValue) { return LocalQuickFix.from(new ChangeAnnotationParameterQuickFix(psiAnnotation, name, newValue)); }
|
createChangeAnnotationParameterFix
|
12,745
|
PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new LombokElementVisitor(holder); }
|
createVisitor
|
12,746
|
void (final @NotNull PsiAnnotation annotation) { if (annotation.hasQualifiedName(SPRING_QUALIFIER_FQN)) { PsiAnnotationOwner annotationOwner = annotation.getOwner(); if (annotationOwner instanceof PsiModifierList) { PsiElement annotationOwnerParent = ((PsiModifierList)annotationOwner).getParent(); if (annotationOwnerParent instanceof PsiField) { PsiClass psiClass = ((PsiField)annotationOwnerParent).getContainingClass(); if (psiClass != null && PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.REQUIRED_ARGS_CONSTRUCTOR, LombokClassNames.ALL_ARGS_CONSTRUCTOR)) { Collection<String> configuredCopyableAnnotations = ConfigDiscovery.getInstance().getMultipleValueLombokConfigProperty(ConfigKey.COPYABLE_ANNOTATIONS, psiClass); if (!configuredCopyableAnnotations.contains(SPRING_QUALIFIER_FQN)) { holder.registerProblem(annotation, LombokBundle.message("inspection.message.annotation.not.lombok.copyable", SPRING_QUALIFIER_FQN), ProblemHighlightType.WARNING); } } } } } }
|
visitAnnotation
|
12,747
|
String () { return "param"; }
|
getTagName
|
12,748
|
String () { return "SETTER"; }
|
getJavaDocMethodMarkup
|
12,749
|
boolean ( @NotNull PsiMethod method, @NotNull List<Pair<PsiField, PsiMethod>> instanceCandidates, @NotNull List<Pair<PsiField, PsiMethod>> staticCandidates ) { if (!method.hasModifierProperty(PsiModifier.PUBLIC) || method.isConstructor() || !method.hasParameters() || method.getParameterList().getParameters().length != 1 || 0 < method.getThrowsTypes().length || method.hasModifierProperty(PsiModifier.FINAL) || method.hasModifierProperty(PsiModifier.ABSTRACT) || method.hasModifierProperty(PsiModifier.SYNCHRONIZED) || method.hasModifierProperty(PsiModifier.NATIVE) || method.hasModifierProperty(PsiModifier.STRICTFP) || 0 < method.getAnnotations().length || !PsiTypes.voidType().equals(method.getReturnType()) || !method.isWritable()) { return false; } final PsiParameter parameter = method.getParameterList().getParameters()[0]; if ( parameter.isVarArgs() || ( parameter.getModifierList() != null && 0 < parameter.getModifierList().getChildren().length && (parameter.getModifierList().getChildren().length != 1 || !parameter.hasModifier(JvmModifier.FINAL)) ) || 0 < parameter.getAnnotations().length ) { return false; } final PsiType parameterType = parameter.getType(); final String methodName = method.getName(); if (!methodName.startsWith("set")) { return false; } final String fieldName = StringUtil.getPropertyName(methodName); if (StringUtil.isEmpty(fieldName)) { return false; } if (method.getBody() == null) { return false; } final PsiStatement @NotNull [] methodStatements = Arrays.stream(method.getBody().getStatements()).filter(e -> !(e instanceof PsiEmptyStatement)).toArray(PsiStatement[]::new); if (methodStatements.length != 1) { return false; } final PsiExpressionStatement assignmentStatement = tryCast(methodStatements[0], PsiExpressionStatement.class); if (assignmentStatement == null) { return false; } final PsiAssignmentExpression assignment = tryCast(assignmentStatement.getExpression(), PsiAssignmentExpression.class); if (assignment == null || assignment.getOperationTokenType() != JavaTokenType.EQ) { return false; } final PsiReferenceExpression sourceRef = tryCast(PsiUtil.skipParenthesizedExprDown(assignment.getRExpression()), PsiReferenceExpression.class); if (sourceRef == null || sourceRef.getQualifierExpression() != null) { return false; } final @Nullable String paramIdentifier = sourceRef.getReferenceName(); if (paramIdentifier == null) { return false; } if (!paramIdentifier.equals(parameter.getName())) { return false; } final PsiReferenceExpression targetRef = tryCast(assignment.getLExpression(), PsiReferenceExpression.class); if (targetRef == null) { return false; } final @Nullable PsiExpression qualifier = targetRef.getQualifierExpression(); final @Nullable PsiThisExpression thisExpression = tryCast(qualifier, PsiThisExpression.class); final PsiClass psiClass = PsiTreeUtil.getParentOfType(method, PsiClass.class); if (psiClass == null) { return false; } if (qualifier != null) { if (thisExpression == null) { return false; } else if (thisExpression.getQualifier() != null) { if (!thisExpression.getQualifier().isReferenceTo(psiClass)) { return false; } } } final @Nullable String fieldIdentifier = targetRef.getReferenceName(); if (fieldIdentifier == null) { return false; } if (!fieldName.equals(fieldIdentifier) && !StringUtil.capitalize(fieldName).equals(fieldIdentifier)) { return false; } if (qualifier == null && paramIdentifier.equals(fieldIdentifier)) { return false; } final boolean isMethodStatic = method.hasModifierProperty(PsiModifier.STATIC); final PsiField field = psiClass.findFieldByName(fieldIdentifier, false); if (field == null || !field.isWritable() || isMethodStatic != field.hasModifierProperty(PsiModifier.STATIC) || !field.getType().equals(parameterType)) { return false; } if (isMethodStatic) { staticCandidates.add(Pair.pair(field, method)); } else { instanceCandidates.add(Pair.pair(field, method)); } return true; }
|
processMethod
|
12,750
|
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { Module module = ModuleUtilCore.findModuleForFile(holder.getFile()); if (!LombokLibraryUtil.hasLombokClasses(module)) { return PsiElementVisitor.EMPTY_VISITOR; } return createVisitor(holder, isOnTheFly); }
|
buildVisitor
|
12,751
|
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new LombokDefinitionVisitor(holder); }
|
createVisitor
|
12,752
|
void (@NotNull PsiField field) { super.visitField(field); findRedundantDefinition(field, field.getContainingClass()); }
|
visitField
|
12,753
|
void (@NotNull PsiField field, PsiClass containingClass) { if (field.getType().equalsToText(LOGGER_SLF4J_FQCN)) { final PsiExpression initializer = field.getInitializer(); if (initializer != null && containingClass != null) { if (initializer.getText().contains(format(LOGGER_INITIALIZATION, containingClass.getQualifiedName()))) { holder.problem(field, LombokBundle.message("inspection.message.slf4j.logger.defined.explicitly")) .highlight(ProblemHighlightType.WARNING).fix(new UseSlf4jAnnotationQuickFix(field, containingClass)).register(); } } } }
|
findRedundantDefinition
|
12,754
|
String () { return "return"; }
|
getTagName
|
12,755
|
String () { return "GETTER"; }
|
getJavaDocMethodMarkup
|
12,756
|
boolean ( @NotNull PsiMethod method, @NotNull List<Pair<PsiField, PsiMethod>> instanceCandidates, @NotNull List<Pair<PsiField, PsiMethod>> staticCandidates ) { final PsiType returnType = method.getReturnType(); if (!method.hasModifierProperty(PsiModifier.PUBLIC) || method.isConstructor() || method.hasParameters() || method.getThrowsTypes().length != 0 || method.hasModifierProperty(PsiModifier.FINAL) || method.hasModifierProperty(PsiModifier.ABSTRACT) || method.hasModifierProperty(PsiModifier.SYNCHRONIZED) || method.hasModifierProperty(PsiModifier.NATIVE) || method.hasModifierProperty(PsiModifier.STRICTFP) || method.getAnnotations().length != 0 || PsiTypes.voidType().equals(returnType) || returnType == null || returnType.getAnnotations().length != 0 || !method.isWritable()) { return false; } final String methodName = method.getName(); final boolean isBooleanType = PsiTypes.booleanType().equals(returnType); if (isBooleanType ? !methodName.startsWith("is") : !methodName.startsWith("get")) { return false; } final String fieldName = StringUtil.getPropertyName(methodName); if (StringUtil.isEmpty(fieldName)) { return false; } if (method.getBody() == null) { return false; } final PsiStatement @NotNull [] methodStatements = Arrays.stream(method.getBody().getStatements()).filter(e -> !(e instanceof PsiEmptyStatement)).toArray(PsiStatement[]::new); if (methodStatements.length != 1) { return false; } final PsiReturnStatement returnStatement = tryCast(methodStatements[0], PsiReturnStatement.class); if (returnStatement == null) { return false; } final PsiReferenceExpression targetRef = tryCast( PsiUtil.skipParenthesizedExprDown(returnStatement.getReturnValue()), PsiReferenceExpression.class); if (targetRef == null) { return false; } final @Nullable PsiExpression qualifier = targetRef.getQualifierExpression(); final @Nullable PsiThisExpression thisExpression = tryCast(qualifier, PsiThisExpression.class); final PsiClass psiClass = PsiTreeUtil.getParentOfType(method, PsiClass.class); if (psiClass == null) { return false; } if (qualifier != null) { if (thisExpression == null) { return false; } else if (thisExpression.getQualifier() != null) { if (!thisExpression.getQualifier().isReferenceTo(psiClass)) { return false; } } } final @Nullable String fieldIdentifier = targetRef.getReferenceName(); if (!fieldName.equals(fieldIdentifier) && !StringUtil.capitalize(fieldName).equals(fieldIdentifier)) { return false; } final boolean isMethodStatic = method.hasModifierProperty(PsiModifier.STATIC); final PsiField field = psiClass.findFieldByName(fieldIdentifier, false); if (field == null || !field.isWritable() || isMethodStatic != field.hasModifierProperty(PsiModifier.STATIC) || !field.getType().equals(returnType)) { return false; } if (isMethodStatic) { staticCandidates.add(Pair.pair(field, method)); } else { instanceCandidates.add(Pair.pair(field, method)); } return true; }
|
processMethod
|
12,757
|
PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new LombokGetterOrSetterMayBeUsedVisitor(holder, null); }
|
createVisitor
|
12,758
|
void (@NotNull PsiJavaFile psiJavaFile) { }
|
visitJavaFile
|
12,759
|
void (@NotNull PsiClass psiClass) { List<PsiField> annotatedFields = new ArrayList<>(); List<Pair<PsiField, PsiMethod>> instanceCandidates = new ArrayList<>(); List<Pair<PsiField, PsiMethod>> staticCandidates = new ArrayList<>(); for (PsiMethod method : psiClass.getMethods()) { processMethod(method, instanceCandidates, staticCandidates); } boolean isLombokAnnotationAtClassLevel = true; for (PsiField field : psiClass.getFields()) { PsiAnnotation annotation = field.getAnnotation(getAnnotationName()); if (annotation != null) { if (!annotation.getAttributes().isEmpty() || field.hasModifierProperty(PsiModifier.STATIC)) { isLombokAnnotationAtClassLevel = false; } else { annotatedFields.add(field); } } else if (!field.hasModifierProperty(PsiModifier.STATIC)) { boolean found = false; for (Pair<PsiField, PsiMethod> instanceCandidate : instanceCandidates) { if (field.equals(instanceCandidate.getFirst())) { found = true; break; } } isLombokAnnotationAtClassLevel = found; } if (!isLombokAnnotationAtClassLevel) { break; } } List<Pair<PsiField, PsiMethod>> allCandidates = new ArrayList<>(staticCandidates); if (isLombokAnnotationAtClassLevel && (!instanceCandidates.isEmpty() || !annotatedFields.isEmpty())) { warnOrFix(psiClass, instanceCandidates, annotatedFields); } else { allCandidates.addAll(instanceCandidates); } for (Pair<PsiField, PsiMethod> candidate : allCandidates) { warnOrFix(candidate.getFirst(), candidate.getSecond()); } }
|
visitClass
|
12,760
|
void (@NotNull PsiMethod psiMethod) { List<Pair<PsiField, PsiMethod>> fieldsAndMethods = new ArrayList<>(); if (!processMethod(psiMethod, fieldsAndMethods, fieldsAndMethods)) return; if (!fieldsAndMethods.isEmpty()) { final Pair<PsiField, PsiMethod> psiFieldPsiMethodPair = fieldsAndMethods.get(0); warnOrFix(psiFieldPsiMethodPair.getFirst(), psiFieldPsiMethodPair.getSecond()); } }
|
visitMethodForFix
|
12,761
|
void ( @NotNull PsiClass psiClass, @NotNull List<Pair<PsiField, PsiMethod>> fieldsAndMethods, @NotNull List<PsiField> annotatedFields ) { if (myHolder != null) { String className = psiClass.getName(); final PsiIdentifier psiClassNameIdentifier = psiClass.getNameIdentifier(); final LocalQuickFix fix = new LombokGetterOrSetterMayBeUsedFix(Objects.requireNonNull(className)); myHolder.registerProblem(psiClass, getClassErrorMessage(className), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, psiClassNameIdentifier != null ? psiClassNameIdentifier.getTextRangeInParent() : psiClass.getTextRange(), fix); } else if (myLombokGetterOrSetterMayBeUsedFix != null) { myLombokGetterOrSetterMayBeUsedFix.effectivelyDoFix(psiClass, fieldsAndMethods, annotatedFields); } }
|
warnOrFix
|
12,762
|
void (@NotNull PsiField field, @NotNull PsiMethod method) { if (myHolder != null) { String fieldName = field.getName(); final LocalQuickFix fix = new LombokGetterOrSetterMayBeUsedFix(fieldName); myHolder.registerProblem(method, getFieldErrorMessage(fieldName), fix); } else if (myLombokGetterOrSetterMayBeUsedFix != null) { myLombokGetterOrSetterMayBeUsedFix.effectivelyDoFix(field, method); } }
|
warnOrFix
|
12,763
|
String () { return getFixName(myText); }
|
getName
|
12,764
|
String () { return getFixFamilyName(); }
|
getFamilyName
|
12,765
|
void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (element instanceof PsiMethod) { new LombokGetterOrSetterMayBeUsedVisitor(null, this).visitMethodForFix((PsiMethod)element); } else if (element instanceof PsiClass) { new LombokGetterOrSetterMayBeUsedVisitor(null, this).visitClass((PsiClass)element); } }
|
applyFix
|
12,766
|
void (@NotNull PsiField field, @NotNull PsiMethod method) { if (!addLombokAnnotation(field)) return; removeMethodAndMoveJavaDoc(field, method); }
|
effectivelyDoFix
|
12,767
|
void (@NotNull PsiClass aClass, @NotNull List<Pair<PsiField, PsiMethod>> fieldsAndMethods, @NotNull List<PsiField> annotatedFields) { if (!addLombokAnnotation(aClass)) return; for (Pair<PsiField, PsiMethod> fieldAndMethod : fieldsAndMethods) { PsiField field = fieldAndMethod.getFirst(); PsiMethod method = fieldAndMethod.getSecond(); removeMethodAndMoveJavaDoc(field, method); } for (PsiField annotatedField : annotatedFields) { PsiAnnotation oldAnnotation = annotatedField.getAnnotation(getAnnotationName()); if (oldAnnotation != null) { new CommentTracker().deleteAndRestoreComments(oldAnnotation); } } }
|
effectivelyDoFix
|
12,768
|
boolean (@NotNull PsiModifierListOwner fieldOrClass) { final PsiModifierList modifierList = fieldOrClass.getModifierList(); if (modifierList == null) { return false; } Project project = fieldOrClass.getProject(); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); final PsiAnnotation annotation = factory.createAnnotationFromText("@" + getAnnotationName(), fieldOrClass); JavaCodeStyleManager.getInstance(project).shortenClassReferences(annotation); modifierList.addAfter(annotation, null); return true; }
|
addLombokAnnotation
|
12,769
|
void (@NotNull PsiField field, @NotNull PsiMethod method) { final PsiElementFactory factory = JavaPsiFacade.getElementFactory(field.getProject()); CommentTracker tracker = new CommentTracker(); PsiDocComment methodJavaDoc = method.getDocComment(); if (methodJavaDoc != null) { tracker.text(methodJavaDoc); PsiDocComment fieldJavaDoc = field.getDocComment(); List<String> methodJavaDocTokens = Arrays.stream(methodJavaDoc.getChildren()) .filter(e -> e instanceof PsiDocToken) .map(PsiElement::getText) .filter(text -> !text.matches("\\s*\\*\\s*")) .toList(); methodJavaDocTokens = methodJavaDocTokens.subList(1, methodJavaDocTokens.size() - 1); String javaDocMethodText = String.join("\n* ", methodJavaDocTokens); PsiDocTag[] methodTags = methodJavaDoc.findTagsByName(getTagName()); if (fieldJavaDoc == null) { if (javaDocMethodText.isEmpty()) { fieldJavaDoc = factory.createDocCommentFromText("/**\n*/"); } else { fieldJavaDoc = factory.createDocCommentFromText("/**\n* -- " + getJavaDocMethodMarkup() + " --\n* " + javaDocMethodText + "\n*/"); } for (PsiDocTag methodTag : methodTags) { fieldJavaDoc.add(methodTag); } field.getParent().addBefore(fieldJavaDoc, field); } else { @NotNull PsiElement @NotNull [] fieldJavaDocChildren = Arrays.stream(fieldJavaDoc.getChildren()) .filter(e -> e instanceof PsiDocToken) .toArray(PsiElement[]::new); @NotNull PsiElement fieldJavaDocChild = fieldJavaDocChildren[fieldJavaDocChildren.length - 2]; PsiDocComment newMethodJavaDoc = factory.createDocCommentFromText("/**\n* -- " + getJavaDocMethodMarkup() + " --\n* " + javaDocMethodText + "\n*/"); PsiElement[] tokens = newMethodJavaDoc.getChildren(); for (int i = tokens.length - 2; 0 < i; i--) { fieldJavaDoc.addAfter(tokens[i], fieldJavaDocChild); } for (PsiDocTag methodTag : methodTags) { fieldJavaDoc.add(methodTag); } } methodJavaDoc.delete(); } tracker.delete(method); tracker.insertCommentsBefore(field); }
|
removeMethodAndMoveJavaDoc
|
12,770
|
PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new LombokElementVisitor(holder); }
|
createVisitor
|
12,771
|
void (final @NotNull PsiAnnotation annotation) { checkFor("lombok.experimental.Builder", LombokClassNames.BUILDER, annotation); checkFor("lombok.experimental.Value", LombokClassNames.VALUE, annotation); checkFor("lombok.experimental.Wither", LombokClassNames.WITH, annotation); }
|
visitAnnotation
|
12,772
|
void (String deprecatedAnnotationFQN, String newAnnotationFQN, PsiAnnotation psiAnnotation) { if (psiAnnotation.hasQualifiedName(deprecatedAnnotationFQN)) { final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(psiAnnotation, PsiModifierListOwner.class, false); if (null != listOwner) { holder.registerProblem(psiAnnotation, LombokBundle .message("inspection.message.lombok.annotation.deprecated.not.supported", deprecatedAnnotationFQN, newAnnotationFQN), ProblemHighlightType.ERROR, new AddAnnotationFix(newAnnotationFQN, listOwner, psiAnnotation.getParameterList().getAttributes(), deprecatedAnnotationFQN)); } } }
|
checkFor
|
12,773
|
PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new LombokElementVisitor(holder); }
|
createVisitor
|
12,774
|
void (@NotNull PsiLocalVariable variable) { super.visitLocalVariable(variable); valProcessor.verifyVariable(variable, holder); }
|
visitLocalVariable
|
12,775
|
void (@NotNull PsiParameter parameter) { super.visitParameter(parameter); valProcessor.verifyParameter(parameter, holder); }
|
visitParameter
|
12,776
|
void (@NotNull PsiAnnotation annotation) { super.visitAnnotation(annotation); final Collection<LombokProblem> problems = new HashSet<>(); for (Processor inspector : LombokProcessorManager.getProcessors(annotation)) { problems.addAll(inspector.verifyAnnotation(annotation)); } for (LombokProblem problem : problems) { holder.registerProblem(annotation, problem.getMessage(), problem.getHighlightType(), problem.getQuickFixes()); } }
|
visitAnnotation
|
12,777
|
void (@NotNull PsiMethodCallExpression methodCall) { super.visitMethodCallExpression(methodCall); PsiExpressionList list = methodCall.getArgumentList(); PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression(); boolean isThisOrSuper = referenceToMethod.getReferenceNameElement() instanceof PsiKeyword; final int parameterCount = list.getExpressions().length; if (isThisOrSuper && parameterCount == 0) { JavaResolveResult[] results = referenceToMethod.multiResolve(true); JavaResolveResult resolveResult = results.length == 1 ? results[0] : JavaResolveResult.EMPTY; PsiElement resolved = resolveResult.getElement(); if (resolved instanceof LombokLightMethodBuilder && ((LombokLightMethodBuilder) resolved).getParameterList().getParameters().length != 0) { holder.registerProblem(methodCall, LombokBundle.message("inspection.message.default.constructor.doesn.t.exist"), ProblemHighlightType.ERROR); } } }
|
visitMethodCallExpression
|
12,778
|
boolean (PsiModifierListOwner psiModifierListOwner) { PsiVariable psiVariable = (PsiVariable) psiModifierListOwner; return ValProcessor.isVal(psiVariable); }
|
shouldCheck
|
12,779
|
PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new LombokRedundantModifiersVisitor(holder); }
|
createVisitor
|
12,780
|
void (@NotNull PsiClass aClass) { super.visitClass(aClass); this.visit(aClass); }
|
visitClass
|
12,781
|
void (@NotNull PsiField field) { super.visitField(field); this.visit(field); }
|
visitField
|
12,782
|
void (@NotNull PsiMethod method) { super.visitMethod(method); this.visit(method); }
|
visitMethod
|
12,783
|
void (@NotNull PsiLocalVariable variable) { super.visitLocalVariable(variable); this.visit(variable); }
|
visitLocalVariable
|
12,784
|
void (@NotNull PsiParameter parameter) { super.visitParameter(parameter); this.visit(parameter); }
|
visitParameter
|
12,785
|
void (PsiModifierListOwner psiModifierListOwner) { for (RedundantModifiersInfo redundantModifiersInfo : redundantModifiersInfo) { RedundantModifiersInfoType infoType = redundantModifiersInfo.getType(); PsiModifierListOwner parentModifierListOwner = PsiTreeUtil.getParentOfType(psiModifierListOwner, PsiModifierListOwner.class, infoType != RedundantModifiersInfoType.CLASS && infoType != RedundantModifiersInfoType.VARIABLE); if (parentModifierListOwner == null) { continue; } if (infoType == RedundantModifiersInfoType.VARIABLE && !(parentModifierListOwner instanceof PsiLocalVariable || parentModifierListOwner instanceof PsiParameter) || (infoType != RedundantModifiersInfoType.VARIABLE && !(parentModifierListOwner instanceof PsiClass))) { continue; } if ((supportedAnnotation == null || parentModifierListOwner.hasAnnotation(supportedAnnotation)) && redundantModifiersInfo.getType().getSupportedClass().isAssignableFrom(psiModifierListOwner.getClass())) { PsiModifierList psiModifierList = psiModifierListOwner.getModifierList(); if (psiModifierList == null || (redundantModifiersInfo.getDontRunOnModifier() != null && psiModifierList.hasExplicitModifier(redundantModifiersInfo.getDontRunOnModifier()))) { continue; } if (!redundantModifiersInfo.shouldCheck(psiModifierListOwner)) { continue; } for (String modifier : redundantModifiersInfo.getModifiers()) { if (psiModifierList.hasExplicitModifier(modifier)) { final Optional<PsiElement> psiModifier = Arrays.stream(psiModifierList.getChildren()) .filter(psiElement -> modifier.equals(psiElement.getText())) .findFirst(); psiModifier.ifPresent(psiElement -> holder.registerProblem(psiElement, redundantModifiersInfo.getDescription(), ProblemHighlightType.WARNING, new RemoveModifierFix(modifier)) ); } } } } }
|
visit
|
12,786
|
String[] () { return modifiers; }
|
getModifiers
|
12,787
|
String () { return description; }
|
getDescription
|
12,788
|
String () { return dontRunOnModifier; }
|
getDontRunOnModifier
|
12,789
|
RedundantModifiersInfoType () { return redundantModifiersInfoType; }
|
getType
|
12,790
|
boolean (PsiModifierListOwner psiModifierListOwner) { return true; }
|
shouldCheck
|
12,791
|
PsiExpressionList () { return null; }
|
getArgumentList
|
12,792
|
PsiEnumConstantInitializer () { return null; }
|
getInitializingClass
|
12,793
|
PsiEnumConstantInitializer () { final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject()); return factory.createEnumConstantFromText("foo{}", null).getInitializingClass(); }
|
getOrCreateInitializingClass
|
12,794
|
PsiMethod () { return null; }
|
resolveMethod
|
12,795
|
JavaResolveResult () { return JavaResolveResult.EMPTY; }
|
resolveMethodGenerics
|
12,796
|
PsiMethod () { return null; }
|
resolveConstructor
|
12,797
|
LombokLightModifierList () { return myModifierList; }
|
getModifierList
|
12,798
|
PsiElement () { if (getContainingClass() != null) { return getContainingClass().getScope(); } return super.getScope(); }
|
getScope
|
12,799
|
PsiElement () { return getContainingClass(); }
|
getParent
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.