}
protected CompilationLog rebuild() {
- return compile(false, compileStatusNotification -> {
- getCompilerManager().rebuild(compileStatusNotification);
- });
+ return compile(false, compileStatusNotification -> getCompilerManager().rebuild(compileStatusNotification));
}
protected CompilationLog compile(final boolean errorsExpected, final ParameterizedRunnable<CompileStatusNotification> action) {
process.getManagerThread().invoke(new DebuggerCommandImpl() {
protected void action() throws Exception {
final List<ThreadState> threads = ThreadDumpAction.buildThreadStates(process.getVirtualMachineProxy());
- ApplicationManager.getApplication().invokeLater(() -> {
- ExportToTextFileAction.export(project, ThreadDumpPanel.createToFileExporter(project, threads));
- }, ModalityState.NON_MODAL);
+ ApplicationManager.getApplication().invokeLater(() -> ExportToTextFileAction.export(project, ThreadDumpPanel.createToFileExporter(project, threads)), ModalityState.NON_MODAL);
}
});
}
}
private static void showError(final Project project, final String message) {
- ApplicationManager.getApplication().invokeLater(() -> {
- Messages.showMessageDialog(project,
- message,
- UIUtil.removeMnemonic(ActionsBundle.actionText("Debugger.ForceEarlyReturn")),
- Messages.getErrorIcon());
- }, ModalityState.any());
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(project,
+ message,
+ UIUtil.removeMnemonic(ActionsBundle.actionText("Debugger.ForceEarlyReturn")),
+ Messages.getErrorIcon()), ModalityState.any());
}
public void update(@NotNull AnActionEvent e) {
@Override
public void threadAction() {
- ApplicationManager.getApplication().runReadAction(() -> {
- positionRef.set(SourcePositionProvider.getSourcePosition(selectedNode.getDescriptor(), project, debuggerContext));
- });
+ ApplicationManager.getApplication().runReadAction(() -> positionRef.set(SourcePositionProvider.getSourcePosition(selectedNode.getDescriptor(), project, debuggerContext)));
}
});
final SourcePosition sourcePosition = positionRef.get();
final SourcePosition sourcePosition = debuggerContext.getSourcePosition();
final Map<String, LocalVariableProxyImpl> visibleVariables =
ContainerUtil.map2Map(getVisibleVariables(),
- var -> {
- return Pair.create(var.name(), var);
- });
+ var -> Pair.create(var.name(), var));
Pair<Set<String>, Set<TextWithImports>> usedVars = EMPTY_USED_VARS;
if (sourcePosition != null) {
@Override
protected void doAction(@Nullable final SourcePosition sourcePosition) {
if (sourcePosition != null) {
- ApplicationManager.getApplication().runReadAction(() -> {
- navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(sourcePosition));
- });
+ ApplicationManager.getApplication().runReadAction(() -> navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(sourcePosition)));
}
}
});
ComboBoxClassElement[] elems = ContainerUtil.map2Array(alts,
ComboBoxClassElement.class,
- psiClass -> {
- return new ComboBoxClassElement((PsiClass)psiClass.getNavigationElement());
- });
+ psiClass -> new ComboBoxClassElement((PsiClass)psiClass.getNavigationElement()));
return new AlternativeSourceNotificationPanel(elems, baseClass, myProject, file);
}
if (breakpoint == null) {
return;
}
- ApplicationManager.getApplication().runWriteAction(() -> {
- getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint));
}
public void writeExternal(@NotNull final Element parentNode) {
if (element instanceof PsiClass && PsiMethodUtil.findMainInClass((PsiClass)element) != null ||
element instanceof PsiMethod && "main".equals(((PsiMethod)element).getName()) && PsiMethodUtil.isMainMethod((PsiMethod)element)) {
final AnAction[] actions = ExecutorAction.getActions(0);
- return new Info(AllIcons.RunConfigurations.TestState.Run, element1 -> StringUtil.join(ContainerUtil.mapNotNull(actions, action -> {
- return getText(action, element1);
- }), "\n"), actions);
+ return new Info(AllIcons.RunConfigurations.TestState.Run, element1 -> StringUtil.join(ContainerUtil.mapNotNull(actions, action -> getText(action, element1)), "\n"), actions);
}
}
return null;
}
private void showThreadDump(final String out, final List<ThreadState> threadStates) {
- ApplicationManager.getApplication().invokeLater(() -> {
- AnalyzeStacktraceUtil.addConsole(myProject, threadStates.size() > 1 ?
- new ThreadDumpConsoleFactory(myProject, threadStates) : null,
- "<Stacktrace> " + DateFormatUtil.formatDateTime(System.currentTimeMillis()), out);
- }, ModalityState.NON_MODAL);
+ ApplicationManager.getApplication().invokeLater(() -> AnalyzeStacktraceUtil.addConsole(myProject, threadStates.size() > 1 ?
+ new ThreadDumpConsoleFactory(myProject, threadStates) : null,
+ "<Stacktrace> " + DateFormatUtil.formatDateTime(System.currentTimeMillis()), out), ModalityState.NON_MODAL);
}
}
final TestDiscoveryIndex coverageIndex = TestDiscoveryIndex.getInstance(configuration.getProject());
synchronized (ourTracesLock) {
final File tracesDirectoryFile = new File(tracesDirectory);
- final File[] testMethodTraces = tracesDirectoryFile.listFiles((dir, name) -> {
- return name.endsWith(".tr");
- });
+ final File[] testMethodTraces = tracesDirectoryFile.listFiles((dir, name) -> name.endsWith(".tr"));
if (testMethodTraces != null) {
for (File testMethodTrace : testMethodTraces) {
try {
final Sdk jdk = dialog.getNewProjectJdk();
if (jdk != null) {
- CommandProcessor.getInstance().executeCommand(newProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
- applyJdkToProject(newProject, jdk);
- }), null, null);
+ CommandProcessor.getInstance().executeCommand(newProject, () -> ApplicationManager.getApplication().runWriteAction(() -> applyJdkToProject(newProject, jdk)), null, null);
}
final String compileOutput = dialog.getNewCompileOutput();
return o1.compareTo(o2);
});
- Set<String> groupNames = ContainerUtil.map2Set(groups, group -> {
- return group.getParentGroup();
- });
+ Set<String> groupNames = ContainerUtil.map2Set(groups, group -> group.getParentGroup());
// move subgroups
MultiMap<String, TemplatesGroup> subGroups = new MultiMap<String, TemplatesGroup>();
final String productName = ApplicationNamesInfo.getInstance().getFullProductName();
return ProjectBundle.message("project.new.wizard.import.description", productName, context.getPresentationName(), StringUtil.join(
Arrays.asList(Extensions.getExtensions(ProjectImportProvider.PROJECT_IMPORT_PROVIDER)),
- provider -> {
- return provider.getName();
- }, ", "));
+ provider -> provider.getName(), ", "));
}
@Nullable
if (jdk == null) {
return null;
}
- ApplicationManager.getApplication().runWriteAction(() -> {
- ProjectRootManager.getInstance(project).setProjectSdk(jdk);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> ProjectRootManager.getInstance(project).setProjectSdk(jdk));
return jdk;
}
for (SdkPathEditor pathEditor : myPathEditors.values()) {
pathEditor.apply(sdkModificator);
}
- ApplicationManager.getApplication().runWriteAction(() -> {
- sdkModificator.commitChanges();
- });
+ ApplicationManager.getApplication().runWriteAction(() -> sdkModificator.commitChanges());
final AdditionalDataConfigurable configurable = getAdditionalDataConfigurable();
if (configurable != null) {
configurable.apply();
@Override
public void openProjectSettings() {
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
- ShowSettingsUtil.getInstance().editConfigurable(myProject, config, () -> {
- config.selectProjectGeneralSettings(true);
- });
+ ShowSettingsUtil.getInstance().editConfigurable(myProject, config, () -> config.selectProjectGeneralSettings(true));
}
@Override
public void openGlobalLibraries() {
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
- ShowSettingsUtil.getInstance().editConfigurable(myProject, config, () -> {
- config.selectGlobalLibraries(true);
- });
+ ShowSettingsUtil.getInstance().editConfigurable(myProject, config, () -> config.selectGlobalLibraries(true));
}
@Override
public void openLibrary(@NotNull final Library library) {
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
- ShowSettingsUtil.getInstance().editConfigurable(myProject, config, () -> {
- config.selectProjectOrGlobalLibrary(library, true);
- });
+ ShowSettingsUtil.getInstance().editConfigurable(myProject, config, () -> config.selectProjectOrGlobalLibrary(library, true));
}
@Override
@Override
public void openModuleDependenciesSettings(@NotNull final Module module, @Nullable final OrderEntry orderEntry) {
- ShowSettingsUtil.getInstance().editConfigurable(myProject, ProjectStructureConfigurable.getInstance(myProject), () -> {
- ProjectStructureConfigurable.getInstance(myProject).selectOrderEntry(module, orderEntry);
- });
+ ShowSettingsUtil.getInstance().editConfigurable(myProject, ProjectStructureConfigurable.getInstance(myProject), () -> ProjectStructureConfigurable.getInstance(myProject).selectOrderEntry(module, orderEntry));
}
@Override
public static boolean showArtifactSettings(@NotNull Project project, @Nullable final Artifact artifact) {
final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
- return ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> {
- configurable.select(artifact, true);
- });
+ return ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> configurable.select(artifact, true));
}
public static boolean showFacetSettingsDialog(@NotNull final Facet facet,
public static boolean showDialog(Project project, @Nullable final String moduleToSelect, @Nullable final String editorNameToSelect) {
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(project);
- return ShowSettingsUtil.getInstance().editConfigurable(project, config, () -> {
- config.select(moduleToSelect, editorNameToSelect, true);
- });
+ return ShowSettingsUtil.getInstance().editConfigurable(project, config, () -> config.select(moduleToSelect, editorNameToSelect, true));
}
public void moduleRenamed(Module module, final String oldName, final String name) {
private List<OrderRoot> attachFiles(List<OrderRoot> roots) {
final List<OrderRoot> rootsToAttach = filterAlreadyAdded(roots);
if (!rootsToAttach.isEmpty()) {
- ApplicationManager.getApplication().runWriteAction(() -> {
- getLibraryEditor().addRoots(rootsToAttach);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> getLibraryEditor().addRoots(rootsToAttach));
updatePropertiesLabel();
onRootsChanged();
myTreeBuilder.queueUpdate();
@Override
protected Comparator<MyNode> getNodeComparator() {
List<Comparator<MyNode>> comparators = ContainerUtil
- .mapNotNull(ModuleStructureExtension.EP_NAME.getExtensions(), moduleStructureExtension -> {
- return moduleStructureExtension.getNodeComparator();
- });
+ .mapNotNull(ModuleStructureExtension.EP_NAME.getExtensions(), moduleStructureExtension -> moduleStructureExtension.getNodeComparator());
return new MergingComparator<MyNode>(ContainerUtil.concat(comparators, Collections.singletonList(NODE_COMPARATOR)));
}
public String getPlaceholderText(@NotNull ASTNode node) {
final PsiElement element = node.getPsi();
if (element instanceof PsiAnnotation) {
- return "/" + StringUtil.join(((PsiAnnotation)element).getParameterList().getAttributes(), value -> {
- return getMemberValueText(value.getValue());
- }, ", ") + "/";
+ return "/" + StringUtil.join(((PsiAnnotation)element).getParameterList().getAttributes(), value -> getMemberValueText(value.getValue()), ", ") + "/";
}
return element.getText();
}
private static String getMemberValueText(PsiAnnotationMemberValue memberValue) {
if (memberValue instanceof PsiArrayInitializerMemberValue) {
final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)memberValue).getInitializers();
- return StringUtil.join(initializers, psiAnnotationMemberValue -> {
- return getMemberValueText(psiAnnotationMemberValue);
- }, ", ");
+ return StringUtil.join(initializers, psiAnnotationMemberValue -> getMemberValueText(psiAnnotationMemberValue), ", ");
}
if (memberValue instanceof PsiLiteral) {
final Object o = ((PsiLiteral)memberValue).getValue();
public boolean value(PsiTypeElement element) {
return element != myConjunct;
}
- }), element -> {
- return element.getText();
- }, " & ");
+ }), element -> element.getText(), " & ");
final PsiTypeCastExpression newCastExpr =
(PsiTypeCastExpression)JavaPsiFacade.getElementFactory(project).createExpressionFromText("(" + typeText + ")a", castType);
CodeStyleManager.getInstance(project).reformat(castType.replace(newCastExpr.getCastType()));
myConjuncts.remove(myConjunct);
myConjuncts.add(0, myConjunct);
- final String intersectionTypeText = StringUtil.join(myConjuncts, element -> {
- return element.getText();
- }, " & ");
+ final String intersectionTypeText = StringUtil.join(myConjuncts, element -> element.getText(), " & ");
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
final PsiTypeCastExpression fixedCast =
(PsiTypeCastExpression)elementFactory.createExpressionFromText("(" + intersectionTypeText + ") a", myCastTypeElement);
if (!isAvailable()) return;
final PsiExpression expression = getSubExpression();
if (!FileModificationService.getInstance().preparePsiElementForWrite(expression)) return;
- ApplicationManager.getApplication().runWriteAction(() -> {
- simplifyExpression(project, expression, mySubExpressionValue);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> simplifyExpression(project, expression, mySubExpressionValue));
}
public static void simplifyExpression(Project project, final PsiExpression subExpression, final Boolean subExpressionValue) {
if (expressions.isEmpty()) {
resultExpression = negate ? trueExpression : falseExpression;
} else {
- String simplifiedText = StringUtil.join(expressions, expression1 -> {
- return expression1.getText();
- }, " ^ ");
+ String simplifiedText = StringUtil.join(expressions, expression1 -> expression1.getText(), " ^ ");
if (negate) {
if (expressions.size() > 1) {
simplifiedText = "!(" + simplifiedText + ")";
}
- return ContainerUtil.map(memoryStates, state1 -> {
- return new DfaInstructionState(instruction, state1);
- });
+ return ContainerUtil.map(memoryStates, state1 -> new DfaInstructionState(instruction, state1));
}
private static List<DfaMemoryStateImpl> mergeGroup(List<DfaMemoryStateImpl> group) {
@Override
public void flushVariable(@NotNull final DfaVariableValue variable) {
- List<DfaValue> updatedStack = ContainerUtil.map(myStack, value -> {
- return handleFlush(variable, value);
- });
+ List<DfaValue> updatedStack = ContainerUtil.map(myStack, value -> handleFlush(variable, value));
myStack.clear();
for (DfaValue value : updatedStack) {
myStack.push(value);
ValuableInstructionVisitor.PlaceResult placeResult = value.get(context);
final Collection<FList<PsiExpression>> concatenations = placeResult == null ? null : placeResult.myValues.get(variable);
if (concatenations != null) {
- return ContainerUtil.map(concatenations, expressions -> {
- return concatenateExpressions(expressions);
- });
+ return ContainerUtil.map(concatenations, expressions -> concatenateExpressions(expressions));
}
return Collections.emptyList();
}
return concatenation.getHead();
}
String text = StringUtil
- .join(ContainerUtil.reverse(new ArrayList<PsiExpression>(concatenation)), expression -> {
- return expression.getText();
- }, "+");
+ .join(ContainerUtil.reverse(new ArrayList<PsiExpression>(concatenation)), expression -> expression.getText(), "+");
try {
return JavaPsiFacade.getElementFactory(concatenation.getHead().getProject()).createExpressionFromText(text, concatenation.getHead());
}
@Override
public String toString() {
- return StringUtil.join(arguments, constraint -> {
- return constraint.toString();
- }, ", ") + " -> " + returnValue;
+ return StringUtil.join(arguments, constraint -> constraint.toString(), ", ") + " -> " + returnValue;
}
public enum ValueConstraint {
Annotated annotated = check(method, holder, method.getReturnType());
List<PsiMethod> superMethods = ContainerUtil.map(
- method.findSuperMethodSignaturesIncludingStatic(true), signature -> {
- return signature.getMethod();
- });
+ method.findSuperMethodSignaturesIncludingStatic(true), signature -> signature.getMethod());
final NullableNotNullManager nullableManager = NullableNotNullManager.getInstance(holder.getProject());
@Override
public void accept(@NotNull final RefVisitor visitor) {
if (visitor instanceof RefJavaVisitor) {
- ApplicationManager.getApplication().runReadAction(() -> {
- ((RefJavaVisitor)visitor).visitClass(RefClassImpl.this);
- });
+ ApplicationManager.getApplication().runReadAction(() -> ((RefJavaVisitor)visitor).visitClass(RefClassImpl.this));
} else {
super.accept(visitor);
}
@Override
public void accept(@NotNull final RefVisitor visitor) {
if (visitor instanceof RefJavaVisitor) {
- ApplicationManager.getApplication().runReadAction(() -> {
- ((RefJavaVisitor)visitor).visitField(RefFieldImpl.this);
- });
+ ApplicationManager.getApplication().runReadAction(() -> ((RefJavaVisitor)visitor).visitField(RefFieldImpl.this));
} else {
super.accept(visitor);
}
@Override
public void accept(@NotNull final RefVisitor visitor) {
if (visitor instanceof RefJavaVisitor) {
- ApplicationManager.getApplication().runReadAction(() -> {
- ((RefJavaVisitor)visitor).visitMethod(RefMethodImpl.this);
- });
+ ApplicationManager.getApplication().runReadAction(() -> ((RefJavaVisitor)visitor).visitMethod(RefMethodImpl.this));
} else {
super.accept(visitor);
}
@Override
public void accept(@NotNull final RefVisitor visitor) {
if (visitor instanceof RefJavaVisitor) {
- ApplicationManager.getApplication().runReadAction(() -> {
- ((RefJavaVisitor)visitor).visitPackage(RefPackageImpl.this);
- });
+ ApplicationManager.getApplication().runReadAction(() -> ((RefJavaVisitor)visitor).visitPackage(RefPackageImpl.this));
} else {
super.accept(visitor);
}
@Override
public void accept(@NotNull final RefVisitor visitor) {
if (visitor instanceof RefJavaVisitor) {
- ApplicationManager.getApplication().runReadAction(() -> {
- ((RefJavaVisitor)visitor).visitParameter(RefParameterImpl.this);
- });
+ ApplicationManager.getApplication().runReadAction(() -> ((RefJavaVisitor)visitor).visitParameter(RefParameterImpl.this));
} else {
super.accept(visitor);
}
final Set<VirtualFile> files = new HashSet<VirtualFile>(Arrays.asList(((LibraryOrderEntry)entry).getRootFiles(OrderRootType.CLASSES)));
files.removeAll(usedRoots);
if (!files.isEmpty()) {
- final String unusedLibraryRoots = StringUtil.join(files, file -> {
- return file.getPresentableName();
- }, ",");
+ final String unusedLibraryRoots = StringUtil.join(files, file -> file.getPresentableName(), ",");
String message =
InspectionsBundle.message("unused.library.roots.problem.descriptor", unusedLibraryRoots, entry.getPresentableName());
processor.addProblemElement(refModule,
notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
return;
}
- application.invokeLater(() -> {
- DumbService.getInstance(project).withAlternativeResolveEnabled(
- () -> setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, value));
- }, project.getDisposed());
+ application.invokeLater(() -> DumbService.getInstance(project).withAlternativeResolveEnabled(
+ () -> setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, value)), project.getDisposed());
}
break;
}
return;
}
- WriteCommandAction.runWriteCommandAction(project, () -> {
- DumbService.getInstance(project).withAlternativeResolveEnabled(
- () -> JavaCodeStyleManager.getInstance(project).shortenClassReferences(modifierList.addAfter(toInsert, null)));
- });
+ WriteCommandAction.runWriteCommandAction(project, () -> DumbService.getInstance(project).withAlternativeResolveEnabled(
+ () -> JavaCodeStyleManager.getInstance(project).shortenClassReferences(modifierList.addAfter(toInsert, null))));
}
}
public static void putAllMethods(LookupElement item, List<PsiMethod> methods) {
- item.putUserData(ALL_METHODS_ATTRIBUTE, ContainerUtil.map(methods, method -> {
- return SmartPointerManager.getInstance(method.getProject()).createSmartPsiElementPointer(method);
- }));
+ item.putUserData(ALL_METHODS_ATTRIBUTE, ContainerUtil.map(methods, method -> SmartPointerManager.getInstance(method.getProject()).createSmartPsiElementPointer(method)));
}
public static List<PsiMethod> getAllMethods(LookupElement item) {
List<SmartPsiElementPointer<PsiMethod>> pointers = item.getUserData(ALL_METHODS_ATTRIBUTE);
if (pointers == null) return null;
- return ContainerUtil.mapNotNull(pointers, pointer -> {
- return pointer.getElement();
- });
+ return ContainerUtil.mapNotNull(pointers, pointer -> pointer.getElement());
}
public static String[] completeVariableNameForRefactoring(JavaCodeStyleManager codeStyleManager, @Nullable final PsiType varType,
if (psiElement().afterLeaf(psiElement().withText(".")).withSuperParent(2, psiElement(PsiNewExpression.class)).accepts(element)) {
if (((PsiNewExpression)element.getParent().getParent()).getClassReference() == element.getParent()) {
PsiType[] types = ExpectedTypesGetter.getExpectedTypes(element, false);
- return new OrFilter(ContainerUtil.map2Array(types, ElementFilter.class, (Function<PsiType, ElementFilter>)type -> {
- return new AssignableFromFilter(type);
- }));
+ return new OrFilter(ContainerUtil.map2Array(types, ElementFilter.class, (Function<PsiType, ElementFilter>)type -> new AssignableFromFilter(type)));
}
}
private static LookupElement createParametersLookupElement(final PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked) {
final PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
- final String lookupString = StringUtil.join(parameters, psiParameter -> {
- return psiParameter.getName();
- }, ", ");
+ final String lookupString = StringUtil.join(parameters, psiParameter -> psiParameter.getName(), ", ");
final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
LayeredIcon icon = new LayeredIcon(2);
myTypeItems = typeItems;
myGlobalTail = globalTail;
myHasParameters = hasParameters;
- myLookupString = StringUtil.join(myTypeItems, item -> {
- return item.getType().getPresentableText();
- }, ", ");
+ myLookupString = StringUtil.join(myTypeItems, item -> item.getType().getPresentableText(), ", ");
}
@NotNull
private void addImport(final PsiReference ref, final PsiClass targetClass) {
StatisticsManager.getInstance().incUseCount(JavaStatisticsManager.createInfo(null, targetClass));
- CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
- DumbService.getInstance(myProject).withAlternativeResolveEnabled(() -> _addImport(ref, targetClass));
- }), QuickFixBundle.message("add.import"), null);
+ CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> DumbService.getInstance(myProject).withAlternativeResolveEnabled(() -> _addImport(ref, targetClass))), QuickFixBundle.message("add.import"), null);
}
private void _addImport(PsiReference ref, PsiClass targetClass) {
PsiMethod[] constructors = aClass.getConstructors();
if (constructors.length == 0) {
final AddDefaultConstructorFix defaultConstructorFix = new AddDefaultConstructorFix(aClass);
- ApplicationManager.getApplication().runWriteAction(() -> {
- defaultConstructorFix.invoke(project, null, file);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> defaultConstructorFix.invoke(project, null, file));
constructors = aClass.getConstructors();
LOG.assertTrue(constructors.length != 0);
}
@Override
public PopupStep onChosen(final PsiVariable selectedValue, final boolean finalChoice) {
if (selectedValue != null && finalChoice) {
- WriteCommandAction.runWriteCommandAction(selectedValue.getProject(), () -> {
- qualify(selectedValue, editor);
- });
+ WriteCommandAction.runWriteCommandAction(selectedValue.getProject(), () -> qualify(selectedValue, editor));
}
return FINAL_CHOICE;
}
}
};
processor.run();
- ApplicationManager.getApplication().runWriteAction(() -> {
- UndoUtil.markPsiFileForUndo(file);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> UndoUtil.markPsiFileForUndo(file));
return Arrays.asList(newParametersInfo);
}
else {
final PsiClass myClass = (PsiClass)startElement;
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
ApplicationManager.getApplication().runWriteAction(
- () -> {
- invokeImpl(myClass);
- }
+ () -> invokeImpl(myClass)
);
final Editor editor1 = CodeInsightUtil.positionCursorAtLBrace(project, myClass.getContainingFile(), myClass);
if (editor1 == null) return;
ApplicationManager.getApplication().runWriteAction(
() -> {
Collection<PsiMethodMember> members =
- ContainerUtil.map2List(toImplement, s -> {
- return new PsiMethodMember(s);
- });
+ ContainerUtil.map2List(toImplement, s -> new PsiMethodMember(s));
OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(editor1, myClass, members, false);
});
}
PsiMethod[] constructors = myClass.getConstructors();
if (constructors.length == 0) {
final AddDefaultConstructorFix defaultConstructorFix = new AddDefaultConstructorFix(myClass);
- ApplicationManager.getApplication().runWriteAction(() -> {
- defaultConstructorFix.invoke(project, editor, file);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> defaultConstructorFix.invoke(project, editor, file));
constructors = myClass.getConstructors();
}
Arrays.sort(constructors, new Comparator<PsiMethod>() {
final PsiMethod constructor = constructors[0];
final PsiParameter[] parameters = constructor.getParameterList().getParameters();
if (parameters.length > 0) {
- final String params = StringUtil.join(parameters, psiParameter -> {
- return psiParameter.getName();
- }, ",");
+ final String params = StringUtil.join(parameters, psiParameter -> psiParameter.getName(), ",");
enumConstant = (PsiEnumConstant)enumConstant.replace(elementFactory.createEnumConstantFromText(name + "(" + params + ")", null));
final TemplateBuilderImpl builder = new TemplateBuilderImpl(enumConstant);
}
IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();
- ApplicationManager.getApplication().runWriteAction(() -> {
- invokeImpl(targetClass);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> invokeImpl(targetClass));
}
@Nullable
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, classResolveResult);
final ExpectedTypeInfo[] expectedTypes = {new ExpectedTypeInfoImpl(interfaceReturnType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, interfaceReturnType, TailType.NONE, null, ExpectedTypeInfoImpl.NULL)};
CreateMethodFromUsageFix.doCreate(targetClass, method, false,
- ContainerUtil.map2List(interfaceMethod.getParameterList().getParameters(), parameter -> {
- return Pair.create(null, substitutor.substitute(parameter.getType()));
- }),
+ ContainerUtil.map2List(interfaceMethod.getParameterList().getParameters(), parameter -> Pair.create(null, substitutor.substitute(parameter.getType()))),
PsiSubstitutor.EMPTY,
expectedTypes, context);
}
public FieldExpression(final PsiField field, PsiClass aClass, PsiType[] expectedTypes) {
myField = field;
myClass = aClass;
- myExpectedTypes = ContainerUtil.map(expectedTypes, type -> {
- return SmartTypePointerManager.getInstance(field.getProject()).createSmartTypePointer(type);
- });
+ myExpectedTypes = ContainerUtil.map(expectedTypes, type -> SmartTypePointerManager.getInstance(field.getProject()).createSmartTypePointer(type));
myDefaultFieldName = field.getName();
}
}
PsiUtil.setModifierProperty(method, PsiModifier.STATIC, true);
- List<Pair<PsiExpression,PsiType>> args = ContainerUtil.map(types, s -> {
- return new Pair<PsiExpression, PsiType>(null, PsiType.getTypeByName(s, project, GlobalSearchScope.allScope(project)));
- });
+ List<Pair<PsiExpression,PsiType>> args = ContainerUtil.map(types, s -> new Pair<PsiExpression, PsiType>(null, PsiType.getTypeByName(s, project, GlobalSearchScope.allScope(project))));
CreateMethodFromUsageFix.doCreate(targetClass, method, false,
args,
PsiSubstitutor.UNKNOWN,
final List<PsiMethod> constructors = choose(filterIfFieldAlreadyAssigned(myField, myClass.getConstructors()), project);
- ApplicationManager.getApplication().runWriteAction(() -> {
- addFieldInitialization(constructors, myField, project, editor);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> addFieldInitialization(constructors, myField, project, editor));
}
private static void addFieldInitialization(@NotNull List<PsiMethod> constructors,
private static void createDefaultConstructor(PsiClass psiClass, @NotNull final Project project, final Editor editor, final PsiFile file) {
final AddDefaultConstructorFix defaultConstructorFix = new AddDefaultConstructorFix(psiClass);
- ApplicationManager.getApplication().runWriteAction(() -> {
- defaultConstructorFix.invoke(project, editor, file);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> defaultConstructorFix.invoke(project, editor, file));
}
private static PsiMethod[] filterIfFieldAlreadyAssigned(@NotNull PsiField field, @NotNull PsiMethod[] ctors) {
@NotNull
public static List<String> refreshAndConvertToUrls(@NotNull List<String> jarPaths) {
- return ContainerUtil.map(jarPaths, path -> {
- return refreshAndConvertToUrl(path);
- });
+ return ContainerUtil.map(jarPaths, path -> refreshAndConvertToUrl(path));
}
@NotNull
protected void run(@NotNull Result result) throws Throwable {
final PsiDirectory directory = chooseDirectory(project, file);
if (directory == null) return;
- ApplicationManager.getApplication().runWriteAction(() -> {
- doCreate(directory, startElement);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> doCreate(directory, startElement));
}
}.execute();
}
final PsiExpression[] arguments = ((PsiExpressionList)lambdaParent).getExpressions();
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
arguments[idx] = javaPsiFacade.getElementFactory().createExpressionFromText(
- "(" + StringUtil.join(expression.getParameterList().getParameters(), parameter -> {
- return parameter.getName();
- }, ", ") + ") -> {}", expression);
+ "(" + StringUtil.join(expression.getParameterList().getParameters(), parameter -> parameter.getName(), ", ") + ") -> {}", expression);
final PsiParameter[] methodParams = method.getParameterList().getParameters();
final PsiSubstitutor substitutor = javaPsiFacade.getResolveHelper()
.inferTypeArguments(typeParameters, methodParams, arguments, ((MethodCandidateInfo)resolveResult).getSiteSubstitutor(),
text = parameters[0].getName();
}
else {
- text = "(" + StringUtil.join(parameters, parameter -> {
- return parameter.getName();
- }, ", ") + ")";
+ text = "(" + StringUtil.join(parameters, parameter -> parameter.getName(), ", ") + ")";
}
final PsiLambdaExpression expression = (PsiLambdaExpression)JavaPsiFacade.getElementFactory(lambdaExpression.getProject())
.createExpressionFromText(text + "->{}", lambdaExpression);
askReferencesToRestore(project, refs, referenceData);
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
- ApplicationManager.getApplication().runWriteAction(() -> {
- restoreReferences(referenceData, refs);
- });
+ ApplicationManager.getApplication().runWriteAction(() -> restoreReferences(referenceData, refs));
}
protected static void addReferenceData(final PsiElement element,
}
protected synchronized static List<EncapsulatableClassMember> getEncapsulatableClassMembers(final PsiClass psiClass) {
- return ContainerUtil.concat(ourProviders, s -> {
- return s.fun(psiClass);
- });
+ return ContainerUtil.concat(ourProviders, s -> s.fun(psiClass));
}
}
}
else {
final PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, aClass, PsiSubstitutor.EMPTY);
- PsiMethodMember[] constructors = ContainerUtil.map2Array(array, PsiMethodMember.class, s -> {
- return new PsiMethodMember(s, substitutor);
- });
+ PsiMethodMember[] constructors = ContainerUtil.map2Array(array, PsiMethodMember.class, s -> new PsiMethodMember(s, substitutor));
MemberChooser<PsiMethodMember> chooser = new MemberChooser<PsiMethodMember>(constructors, false, true, project);
chooser.setTitle(CodeInsightBundle.message("generate.constructor.super.constructor.chooser.title"));
chooser.show();
generator.generateSuperCallIfNeeded(buffer, baseConstructor.getParameterList().getParameters());
}
final PsiParameter[] parameters = fieldParams.toArray(new PsiParameter[fieldParams.size()]);
- final List<String> existingNames = ContainerUtil.map(dummyConstructor.getParameterList().getParameters(), parameter -> {
- return parameter.getName();
- });
+ final List<String> existingNames = ContainerUtil.map(dummyConstructor.getParameterList().getParameters(), parameter -> parameter.getName());
if (generator instanceof ConstructorBodyGeneratorEx) {
((ConstructorBodyGeneratorEx)generator).generateFieldInitialization(buffer, fields, parameters, existingNames);
}
}
private static PsiMethodMember[] convertToMethodMembers(Collection<CandidateInfo> candidates) {
- return ContainerUtil.map2Array(candidates, PsiMethodMember.class, s -> {
- return new PsiMethodMember(s);
- });
+ return ContainerUtil.map2Array(candidates, PsiMethodMember.class, s -> new PsiMethodMember(s));
}
private class MySortByOverridingAction extends ToggleAction {
boolean toCopyJavaDoc,
boolean toInsertAtOverride)
throws IncorrectOperationException {
- List<CandidateInfo> candidateInfos = ContainerUtil.map2List(candidates, s -> {
- return new CandidateInfo(s.getElement(), s.getSubstitutor());
- });
+ List<CandidateInfo> candidateInfos = ContainerUtil.map2List(candidates, s -> new CandidateInfo(s.getElement(), s.getSubstitutor()));
final List<PsiMethod> methods = overrideOrImplementMethodCandidates(aClass, candidateInfos, toCopyJavaDoc, toInsertAtOverride);
return convert2GenerationInfos(methods);
}
}
public static List<PsiGenerationInfo<PsiMethod>> convert2GenerationInfos(final Collection<PsiMethod> methods) {
- return ContainerUtil.map2List(methods, s -> {
- return createGenerationInfo(s);
- });
+ return ContainerUtil.map2List(methods, s -> createGenerationInfo(s));
}
public static PsiGenerationInfo<PsiMethod> createGenerationInfo(PsiMethod s) {
buffer.append(" extends ");
buffer.append(StringUtil.join(
Arrays.asList(typeParameter.getSuperTypes()),
- t -> {
- return t.getPresentableText();
- }, ", "));
+ t -> t.getPresentableText(), ", "));
context.setupUIComponentPresentation(buffer.toString(), 0, highlightEndOffset, false, false, false,
context.getDefaultParameterColor());
}
public void invoke() {
- ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> {
- searchExistingImplementations();
- }), CodeInsightBundle.message("searching.for.implementations"), false, myProject);
+ ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> searchExistingImplementations()), CodeInsightBundle.message("searching.for.implementations"), false, myProject);
if (mySourceMethods.isEmpty()) {
Messages.showErrorDialog(myProject, CodeInsightBundle.message("copy.abstract.method.no.existing.implementations.found"),
CodeInsightBundle.message("copy.abstract.method.title"));
buffer.append("<html><body></body></html>");
}
String errorSection = "<p id=\"error\">Following external urls were checked:<br> <i>" +
- StringUtil.join(docURLs, url -> {
- return XmlStringUtil.escapeString(url);
- }, "</i><br> <i>") +
+ StringUtil.join(docURLs, url -> XmlStringUtil.escapeString(url), "</i><br> <i>") +
"</i><br>The documentation for this element is not found. Please add all the needed paths to API docs in " +
"<a href=\"open://Project Settings\">Project Settings.</a></p>";
buffer.insert(buffer.indexOf("<body>"), errorSection);
Result paramResult = params[i].calculateResult(context);
Object value = null;
if (paramResult instanceof ListResult) {
- value = ContainerUtil.map2List(((ListResult)paramResult).getComponents(), result1 -> {
- return result1.toString();
- });
+ value = ContainerUtil.map2List(((ListResult)paramResult).getComponents(), result1 -> result1.toString());
} else if (paramResult != null) {
value = paramResult.toString();
}
ApplicationManager.getApplication().assertIsDispatchThread();
if (isSemicolonNeeded(file, editor)) {
- ApplicationManager.getApplication().runWriteAction(() -> {
- CommandProcessor.getInstance().runUndoTransparentAction(
- () -> {
- EditorModificationUtil.insertStringAtCaret(editor, ";", false, false);
- PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
- });
- });
+ ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().runUndoTransparentAction(
+ () -> {
+ EditorModificationUtil.insertStringAtCaret(editor, ";", false, false);
+ PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
+ }));
}
}
if (psiExpression instanceof PsiReferenceExpression) {
references.add((PsiReferenceExpression)psiExpression);
}
- return ContainerUtil.mapNotNull(references, (NullableFunction<PsiReferenceExpression, PsiElement>)expression1 -> {
- return expression1.resolve();
- });
+ return ContainerUtil.mapNotNull(references, (NullableFunction<PsiReferenceExpression, PsiElement>)expression1 -> expression1.resolve());
}
private static boolean isReferenceToOneOf(PsiReferenceExpression reference, List<PsiElement> elements) {
});
}
- ApplicationManager.getApplication().invokeLater(() -> {
- SafeDeleteHandler.invoke(project, PsiUtilCore.toPsiElementArray(psiElements), false);
- }, project.getDisposed());
+ ApplicationManager.getApplication().invokeLater(() -> SafeDeleteHandler.invoke(project, PsiUtilCore.toPsiElementArray(psiElements), false), project.getDisposed());
}
}
}
}
}
}
- ApplicationManager.getApplication().invokeLater(() -> {
- SafeDeleteHandler.invoke(project, PsiUtilCore.toPsiElementArray(psiElementsToIgnore), false, refreshViews);
- }, project.getDisposed());
+ ApplicationManager.getApplication().invokeLater(() -> SafeDeleteHandler.invoke(project, PsiUtilCore.toPsiElementArray(psiElementsToIgnore), false, refreshViews), project.getDisposed());
}
}
}
private void showUsageView(@NotNull Project project, final UsageInfo[] usageInfos, @NotNull AnalysisScope scope) {
final UsageTarget[] targets = UsageTarget.EMPTY_ARRAY;
final Ref<Usage[]> convertUsagesRef = new Ref<Usage[]>();
- if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> {
- convertUsagesRef.set(UsageInfo2UsageAdapter.convert(usageInfos));
- }), "Preprocess Usages", true, project)) return;
+ if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> convertUsagesRef.set(UsageInfo2UsageAdapter.convert(usageInfos))), "Preprocess Usages", true, project)) return;
if (convertUsagesRef.isNull()) return;
final Usage[] usages = convertUsagesRef.get();
private static void invoke(final Project project,
final PsiModifierListOwner element,
final String fqn, final String toRemove) {
- WriteCommandAction.runWriteCommandAction(project, () -> {
- new AddAnnotationFix(fqn, element, toRemove).invoke(project, null, element.getContainingFile());
- });
+ WriteCommandAction.runWriteCommandAction(project, () -> new AddAnnotationFix(fqn, element, toRemove).invoke(project, null, element.getContainingFile()));
}
public int getCount() {
final String fqn = aClass.getQualifiedName();
LOG.assertTrue(fqn != null);
final String parameters =
- StringUtil.join(ContainerUtil.map(method.getParameterList().getParameters(), parameter -> {
- return parameter.getName();
- }), ", ");
+ StringUtil.join(ContainerUtil.map(method.getParameterList().getParameters(), parameter -> parameter.getName()), ", ");
final String expressionText = fqn + "." + method.getName() + "(" + parameters + ")";
final PsiExpression psiExpression = JavaPsiFacade.getElementFactory(method.getProject())
.createExpressionFromText(expressionText, null);
public ValidationInfo validate(final PsiMethod method) {
final PsiParameter[] parameters = method.getParameterList().getParameters();
final PsiType[] parameterTypes =
- ContainerUtil.map2Array(Arrays.asList(parameters), new PsiType[parameters.length], parameter -> {
- return parameter.getType();
- });
+ ContainerUtil.map2Array(Arrays.asList(parameters), new PsiType[parameters.length], parameter -> parameter.getType());
final PsiType returnType = method.getReturnType();
if (StreamApiConstants.FAKE_FIND_MATCHED.equals(myStreamApiMethodName)) {
if (project == null) return;
final String commandName = event.getPresentation().getText();
- ApplicationManager.getApplication().runWriteAction(() -> {
- CommandProcessor.getInstance().executeCommand(project, () -> {
-
- try{
- final HierarchyNodeDescriptor[] selectedDescriptors = methodHierarchyBrowser.getSelectedDescriptors();
- if (selectedDescriptors.length > 0) {
- final List<VirtualFile> files = new ArrayList<VirtualFile>(selectedDescriptors.length);
- for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
- final PsiFile containingFile = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass().getContainingFile();
- if (containingFile != null) {
- final VirtualFile vFile = containingFile.getVirtualFile();
- if (vFile != null) {
- files.add(vFile);
- }
+ ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(project, () -> {
+
+ try{
+ final HierarchyNodeDescriptor[] selectedDescriptors = methodHierarchyBrowser.getSelectedDescriptors();
+ if (selectedDescriptors.length > 0) {
+ final List<VirtualFile> files = new ArrayList<VirtualFile>(selectedDescriptors.length);
+ for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
+ final PsiFile containingFile = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass().getContainingFile();
+ if (containingFile != null) {
+ final VirtualFile vFile = containingFile.getVirtualFile();
+ if (vFile != null) {
+ files.add(vFile);
}
}
- final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(files));
- if (!status.hasReadonlyFiles()) {
- for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
- final PsiElement aClass = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass();
- if (aClass instanceof PsiClass) {
- OverrideImplementUtil.overrideOrImplement((PsiClass)aClass, methodHierarchyBrowser.getBaseMethod());
- }
+ }
+ final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(files));
+ if (!status.hasReadonlyFiles()) {
+ for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
+ final PsiElement aClass = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass();
+ if (aClass instanceof PsiClass) {
+ OverrideImplementUtil.overrideOrImplement((PsiClass)aClass, methodHierarchyBrowser.getBaseMethod());
}
- ToolWindowManager.getInstance(project).activateEditorComponent();
- }
- else {
- ApplicationManager.getApplication().invokeLater(
- () -> Messages.showErrorDialog(project, status.getReadonlyFilesMessage(), commandName));
}
+ ToolWindowManager.getInstance(project).activateEditorComponent();
+ }
+ else {
+ ApplicationManager.getApplication().invokeLater(
+ () -> Messages.showErrorDialog(project, status.getReadonlyFilesMessage(), commandName));
}
}
- catch(IncorrectOperationException e){
- LOG.error(e);
- }
- }, commandName, null);
- });
+ }
+ catch(IncorrectOperationException e){
+ LOG.error(e);
+ }
+ }, commandName, null));
}
public final void update(final AnActionEvent e) {
}
private static void searchFields(final PsiClass allIcons, final UsageView view, final ProgressIndicator indicator) {
- ApplicationManager.getApplication().runReadAction(() -> {
- indicator.setText("Searching for: " + allIcons.getQualifiedName());
- });
+ ApplicationManager.getApplication().runReadAction(() -> indicator.setText("Searching for: " + allIcons.getQualifiedName()));
ReferencesSearch.search(allIcons).forEach(reference -> {
PsiElement elt = reference.getElement();
}
private static void scanFolder(File javasFolder, ArrayList<String> result) {
- File[] candidates = javasFolder.listFiles(pathname -> {
- return JdkUtil.checkForJdk(pathname);
- });
+ File[] candidates = javasFolder.listFiles(pathname -> JdkUtil.checkForJdk(pathname));
if (candidates != null) {
- result.addAll(ContainerUtil.map2List(candidates, file -> {
- return file.getAbsolutePath();
- }));
+ result.addAll(ContainerUtil.map2List(candidates, file -> file.getAbsolutePath()));
}
}
}
languageLevels.add(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().toString());
- return ContainerUtil.map2Set(languageLevels, languageLevel -> {
- return new UsageDescriptor(languageLevel, 1);
- });
+ return ContainerUtil.map2Set(languageLevels, languageLevel -> new UsageDescriptor(languageLevel, 1));
}
}
@NotNull
private static String toVfString(@NotNull Collection<VirtualFile> list) {
List<VirtualFile> sub = new ArrayList<VirtualFile>(list).subList(0, Math.min(list.size(), 100));
- return list.size() + " files: " + StringUtil.join(sub, file -> {
- return file.getName();
- }, ", ") + (list.size() == sub.size() ? "" : "...");
+ return list.size() + " files: " + StringUtil.join(sub, file -> file.getName(), ", ") + (list.size() == sub.size() ? "" : "...");
}
private void initListeners(@NotNull MessageBus messageBus, @NotNull PsiManager psiManager) {
}, indicator);
return result[0];
};
- List<Future<Boolean>> futures = ContainerUtil.map(Collections.nCopies(parallelism, ""), s -> {
- return myApplication.executeOnPooledThread(processFileFromSet);
- });
+ List<Future<Boolean>> futures = ContainerUtil.map(Collections.nCopies(parallelism, ""), s -> myApplication.executeOnPooledThread(processFileFromSet));
List<Boolean> results = ContainerUtil.map(futures, future -> {
try {
}
void enter(final PsiClassOwner psiClassOwner) {
- ApplicationManager.getApplication().runReadAction(() -> {
- enterTopLevels(psiClassOwner);
- });
+ ApplicationManager.getApplication().runReadAction(() -> enterTopLevels(psiClassOwner));
}
private void enterTopLevels(PsiClassOwner owner) {
@Override
public void connect(final Symbol sym) {
- ApplicationManager.getApplication().runReadAction(() -> {
- connectInternal((Symbol.ClassSymbol)sym);
- });
+ ApplicationManager.getApplication().runReadAction(() -> connectInternal((Symbol.ClassSymbol)sym));
}
private void connectInternal(Symbol.ClassSymbol sym) {
int size = symbols.myClassAnchors.length;
for (int i = 0; i < size; i++) {
final int finalI = i;
- ApplicationManager.getApplication().runReadAction(() -> {
- test(classes[finalI]);
- });
+ ApplicationManager.getApplication().runReadAction(() -> test(classes[finalI]));
indicator.setFraction(i * 1.0 / (double)size);
}
LOG.info("TestStubHierarchyAction finished");
private static String getCanonicalText(PsiType boundType) {
if (boundType instanceof PsiIntersectionType) {
- return StringUtil.join(ContainerUtil.map(((PsiIntersectionType)boundType).getConjuncts(), type -> {
- return type.getCanonicalText();
- }), " & ");
+ return StringUtil.join(ContainerUtil.map(((PsiIntersectionType)boundType).getConjuncts(), type -> type.getCanonicalText()), " & ");
}
return boundType.getCanonicalText();
}
return statement instanceof PsiReturnStatement && ((PsiReturnStatement)statement).getReturnValue() != null;
}
});
- final List<PsiExpression> map = ContainerUtil.map(filter, statement -> {
- return ((PsiReturnStatement)statement).getReturnValue();
- });
+ final List<PsiExpression> map = ContainerUtil.map(filter, statement -> ((PsiReturnStatement)statement).getReturnValue());
return map.toArray(new PsiExpression[map.size()]);
}
CommandProcessor.getInstance().executeCommand(project,
() -> PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(() -> {
try {
- ApplicationManager.getApplication().runWriteAction(() -> {
- extractProcessor.doRefactoring();
- });
+ ApplicationManager.getApplication().runWriteAction(() -> extractProcessor.doRefactoring());
processor.run();
- ApplicationManager.getApplication().runWriteAction(() -> {
- processor.runChangeSignature();
- });
+ ApplicationManager.getApplication().runWriteAction(() -> processor.runChangeSignature());
}
catch (IncorrectOperationException e) {
LOG.error(e);
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (processor.isCreateInnerClass()) {
- ApplicationManager.getApplication().runWriteAction(() -> {
- processor.moveUsedMethodsToInner();
- });
+ ApplicationManager.getApplication().runWriteAction(() -> processor.moveUsedMethodsToInner());
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (editor != null) {
DuplicatesImpl.processDuplicates(extractProcessor, project, editor);
myClass.getContainingFile().getContainingDirectory().getVirtualFile())) {
conflicts.putValue(sourceClass, "Extracted class won't be accessible in " + RefactoringUIUtil.getDescription(sourceClass, true));
}
- ApplicationManager.getApplication().runWriteAction(() -> {
- myClass.delete();
- });
+ ApplicationManager.getApplication().runWriteAction(() -> myClass.delete());
final Project project = sourceClass.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final PsiClass existingClass =