Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
12,600
|
String () { return variableSettings.getEnteredName(); }
|
getEnteredName
|
12,601
|
boolean () { return variableSettings.isReplaceAllOccurrences(); }
|
isReplaceAllOccurrences
|
12,602
|
boolean () { return variableSettings.isDeclareFinal(); }
|
isDeclareFinal
|
12,603
|
boolean () { return variableSettings.isReplaceLValues(); }
|
isReplaceLValues
|
12,604
|
PsiType () { return psiClassType; }
|
getSelectedType
|
12,605
|
boolean () { return variableSettings.isOK(); }
|
isOK
|
12,606
|
void (@NotNull PsiElement expression, @NotNull Editor editor) { IntroduceVariableHandler handler = new IntroduceLombokVariableHandler(selectedTypeFQN); handler.invoke(expression.getProject(), editor, (PsiExpression) expression); }
|
expandForChooseExpression
|
12,607
|
IntroduceVariableSettings (Project project, Editor editor, PsiExpression expr, PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager, boolean declareFinalIfAll, boolean anyAssignmentLHS, InputValidator validator, PsiElement anchor, JavaReplaceChoice replaceChoice) { final IntroduceVariableSettings variableSettings; if (ApplicationManager.getApplication().isUnitTestMode()) { variableSettings = new UnitTestMockVariableSettings(expr); } else { variableSettings = super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS, validator, anchor, replaceChoice); } return getIntroduceVariableSettings(project, variableSettings); }
|
getSettings
|
12,608
|
IntroduceVariableSettings (Project project, IntroduceVariableSettings variableSettings) { final PsiClassType psiClassType = PsiType.getTypeByName(selectedTypeFQN, project, GlobalSearchScope.projectScope(project)); return new IntroduceVariableSettingsDelegate(variableSettings, psiClassType); }
|
getIntroduceVariableSettings
|
12,609
|
String () { return "foo"; }
|
getEnteredName
|
12,610
|
boolean () { return false; }
|
isReplaceAllOccurrences
|
12,611
|
boolean () { return false; }
|
isDeclareFinal
|
12,612
|
boolean () { return false; }
|
isReplaceLValues
|
12,613
|
PsiType () { return expr.getType(); }
|
getSelectedType
|
12,614
|
boolean () { return true; }
|
isOK
|
12,615
|
boolean (@NotNull PsiElement element) { @Nullable PsiReferenceExpression psiReferenceExpression = PsiTreeUtil.getParentOfType(element, PsiReferenceExpression.class); if (psiReferenceExpression == null) { return false; } PsiElement psiElement = psiReferenceExpression.resolve(); if (!(psiElement instanceof PsiModifierListOwner)) { return false; } return PsiAnnotationSearchUtil.isAnnotatedWith((PsiModifierListOwner) psiElement, LombokClassNames.FIELD_NAME_CONSTANTS); }
|
isFiledNameConstants
|
12,616
|
boolean (@NotNull PsiElement element) { if (!(element instanceof PsiIdentifier)) { return false; } PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class); if (field == null) { return false; } final PsiAnnotation getterAnnotation = PsiAnnotationSearchUtil.findAnnotation(field, LombokClassNames.GETTER); return null != getterAnnotation && PsiAnnotationUtil.getBooleanAnnotationValue(getterAnnotation, "lazy", false); }
|
isLazyGetterHandled
|
12,617
|
boolean (@NotNull PsiElement element) { if (!(element instanceof PsiIdentifier)) { return false; } PsiElement parent = element.getParent(); if (!(parent instanceof PsiReferenceExpression)) { return false; } PsiElement qualifier = ((PsiReferenceExpression) parent).getQualifier(); if (qualifier == null) { return false; } PsiReference reference = qualifier.getReference(); if (reference == null) { return false; } PsiElement field = reference.resolve(); if (!(field instanceof PsiField)) { return false; } PsiClass containingClass = ((PsiField) field).getContainingClass(); if (containingClass == null) { return false; } return InitializationUtils.isInitializedInConstructors((PsiField) field, containingClass); }
|
isInitializedInConstructors
|
12,618
|
boolean (@Nullable PsiElement element, @NotNull PsiClassType exceptionType, PsiElement topElement) { PsiElement parent = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class, PsiTryStatement.class, PsiMethod.class); if (parent instanceof PsiLambdaExpression) { // lambda it's another scope, @SneakyThrows annotation can't neglect exceptions in lambda only on method, constructor return false; } else if (parent instanceof PsiTryStatement && isHandledByTryCatch(exceptionType, (PsiTryStatement) parent)) { // that exception MAY be already handled by regular try-catch statement return false; } if (topElement instanceof PsiTryStatement && isHandledByTryCatch(exceptionType, (PsiTryStatement) topElement)) { // that exception MAY be already handled by regular try-catch statement (don't forget about nested try-catch) return false; } else if (!(topElement instanceof PsiCodeBlock)) { final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class); return psiMethod != null && isExceptionHandled(psiMethod, exceptionType); } return false; }
|
isHandled
|
12,619
|
boolean (@NotNull PsiClassType exceptionType, PsiTryStatement topElement) { List<PsiType> caughtExceptions = ContainerUtil.map(topElement.getCatchBlockParameters(), PsiParameter::getType); return isExceptionHandled(exceptionType, caughtExceptions); }
|
isHandledByTryCatch
|
12,620
|
boolean (@NotNull PsiModifierListOwner psiModifierListOwner, PsiClassType exceptionClassType) { final PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiModifierListOwner, LombokClassNames.SNEAKY_THROWS); if (psiAnnotation == null) { return false; } final Collection<PsiType> sneakedExceptionTypes = PsiAnnotationUtil.getAnnotationValues(psiAnnotation, PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME, PsiType.class); //Default SneakyThrows handles all exceptions return sneakedExceptionTypes.isEmpty() || sneakedExceptionTypes.iterator().next().equalsToText(JAVA_LANG_THROWABLE) || isExceptionHandled(exceptionClassType, sneakedExceptionTypes); }
|
isExceptionHandled
|
12,621
|
boolean (@NotNull PsiClassType exceptionClassType, @NotNull Collection<PsiType> sneakedExceptionTypes) { for (PsiType sneakedExceptionType : sneakedExceptionTypes) { if (sneakedExceptionType.equalsToText(JAVA_LANG_THROWABLE) || sneakedExceptionType.equals(exceptionClassType)) { return true; } } final PsiClass unhandledExceptionClass = exceptionClassType.resolve(); if (null != unhandledExceptionClass) { for (PsiType sneakedExceptionType : sneakedExceptionTypes) { if (sneakedExceptionType instanceof PsiClassType) { final PsiClass sneakedExceptionClass = ((PsiClassType) sneakedExceptionType).resolve(); if (null != sneakedExceptionClass && unhandledExceptionClass.isInheritor(sneakedExceptionClass, true)) { return true; } } } } return false; }
|
isExceptionHandled
|
12,622
|
boolean (HighlightInfo highlightInfo, PsiFile file) { final String description = StringUtil.notNullize(highlightInfo.getDescription()); if (!(ANNOTATION_TYPE_EXPECTED.equals(description) || CANNOT_RESOLVE_SYMBOL_UNDERSCORES_MESSAGE.matcher(description).matches() || CANNOT_RESOLVE_METHOD_UNDERSCORES_MESSAGE.matcher(description).matches())) { return false; } PsiElement highlightedElement = file.findElementAt(highlightInfo.getStartOffset()); PsiNameValuePair nameValuePair = findContainingNameValuePair(highlightedElement); if (nameValuePair == null || !(nameValuePair.getContext() instanceof PsiAnnotationParameterList)) { return false; } String parameterName = nameValuePair.getName(); if (null != parameterName && parameterName.contains("_")) { parameterName = parameterName.substring(0, parameterName.indexOf('_')); } if (!ONX_PARAMETERS.contains(parameterName)) { return false; } PsiElement containingAnnotation = nameValuePair.getContext().getContext(); return containingAnnotation instanceof PsiAnnotation && ONXABLE_ANNOTATIONS.contains(((PsiAnnotation) containingAnnotation).getQualifiedName()); }
|
isOnXParameterAnnotation
|
12,623
|
boolean (HighlightInfo highlightInfo, PsiFile file) { if (!CANNOT_FIND_METHOD_VALUE_MESSAGE.equals(highlightInfo.getDescription())) { return false; } PsiElement highlightedElement = file.findElementAt(highlightInfo.getStartOffset()); PsiNameValuePair nameValuePair = findContainingNameValuePair(highlightedElement); if (nameValuePair == null || !(nameValuePair.getContext() instanceof PsiAnnotationParameterList)) { return false; } PsiElement leftSibling = nameValuePair.getContext().getPrevSibling(); return (leftSibling != null && UNDERSCORES.matcher(StringUtil.notNullize(leftSibling.getText())).matches()); }
|
isOnXParameterValue
|
12,624
|
PsiNameValuePair (PsiElement highlightedElement) { PsiElement nameValuePair = highlightedElement; while (!(nameValuePair == null || nameValuePair instanceof PsiNameValuePair)) { nameValuePair = nameValuePair.getContext(); } return (PsiNameValuePair) nameValuePair; }
|
findContainingNameValuePair
|
12,625
|
boolean (@NotNull PsiElement highlightedElement) { PsiField field = PsiTreeUtil.getParentOfType(highlightedElement, PsiField.class); if (field == null) { return false; } return PsiAnnotationSearchUtil.isAnnotatedWith(field, LombokClassNames.BUILDER_DEFAULT); }
|
isDefaultBuilderValue
|
12,626
|
ActionUpdateThread () { return ActionUpdateThread.BGT; }
|
getActionUpdateThread
|
12,627
|
void (@NotNull AnActionEvent e) { final Project project = e.getProject(); final boolean shouldShow = e.getData(CommonDataKeys.PSI_FILE) instanceof PsiJavaFile && project != null && LombokLibraryUtil.hasLombokLibrary(project); e.getPresentation().setEnabledAndVisible(shouldShow); }
|
update
|
12,628
|
boolean (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { return file.isWritable() && super.isValidForFile(project, editor, file) && LombokLibraryUtil.hasLombokLibrary(project); }
|
isValidForFile
|
12,629
|
void (@NotNull PsiClass psiClass) { LombokProcessorManager manager = LombokProcessorManager.getInstance(); final Collection<AbstractLogProcessor> logProcessors = Arrays.asList( manager.getCommonsLogProcessor(), manager.getJBossLogProcessor(), manager.getLog4jProcessor(), manager.getLog4j2Processor(), manager.getLogProcessor(), manager.getSlf4jProcessor(), manager.getXSlf4jProcessor(), manager.getFloggerProcessor(), manager.getCustomLogProcessor()); final String lombokLoggerName = AbstractLogProcessor.getLoggerName(psiClass); final boolean lombokLoggerIsStatic = AbstractLogProcessor.isLoggerStatic(psiClass); for (AbstractLogProcessor logProcessor : logProcessors) { String loggerType = logProcessor.getLoggerType(psiClass); // null when the custom log's declaration is invalid if (loggerType == null) { continue; } for (PsiField psiField : psiClass.getFields()) { if (psiField.getType().equalsToText(loggerType) && checkLoggerField(psiField, lombokLoggerName, lombokLoggerIsStatic)) { processLoggerField(psiField, psiClass, logProcessor, lombokLoggerName); } } } }
|
processClass
|
12,630
|
void (@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull AbstractLogProcessor logProcessor, @NotNull String lombokLoggerName) { if (!lombokLoggerName.equals(psiField.getName())) { RenameProcessor processor = new RenameProcessor(psiField.getProject(), psiField, lombokLoggerName, false, false); processor.doRun(); } addAnnotation(psiClass, logProcessor.getSupportedAnnotationClasses()[0]); psiField.delete(); }
|
processLoggerField
|
12,631
|
boolean (@NotNull PsiField psiField, @NotNull String lombokLoggerName, boolean lombokLoggerIsStatic) { if (!isValidLoggerField(psiField, lombokLoggerName, lombokLoggerIsStatic)) { String messageText = LombokBundle.message("dialog.message.logger.field.s.not.private.sfinal.field.named.s.refactor.anyway", psiField.getName(), lombokLoggerIsStatic ? 1 : 0, lombokLoggerName); int result = Messages.showOkCancelDialog(messageText, LombokBundle.message("dialog.title.attention"), Messages.getOkButton(), Messages.getCancelButton(), Messages.getQuestionIcon()); return DialogWrapper.OK_EXIT_CODE == result; } return true; }
|
checkLoggerField
|
12,632
|
boolean (@NotNull PsiField psiField, @NotNull String lombokLoggerName, boolean lombokLoggerIsStatic) { boolean isPrivate = psiField.hasModifierProperty(PsiModifier.PRIVATE); boolean isStatic = lombokLoggerIsStatic == psiField.hasModifierProperty(PsiModifier.STATIC); boolean isFinal = psiField.hasModifierProperty(PsiModifier.FINAL); boolean isProperlyNamed = lombokLoggerName.equals(psiField.getName()); return isPrivate && isStatic && isFinal && isProperlyNamed; }
|
isValidLoggerField
|
12,633
|
void (@NotNull PsiClass psiClass) { final Map<PsiField, PsiMethod> fieldMethodMap = new HashMap<>(); for (PsiField psiField : psiClass.getFields()) { PsiMethod propertySetter = PropertyUtilBase.findPropertySetter(psiClass, psiField.getName(), psiField.hasModifierProperty(PsiModifier.STATIC), false); if (null != propertySetter) { fieldMethodMap.put(psiField, propertySetter); } } processIntern(fieldMethodMap, psiClass, LombokClassNames.SETTER); }
|
processClass
|
12,634
|
void (@NotNull PsiClass psiClass) { final PsiMethod equalsMethod = findPublicNonStaticMethod(psiClass, "equals", PsiTypes.booleanType(), PsiType.getJavaLangObject(psiClass.getManager(), psiClass.getResolveScope())); if (null != equalsMethod) { equalsMethod.delete(); } final PsiMethod hashCodeMethod = findPublicNonStaticMethod(psiClass, "hashCode", PsiTypes.intType()); if (null != hashCodeMethod) { hashCodeMethod.delete(); } addAnnotation(psiClass, LombokClassNames.EQUALS_AND_HASHCODE); }
|
processClass
|
12,635
|
void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (file.isWritable()) { PsiClass psiClass = OverrideImplementUtil.getContextClass(project, editor, file, false); if (null != psiClass) { processClass(psiClass); UndoUtil.markPsiFileForUndo(file); } } }
|
invoke
|
12,636
|
void (@NotNull Map<PsiField, PsiMethod> fieldMethodMap, @NotNull PsiClass psiClass, String annotationClassName) { if (fieldMethodMap.isEmpty()) { return; } final PsiMethod firstPropertyMethod = fieldMethodMap.values().iterator().next(); final boolean useAnnotationOnClass = haveAllMethodsSameAccessLevel(fieldMethodMap.values()) && isNotAnnotatedWithOrSameAccessLevelAs(psiClass, firstPropertyMethod, annotationClassName); if (useAnnotationOnClass) { addAnnotation(psiClass, firstPropertyMethod, annotationClassName); } for (Map.Entry<PsiField, PsiMethod> fieldMethodEntry : fieldMethodMap.entrySet()) { final PsiField propertyField = fieldMethodEntry.getKey(); final PsiMethod propertyMethod = fieldMethodEntry.getValue(); if (null != propertyField) { boolean isStatic = propertyField.hasModifierProperty(PsiModifier.STATIC); if (isStatic || !useAnnotationOnClass) { addAnnotation(propertyField, propertyMethod, annotationClassName); } // Move all annotations to field declaration for (PsiAnnotation psiMethodAnnotation : propertyMethod.getModifierList().getAnnotations()) { psiClass.addBefore(psiMethodAnnotation, propertyField); } propertyMethod.delete(); } } }
|
processIntern
|
12,637
|
boolean (PsiClass psiClass, PsiMethod firstPropertyMethod, String annotationClassName) { final PsiAnnotation presentAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiClass, annotationClassName); if (null != presentAnnotation) { final String presentAccessModifier = LombokProcessorUtil.getMethodModifier(presentAnnotation); final String currentAccessModifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(firstPropertyMethod.getModifierList())); return presentAccessModifier != null && presentAccessModifier.equals(currentAccessModifier); } return true; }
|
isNotAnnotatedWithOrSameAccessLevelAs
|
12,638
|
boolean (Collection<PsiMethod> psiMethods) { final Set<Integer> accessLevelSet = new HashSet<>(); for (PsiMethod psiMethod : psiMethods) { accessLevelSet.add(PsiUtil.getAccessLevel(psiMethod.getModifierList())); } return accessLevelSet.size() <= 1; }
|
haveAllMethodsSameAccessLevel
|
12,639
|
void (@NotNull PsiModifierListOwner targetElement, @NotNull PsiModifierListOwner sourceElement, String annotationClassName) { final PsiAnnotation newPsiAnnotation = LombokProcessorUtil.createAnnotationWithAccessLevel(sourceElement, annotationClassName); addAnnotation(targetElement, newPsiAnnotation, annotationClassName); }
|
addAnnotation
|
12,640
|
void (@NotNull PsiClass targetElement, String annotationClassName) { final PsiAnnotation newPsiAnnotation = PsiAnnotationUtil.createPsiAnnotation(targetElement, annotationClassName); addAnnotation(targetElement, newPsiAnnotation, annotationClassName); }
|
addAnnotation
|
12,641
|
void (@NotNull PsiModifierListOwner targetElement, @NotNull PsiAnnotation newPsiAnnotation, String annotationClassName) { final PsiAnnotation presentAnnotation = PsiAnnotationSearchUtil.findAnnotation(targetElement, annotationClassName); final Project project = targetElement.getProject(); final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project); javaCodeStyleManager.shortenClassReferences(newPsiAnnotation); if (null == presentAnnotation) { PsiModifierList modifierList = targetElement.getModifierList(); if (null != modifierList) { modifierList.addAfter(newPsiAnnotation, null); } } else { presentAnnotation.setDeclaredAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME, newPsiAnnotation.findDeclaredAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME)); } }
|
addAnnotation
|
12,642
|
void (@NotNull PsiModifierListOwner targetElement, String annotationClassName) { final PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(targetElement, annotationClassName); if (null != psiAnnotation) { boolean hasOnlyDefaultValues = true; final PsiAnnotationParameterList psiAnnotationParameterList = psiAnnotation.getParameterList(); for (PsiNameValuePair nameValuePair : psiAnnotationParameterList.getAttributes()) { if (null != psiAnnotation.findDeclaredAttributeValue(nameValuePair.getName())) { hasOnlyDefaultValues = false; break; } } if (hasOnlyDefaultValues) { psiAnnotation.delete(); } } }
|
removeDefaultAnnotation
|
12,643
|
PsiMethod (@NotNull PsiClass psiClass, @NotNull String methodName, @NotNull PsiType returnType, PsiType... params) { final PsiMethod[] toStringMethods = psiClass.findMethodsByName(methodName, false); for (PsiMethod method : toStringMethods) { if (method.hasModifierProperty(PsiModifier.PUBLIC) && !method.hasModifierProperty(PsiModifier.STATIC) && returnType.equals(method.getReturnType())) { final PsiParameterList parameterList = method.getParameterList(); final PsiParameter[] psiParameters = parameterList.getParameters(); final int paramsCount = params.length; if (psiParameters.length == paramsCount) { boolean allParametersFound = true; for (int i = 0; i < paramsCount; i++) { if (!psiParameters[i].getType().equals(params[i])) { allParametersFound = false; break; } } if (allParametersFound) { return method; } } } } return null; }
|
findPublicNonStaticMethod
|
12,644
|
void (@NotNull PsiClass psiClass) { final PsiElementFactory factory = JavaPsiFacade.getElementFactory(psiClass.getProject()); final PsiClassType stringClassType = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_STRING, psiClass.getResolveScope()); final PsiMethod toStringMethod = findPublicNonStaticMethod(psiClass, "toString", stringClassType); if (null != toStringMethod) { toStringMethod.delete(); } addAnnotation(psiClass, LombokClassNames.TO_STRING); }
|
processClass
|
12,645
|
void (@NotNull PsiClass psiClass) { final Map<PsiField, PsiMethod> fieldMethodMap = new HashMap<>(); for (PsiField psiField : psiClass.getFields()) { PsiMethod propertyGetter = PropertyUtilBase.findPropertyGetter(psiClass, psiField.getName(), psiField.hasModifierProperty(PsiModifier.STATIC), false); if (null != propertyGetter) { fieldMethodMap.put(psiField, propertyGetter); } } processIntern(fieldMethodMap, psiClass, LombokClassNames.GETTER); }
|
processClass
|
12,646
|
void (@NotNull PsiClass psiClass) { for (BaseLombokHandler handler : handlers) { handler.processClass(psiClass); } removeDefaultAnnotation(psiClass, LombokClassNames.GETTER); removeDefaultAnnotation(psiClass, LombokClassNames.SETTER); removeDefaultAnnotation(psiClass, LombokClassNames.TO_STRING); removeDefaultAnnotation(psiClass, LombokClassNames.EQUALS_AND_HASHCODE); addAnnotation(psiClass, LombokClassNames.DATA); }
|
processClass
|
12,647
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler( manager.getWitherProcessor(), manager.getWitherFieldProcessor()); }
|
createHandler
|
12,648
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler( manager.getCommonsLogProcessor(), manager.getJBossLogProcessor(), manager.getLog4jProcessor(), manager.getLog4j2Processor(), manager.getLogProcessor(), manager.getSlf4jProcessor(), manager.getXSlf4jProcessor(), manager.getFloggerProcessor(), manager.getCustomLogProcessor()); }
|
createHandler
|
12,649
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler( manager.getAllArgsConstructorProcessor(), manager.getNoArgsConstructorProcessor(), manager.getRequiredArgsConstructorProcessor()); }
|
createHandler
|
12,650
|
DelombokHandler () { return new DelombokHandler(true, LombokProcessorManager.getInstance().getStandardExceptionProcessor()); }
|
createHandler
|
12,651
|
ActionUpdateThread () { return ActionUpdateThread.BGT; }
|
getActionUpdateThread
|
12,652
|
DelombokHandler () { if (null == myHandler) { myHandler = createHandler(); } return myHandler; }
|
getHandler
|
12,653
|
void (@NotNull AnActionEvent event) { final Project project = event.getProject(); if (project == null) { return; } final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); psiDocumentManager.commitAllDocuments(); final DataContext dataContext = event.getDataContext(); final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (null != editor) { final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project); if (null != psiFile) { final PsiClass targetClass = getTargetClass(editor, psiFile); if (null != targetClass) { process(project, psiFile, targetClass); } } } else { final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); if (null != files) { for (VirtualFile file : files) { if (file.isDirectory()) { processDirectory(project, file); } else { processFile(project, file); } } } } }
|
actionPerformed
|
12,654
|
void (@NotNull final Project project, @NotNull VirtualFile vFile) { VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor<Void>() { @Override public boolean visitFile(@NotNull VirtualFile file) { if (!file.isDirectory()) { processFile(project, file); } return true; } }); }
|
processDirectory
|
12,655
|
boolean (@NotNull VirtualFile file) { if (!file.isDirectory()) { processFile(project, file); } return true; }
|
visitFile
|
12,656
|
void (Project project, VirtualFile file) { if (JavaFileType.INSTANCE.equals(file.getFileType())) { final PsiManager psiManager = PsiManager.getInstance(project); PsiJavaFile psiFile = (PsiJavaFile) psiManager.findFile(file); if (psiFile != null) { process(project, psiFile); } } }
|
processFile
|
12,657
|
void (@NotNull final Project project, @NotNull final PsiJavaFile psiJavaFile) { executeCommand(project, () -> getHandler().invoke(project, psiJavaFile)); }
|
process
|
12,658
|
void (@NotNull final Project project, @NotNull final PsiFile psiFile, @NotNull final PsiClass psiClass) { executeCommand(project, () -> getHandler().invoke(project, psiFile, psiClass)); }
|
process
|
12,659
|
void (final Project project, final Runnable action) { CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(action), getCommandName(), null); }
|
executeCommand
|
12,660
|
void (@NotNull AnActionEvent event) { final Presentation presentation = event.getPresentation(); final DataContext dataContext = event.getDataContext(); final Project project = event.getProject(); if (project == null || !LombokLibraryUtil.hasLombokLibrary(project)) { presentation.setEnabled(false); return; } final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (null != editor) { final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); presentation.setEnabled(file != null && isValidForFile(editor, file)); return; } boolean isValid = false; final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); if (null != files) { PsiManager psiManager = PsiManager.getInstance(project); for (VirtualFile file : files) { if (file.isDirectory()) { //directory is valid isValid = true; break; } if (JavaFileType.INSTANCE.equals(file.getFileType())) { PsiJavaFile psiFile = (PsiJavaFile) psiManager.findFile(file); if (psiFile != null) { isValid = ContainerUtil.or(psiFile.getClasses(), this::isValidForClass); } } if (isValid) { break; } } } presentation.setEnabled(isValid); }
|
update
|
12,661
|
boolean (@NotNull PsiClass psiClass) { if (psiClass.isInterface()) { return false; } Collection<PsiAnnotation> psiAnnotations = getHandler().collectProcessableAnnotations(psiClass); if (!psiAnnotations.isEmpty()) { return true; } final Collection<PsiClass> classesIntern = PsiClassUtil.collectInnerClassesIntern(psiClass); return ContainerUtil.exists(classesIntern, this::isValidForClass); }
|
isValidForClass
|
12,662
|
PsiClass (Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); if (element == null) { return null; } final PsiClass target = PsiTreeUtil.getParentOfType(element, PsiClass.class); return target instanceof SyntheticElement ? null : target; }
|
getTargetClass
|
12,663
|
boolean (@NotNull Editor editor, @NotNull PsiFile file) { if (!(file instanceof PsiJavaFile)) { return false; } if (file instanceof PsiCompiledElement) { return false; } if (!file.isWritable()) { return false; } PsiClass targetClass = getTargetClass(editor, file); return targetClass != null && isValidForClass(targetClass); }
|
isValidForFile
|
12,664
|
String () { String text = getTemplatePresentation().getText(); return text == null ? "" : text; }
|
getCommandName
|
12,665
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler(true, manager.getBuilderPreDefinedInnerClassFieldProcessor(), manager.getBuilderPreDefinedInnerClassMethodProcessor(), manager.getBuilderClassProcessor(), manager.getBuilderClassMethodProcessor(), manager.getBuilderMethodProcessor(), manager.getBuilderProcessor()); }
|
createHandler
|
12,666
|
DelombokHandler () { return new DelombokHandler(LombokProcessorManager.getInstance().getEqualsAndHashCodeProcessor()); }
|
createHandler
|
12,667
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler(true, manager.getFieldNameConstantsOldProcessor(), manager.getFieldNameConstantsFieldProcessor(), manager.getFieldNameConstantsProcessor(), manager.getFieldNameConstantsPredefinedInnerClassFieldProcessor()); }
|
createHandler
|
12,668
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler( manager.getGetterProcessor(), manager.getGetterFieldProcessor()); }
|
createHandler
|
12,669
|
DelombokHandler () { return new DelombokHandler(LombokProcessorManager.getInstance().getToStringProcessor()); }
|
createHandler
|
12,670
|
DelombokHandler () { return new DelombokHandler(true, LombokProcessorManager.getInstance().getUtilityClassProcessor()); }
|
createHandler
|
12,671
|
DelombokHandler () { return new DelombokHandler(LombokProcessorManager.getInstance().getDataProcessor()); }
|
createHandler
|
12,672
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler( manager.getSetterProcessor(), manager.getSetterFieldProcessor()); }
|
createHandler
|
12,673
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler(true, manager.getRequiredArgsConstructorProcessor(), manager.getAllArgsConstructorProcessor(), manager.getNoArgsConstructorProcessor(), manager.getDataProcessor(), manager.getGetterProcessor(), manager.getValueProcessor(), manager.getWitherProcessor(), manager.getSetterProcessor(), manager.getEqualsAndHashCodeProcessor(), manager.getToStringProcessor(), manager.getCommonsLogProcessor(), manager.getJBossLogProcessor(), manager.getLog4jProcessor(), manager.getLog4j2Processor(), manager.getLogProcessor(), manager.getSlf4jProcessor(), manager.getXSlf4jProcessor(), manager.getFloggerProcessor(), manager.getCustomLogProcessor(), manager.getGetterFieldProcessor(), manager.getSetterFieldProcessor(), manager.getWitherFieldProcessor(), manager.getDelegateFieldProcessor(), manager.getDelegateMethodProcessor(), manager.getFieldNameConstantsOldProcessor(), manager.getFieldNameConstantsFieldProcessor(), manager.getFieldNameConstantsProcessor(), manager.getFieldNameConstantsPredefinedInnerClassFieldProcessor(), manager.getUtilityClassProcessor(), manager.getStandardExceptionProcessor(), manager.getBuilderPreDefinedInnerClassFieldProcessor(), manager.getBuilderPreDefinedInnerClassMethodProcessor(), manager.getBuilderClassProcessor(), manager.getBuilderClassMethodProcessor(), manager.getBuilderMethodProcessor(), manager.getBuilderProcessor(), manager.getSuperBuilderPreDefinedInnerClassFieldProcessor(), manager.getSuperBuilderPreDefinedInnerClassMethodProcessor(), manager.getSuperBuilderClassProcessor(), manager.getSuperBuilderProcessor()); }
|
createHandler
|
12,674
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler( manager.getDelegateFieldProcessor(), manager.getDelegateMethodProcessor()); }
|
createHandler
|
12,675
|
DelombokHandler () { LombokProcessorManager manager = LombokProcessorManager.getInstance(); return new DelombokHandler(true, manager.getSuperBuilderPreDefinedInnerClassFieldProcessor(), manager.getSuperBuilderPreDefinedInnerClassMethodProcessor(), manager.getSuperBuilderClassProcessor(), manager.getSuperBuilderProcessor()); }
|
createHandler
|
12,676
|
DelombokHandler () { return new DelombokHandler(LombokProcessorManager.getInstance().getValueProcessor()); }
|
createHandler
|
12,677
|
void (@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiClass psiClass) { if (psiFile.isWritable()) { invoke(project, psiClass, processInnerClasses); finish(project, psiFile); } }
|
invoke
|
12,678
|
void (@NotNull Project project, @NotNull PsiJavaFile psiFile) { for (PsiClass psiClass : psiFile.getClasses()) { invoke(project, psiClass, true); } finish(project, psiFile); }
|
invoke
|
12,679
|
void (Project project, PsiClass psiClass, boolean processInnerClasses) { Collection<PsiAnnotation> processedAnnotations = new HashSet<>(); processModifierList(psiClass); // get all inner classes before first lombok processing final PsiClass[] allInnerClasses = psiClass.getAllInnerClasses(); for (AbstractProcessor lombokProcessor : lombokProcessors) { processedAnnotations.addAll(processClass(project, psiClass, lombokProcessor)); } postProcessAugmentedAnnotations(psiClass); CodeStyleManager.getInstance(project).reformat(psiClass); if (processInnerClasses) { for (PsiClass innerClass : allInnerClasses) { //skip our self generated classes if (!(innerClass instanceof LombokLightClassBuilder)) { invoke(project, innerClass, true); } } } processedAnnotations.forEach(PsiAnnotation::delete); }
|
invoke
|
12,680
|
void (Project project, PsiFile psiFile) { JavaCodeStyleManager.getInstance(project).optimizeImports(psiFile); UndoUtil.markPsiFileForUndo(psiFile); }
|
finish
|
12,681
|
Collection<PsiAnnotation> (@NotNull Project project, @NotNull PsiClass psiClass, @NotNull AbstractProcessor lombokProcessor) { Collection<PsiAnnotation> psiAnnotations = lombokProcessor.collectProcessedAnnotations(psiClass); final List<? super PsiElement> psiElements = lombokProcessor.process(psiClass); if (lombokProcessor instanceof FieldNameConstantsPredefinedInnerClassFieldProcessor) { rebuildElementsBeforeExistingFields(project, psiClass, psiElements); } else { rebuildElements(project, psiClass, psiElements); } return psiAnnotations; }
|
processClass
|
12,682
|
void (@NotNull PsiClass psiClass) { rebuildModifierList(psiClass); PsiClassUtil.collectClassFieldsIntern(psiClass).forEach(DelombokHandler::rebuildModifierList); PsiClassUtil.collectClassMethodsIntern(psiClass).forEach(DelombokHandler::rebuildModifierList); PsiClassUtil.collectClassStaticMethodsIntern(psiClass).forEach(DelombokHandler::rebuildModifierList); }
|
processModifierList
|
12,683
|
void (@NotNull PsiModifierListOwner modifierListOwner) { final PsiModifierList modifierList = modifierListOwner.getModifierList(); if (null != modifierList) { final Set<String> lombokModifiers = new HashSet<>(); LombokProcessorManager.getLombokModifierProcessors().forEach(modifierProcessor -> { if (modifierProcessor.isSupported(modifierList)) { modifierProcessor.transformModifiers(modifierList, lombokModifiers); lombokModifiers.forEach(modifier -> modifierList.setModifierProperty(modifier, true)); lombokModifiers.clear(); } }); } }
|
rebuildModifierList
|
12,684
|
void (@NotNull PsiModifierListOwner psiModifierListOwner) { final Collection<String> augmentedAnnotations = psiModifierListOwner.getUserData(LombokUserDataKeys.AUGMENTED_ANNOTATIONS); final PsiModifierList psiModifierList = psiModifierListOwner.getModifierList(); if (null != augmentedAnnotations && !augmentedAnnotations.isEmpty() && psiModifierList != null) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiModifierListOwner.getProject()); for (String augmentedAnnotation : augmentedAnnotations) { psiModifierList.addAfter(elementFactory.createAnnotationFromText(augmentedAnnotation, psiModifierListOwner), null); } } }
|
postProcessAugmentedAnnotations
|
12,685
|
void (Project project, PsiClass psiClass, List<? super PsiElement> psiElements) { //add generated elements in generated/declaration order, but before existing Fields if (!psiElements.isEmpty()) { final PsiField existingField = PsiClassUtil.collectClassFieldsIntern(psiClass).stream().findFirst().orElse(null); Iterator<? super PsiElement> iterator = psiElements.iterator(); PsiElement prev = psiClass.addBefore(rebuildPsiElement(project, (PsiElement)iterator.next()), existingField); while (iterator.hasNext()) { PsiElement curr = rebuildPsiElement(project, (PsiElement)iterator.next()); if (curr != null) { prev = psiClass.addAfter(curr, prev); } } } }
|
rebuildElementsBeforeExistingFields
|
12,686
|
void (Project project, PsiClass psiClass, List<? super PsiElement> psiElements) { for (Object psiElement : psiElements) { final PsiElement element = rebuildPsiElement(project, (PsiElement)psiElement); if (null != element) { psiClass.add(element); } } }
|
rebuildElements
|
12,687
|
Collection<PsiAnnotation> (@NotNull PsiClass psiClass) { Collection<PsiAnnotation> result = new ArrayList<>(); for (AbstractProcessor lombokProcessor : lombokProcessors) { result.addAll(lombokProcessor.collectProcessedAnnotations(psiClass)); } return result; }
|
collectProcessableAnnotations
|
12,688
|
PsiElement (@NotNull Project project, PsiElement psiElement) { if (psiElement instanceof PsiMethod) { return rebuildMethod(project, (PsiMethod)psiElement); } else if (psiElement instanceof PsiField) { return rebuildField(project, (PsiField)psiElement); } else if (psiElement instanceof PsiClass) { if (((PsiClass)psiElement).isEnum()) { return rebuildEnum(project, (PsiClass)psiElement); } else { return rebuildClass(project, (PsiClass)psiElement); } } return null; }
|
rebuildPsiElement
|
12,689
|
PsiClass (@NotNull Project project, @NotNull PsiClass fromClass) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); final PsiClass resultClass = elementFactory.createEnum(StringUtil.defaultIfEmpty(fromClass.getName(), "UnknownClassName")); copyModifiers(fromClass.getModifierList(), resultClass.getModifierList()); rebuildTypeParameter(fromClass, resultClass); final List<PsiField> fields = Arrays.asList(fromClass.getFields()); if (!fields.isEmpty()) { final Iterator<PsiField> iterator = fields.iterator(); PsiElement prev = resultClass.add(rebuildField(project, iterator.next())); while (iterator.hasNext()) { PsiField curr = iterator.next(); //guarantees order of enum constants, should match declaration order prev = resultClass.addAfter(rebuildField(project, curr), prev); } } for (PsiMethod psiMethod : fromClass.getMethods()) { final String psiMethodName = psiMethod.getName(); //skip Enum virtual methods if ("values".equals(psiMethodName) || "valueOf".equals(psiMethodName)) { continue; } resultClass.add(rebuildMethod(project, psiMethod)); } return resultClass; }
|
rebuildEnum
|
12,690
|
PsiClass (@NotNull Project project, @NotNull PsiClass fromClass) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiClass resultClass = elementFactory.createClass(StringUtil.defaultIfEmpty(fromClass.getName(), "UnknownClassName")); copyModifiers(fromClass.getModifierList(), resultClass.getModifierList()); copyAnnotations(fromClass.getModifierList(), resultClass.getModifierList()); rebuildTypeParameter(fromClass, resultClass); // rebuild extends part final PsiReferenceList extendsList = fromClass.getExtendsList(); final PsiReferenceList resultExtendsList = resultClass.getExtendsList(); if (null != extendsList && null != resultExtendsList) { Stream.of(extendsList.getReferencedTypes()).map(elementFactory::createReferenceElementByType).forEach(resultExtendsList::add); } for (PsiField psiField : fromClass.getFields()) { resultClass.add(rebuildField(project, psiField)); } for (PsiMethod psiMethod : fromClass.getMethods()) { resultClass.add(rebuildMethod(project, psiMethod)); } return resultClass; }
|
rebuildClass
|
12,691
|
PsiMethod (@NotNull Project project, @NotNull PsiMethod fromMethod) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); final PsiMethod resultMethod; final PsiType returnType = fromMethod.getReturnType(); if (null == returnType) { resultMethod = elementFactory.createConstructor(fromMethod.getName()); } else { resultMethod = elementFactory.createMethod(fromMethod.getName(), returnType); } rebuildTypeParameter(fromMethod, resultMethod); final PsiClassType[] referencedTypes = fromMethod.getThrowsList().getReferencedTypes(); if (referencedTypes.length > 0) { PsiJavaCodeReferenceElement[] refs = new PsiJavaCodeReferenceElement[referencedTypes.length]; for (int i = 0; i < refs.length; i++) { refs[i] = elementFactory.createReferenceElementByType(referencedTypes[i]); } resultMethod.getThrowsList().replace(elementFactory.createReferenceList(refs)); } for (PsiParameter fromParameter : fromMethod.getParameterList().getParameters()) { PsiParameter toParameter = elementFactory.createParameter(fromParameter.getName(), fromParameter.getType()); final PsiModifierList fromParameterModifierList = fromParameter.getModifierList(); if (fromParameterModifierList != null) { final PsiModifierList toParameterModifierList = toParameter.getModifierList(); copyAnnotations(fromParameterModifierList, toParameterModifierList); toParameterModifierList.setModifierProperty(PsiModifier.FINAL, fromParameterModifierList.hasModifierProperty(PsiModifier.FINAL)); } resultMethod.getParameterList().add(toParameter); } final PsiModifierList fromMethodModifierList = fromMethod.getModifierList(); final PsiModifierList resultMethodModifierList = resultMethod.getModifierList(); copyModifiers(fromMethodModifierList, resultMethodModifierList); copyAnnotations(fromMethodModifierList, resultMethodModifierList); PsiCodeBlock body = fromMethod.getBody(); if (null != body) { resultMethod.getBody().replace(body); } else { resultMethod.getBody().delete(); } return resultMethod; }
|
rebuildMethod
|
12,692
|
void (@NotNull PsiModifierList fromModifierList, @NotNull PsiModifierList toModifierList) { for (PsiAnnotation originalAnnotation : fromModifierList.getAnnotations()) { final String annotationQualifiedName = originalAnnotation.getQualifiedName(); if (!StringUtil.isEmptyOrSpaces(annotationQualifiedName)) { AddAnnotationPsiFix.addPhysicalAnnotationIfAbsent(annotationQualifiedName, originalAnnotation.getParameterList().getAttributes(), toModifierList); } } }
|
copyAnnotations
|
12,693
|
void (@NotNull PsiTypeParameterListOwner listOwner, @NotNull PsiTypeParameterListOwner resultOwner) { final PsiTypeParameterList resultOwnerTypeParameterList = resultOwner.getTypeParameterList(); if (null != resultOwnerTypeParameterList) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(resultOwner.getProject()); for (PsiTypeParameter typeParameter : listOwner.getTypeParameters()) { String typeParameterAsString = getTypeParameterAsString(typeParameter); resultOwnerTypeParameterList.add(elementFactory.createTypeParameterFromText(typeParameterAsString, resultOwner)); } } }
|
rebuildTypeParameter
|
12,694
|
String (@NotNull PsiTypeParameter typeParameter) { final PsiClassType[] referencedTypes = typeParameter.getExtendsList().getReferencedTypes(); String extendsText = ""; if (referencedTypes.length > 0) { extendsText = Stream.of(referencedTypes).map(DelombokHandler::getTypeWithParameter) .collect(Collectors.joining(" & ", " extends ", "")); } return typeParameter.getName() + extendsText; }
|
getTypeParameterAsString
|
12,695
|
String (@NotNull PsiClassType psiClassType) { if (psiClassType instanceof PsiClassReferenceType) { return ((PsiClassReferenceType)psiClassType).getReference().getText(); } return psiClassType.getName(); }
|
getTypeWithParameter
|
12,696
|
void (PsiModifierList fromModifierList, PsiModifierList resultModifierList) { for (String modifier : PsiModifier.MODIFIERS) { resultModifierList.setModifierProperty(modifier, fromModifierList.hasExplicitModifier(modifier)); } }
|
copyModifiers
|
12,697
|
PsiField (@NotNull Project project, @NotNull PsiField fromField) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); final PsiField resultField; if (fromField instanceof PsiEnumConstant) { resultField = elementFactory.createEnumConstantFromText(fromField.getName(), fromField.getContext()); } else { resultField = elementFactory.createField(fromField.getName(), fromField.getType()); resultField.setInitializer(fromField.getInitializer()); } copyModifiers(fromField.getModifierList(), resultField.getModifierList()); return resultField; }
|
rebuildField
|
12,698
|
boolean (PsiElement element) { return element instanceof LombokLightMethodBuilder && element.getLanguage() == JavaLanguage.INSTANCE; }
|
canInlineElement
|
12,699
|
void (final Project project, Editor editor, PsiElement element) { performInline(project, editor, (PsiMethod) element, true); }
|
inlineElement
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.