diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java index 1dfa3e083fb6..91cee0dfa291 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java @@ -366,13 +366,8 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque public boolean isVerified(Requestor requestor) { DebuggerManagerThreadImpl.assertIsManagerThread(); - for (EventRequest request : findRequests(requestor)) { - /*ClassPrepareRequest is added in any case, so do not count it*/ - if (!(request instanceof ClassPrepareRequest)) { - return true; - } - } - return false; + //ClassPrepareRequest is added in any case, so do not count it + return findRequests(requestor).stream().anyMatch(r -> !(r instanceof ClassPrepareRequest)); } public void processDetached(DebugProcessImpl process, boolean closedByUser) { diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java index d4365472d9d2..7c799dc79890 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ /* @@ -21,10 +9,10 @@ package com.intellij.debugger.jdi; import com.intellij.util.ThreeState; import com.sun.jdi.*; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -104,18 +92,11 @@ public class ObjectReferenceProxyImpl extends JdiProxy { * @throws IncompatibleThreadStateException */ public List waitingThreads() throws IncompatibleThreadStateException { - List list = getObjectReference().waitingThreads(); - List proxiesList = new ArrayList<>(list.size()); - - for (ThreadReference threadReference : list) { - proxiesList.add(getVirtualMachineProxy().getThreadReferenceProxy(threadReference)); - } - return proxiesList; + return StreamEx.of(getObjectReference().waitingThreads()).map(getVirtualMachineProxy()::getThreadReferenceProxy).toList(); } public ThreadReferenceProxyImpl owningThread() throws IncompatibleThreadStateException { - ThreadReference threadReference = getObjectReference().owningThread(); - return getVirtualMachineProxy().getThreadReferenceProxy(threadReference); + return getVirtualMachineProxy().getThreadReferenceProxy(getObjectReference().owningThread()); } public int entryCount() throws IncompatibleThreadStateException { diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadGroupReferenceProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadGroupReferenceProxyImpl.java index 9b2cc6c77bc5..5ec174f59d7c 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadGroupReferenceProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadGroupReferenceProxyImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ /* @@ -22,10 +10,9 @@ package com.intellij.debugger.jdi; import com.intellij.debugger.engine.jdi.ThreadGroupReferenceProxy; import com.intellij.openapi.diagnostic.Logger; import com.sun.jdi.ThreadGroupReference; -import com.sun.jdi.ThreadReference; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NonNls; -import java.util.ArrayList; import java.util.List; public class ThreadGroupReferenceProxyImpl extends ObjectReferenceProxyImpl implements ThreadGroupReferenceProxy{ @@ -73,23 +60,11 @@ public class ThreadGroupReferenceProxyImpl extends ObjectReferenceProxyImpl impl } public List threads() { - List list = getThreadGroupReference().threads(); - List proxies = new ArrayList<>(list.size()); - - for (ThreadReference threadReference : list) { - proxies.add(getVirtualMachineProxy().getThreadReferenceProxy(threadReference)); - } - return proxies; + return StreamEx.of(getThreadGroupReference().threads()).map(getVirtualMachineProxy()::getThreadReferenceProxy).toList(); } public List threadGroups() { - List list = getThreadGroupReference().threadGroups(); - List proxies = new ArrayList<>(list.size()); - - for (ThreadGroupReference threadGroupReference : list) { - proxies.add(getVirtualMachineProxy().getThreadGroupReferenceProxy(threadGroupReference)); - } - return proxies; + return StreamEx.of(getThreadGroupReference().threadGroups()).map(getVirtualMachineProxy()::getThreadGroupReferenceProxy).toList(); } public void clearCaches() { diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java index 34f0643d6286..548354764af6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java @@ -1,4 +1,6 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +/* + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ /* * @author Eugene Zhuravlev @@ -22,6 +24,7 @@ import com.sun.jdi.event.EventQueue; import com.sun.jdi.request.EventRequestManager; import com.sun.tools.jdi.JNITypeParser; import com.sun.tools.jdi.TargetVM; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -247,15 +250,7 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { * @return a list of threadGroupProxies */ public List topLevelThreadGroups() { - List list = getVirtualMachine().topLevelThreadGroups(); - - List result = new ArrayList<>(list.size()); - - for (ThreadGroupReference threadGroup : list) { - result.add(getThreadGroupReferenceProxy(threadGroup)); - } - - return result; + return StreamEx.of(getVirtualMachine().topLevelThreadGroups()).map(this::getThreadGroupReferenceProxy).toList(); } public void threadGroupCreated(ThreadGroupReference threadGroupReference){ diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CompositeDataBinding.java b/java/debugger/impl/src/com/intellij/debugger/settings/CompositeDataBinding.java index 492f8ca74a0d..1537743628bd 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CompositeDataBinding.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CompositeDataBinding.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.settings; @@ -29,23 +17,14 @@ public class CompositeDataBinding implements DataBinding{ } public void loadData(Object from) { - for (DataBinding myBinding : myBindings) { - myBinding.loadData(from); - } + myBindings.forEach(binding -> binding.loadData(from)); } public void saveData(Object to) { - for (DataBinding myBinding : myBindings) { - myBinding.saveData(to); - } + myBindings.forEach(binding -> binding.saveData(to)); } public boolean isModified(Object obj) { - for (DataBinding myBinding : myBindings) { - if (myBinding.isModified(obj)) { - return true; - } - } - return false; + return myBindings.stream().anyMatch(binding -> binding.isModified(obj)); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java index 85cdbc5d3e59..c8bd9bceec6b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.ui; @@ -105,12 +93,7 @@ public class HotSwapUIImpl extends HotSwapUI { return false; } // todo: return false if yourkit agent is inactive - for (DebuggerSession session : sessions) { - if (session.isPaused()) { - return true; - } - } - return false; + return sessions.stream().anyMatch(DebuggerSession::isPaused); } private void hotSwapSessions(final List sessions, @Nullable final Map> generatedPaths) { @@ -132,13 +115,7 @@ public class HotSwapUIImpl extends HotSwapUI { findClassesProgress = new HotSwapProgressImpl(myProject); } else { - boolean createProgress = false; - for (DebuggerSession session : sessions) { - if (session.isModifiedClassesScanRequired()) { - createProgress = true; - break; - } - } + boolean createProgress = sessions.stream().anyMatch(DebuggerSession::isModifiedClassesScanRequired); findClassesProgress = createProgress ? new HotSwapProgressImpl(myProject) : null; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java index 6d8f655707c0..6b46fcdb3a21 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.ui; @@ -25,6 +13,7 @@ import com.intellij.openapi.ui.MultiLineLabelUI; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.OptionsDialog; import com.intellij.util.ui.UIUtil; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -116,12 +105,7 @@ public class RunHotswapDialog extends OptionsDialog { } public Collection getSessionsToReload() { - final List markedElements = myElementsChooser.getMarkedElements(); - final List sessions = new ArrayList<>(markedElements.size()); - for (SessionItem item : markedElements) { - sessions.add(item.getSession()); - } - return sessions; + return StreamEx.of(myElementsChooser.getMarkedElements()).map(SessionItem::getSession).toList(); } private static class SessionItem { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java index d4b873811fbf..c160222275da 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.ui.breakpoints; @@ -26,6 +14,7 @@ import com.intellij.util.ui.JBUI; import javax.swing.*; import java.awt.*; +import java.util.Arrays; public class EditInstanceFiltersDialog extends DialogWrapper{ private InstanceFilterEditor myInstanceFilterEditor; @@ -69,11 +58,6 @@ public class EditInstanceFiltersDialog extends DialogWrapper{ } public InstanceFilter[] getFilters() { - ClassFilter [] cFilters = myInstanceFilterEditor.getFilters(); - InstanceFilter [] ifilters = new InstanceFilter[cFilters.length]; - for (int i = 0; i < ifilters.length; i++) { - ifilters[i] = InstanceFilter.create(cFilters[i]); - } - return ifilters; + return Arrays.stream(myInstanceFilterEditor.getFilters()).map(InstanceFilter::create).toArray(InstanceFilter[]::new); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java index aef4cd5150dc..6548478c66ab 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.ui.impl.watch; @@ -41,6 +29,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.refactoring.extractMethod.PrepareFailedException; import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.incremental.java.JavaBuilder; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StaticDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StaticDescriptorImpl.java index 6284de46b724..de1aca671572 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StaticDescriptorImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StaticDescriptorImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ /* @@ -27,8 +15,8 @@ import com.intellij.debugger.settings.NodeRendererSettings; import com.intellij.debugger.ui.tree.StaticDescriptor; import com.intellij.debugger.ui.tree.render.ClassRenderer; import com.intellij.debugger.ui.tree.render.DescriptorLabelListener; -import com.sun.jdi.Field; import com.sun.jdi.ReferenceType; +import com.sun.jdi.TypeComponent; public class StaticDescriptorImpl extends NodeDescriptorImpl implements StaticDescriptor{ @@ -37,15 +25,7 @@ public class StaticDescriptorImpl extends NodeDescriptorImpl implements StaticDe public StaticDescriptorImpl(ReferenceType refType) { myType = refType; - - boolean hasStaticFields = false; - for (Field field : myType.allFields()) { - if (field.isStatic()) { - hasStaticFields = true; - break; - } - } - myHasStaticFields = hasStaticFields; + myHasStaticFields = myType.allFields().stream().anyMatch(TypeComponent::isStatic); } public ReferenceType getType() { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/BatchEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/BatchEvaluator.java index c119ab54e701..52db0f5fd63d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/BatchEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/BatchEvaluator.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.ui.tree.render; @@ -29,6 +17,7 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.rt.debugger.BatchEvaluatorServer; import com.intellij.util.containers.HashMap; import com.sun.jdi.*; +import one.util.streamex.StreamEx; import java.util.ArrayList; import java.util.Collections; @@ -160,11 +149,7 @@ public class BatchEvaluator { private boolean doEvaluateBatch(List requests, EvaluationContext evaluationContext) { try { DebugProcess debugProcess = evaluationContext.getDebugProcess(); - List values = new ArrayList<>(); - for (ToStringCommand toStringCommand : requests) { - Value value = toStringCommand.getValue(); - values.add(value instanceof ObjectReference ? ((ObjectReference)value) : value); - } + List values = StreamEx.of(requests).map(ToStringCommand::getValue).toList(); ArrayType objectArrayClass = (ArrayType)debugProcess.findClass( evaluationContext, diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java index 031ab5828ae7..ef1a86a335b1 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java @@ -14,7 +14,6 @@ import com.intellij.psi.PsiClass; import com.intellij.ui.FieldPanel; import com.intellij.ui.MultiLineTooltipUI; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; @@ -204,12 +203,7 @@ public class JavaBreakpointFiltersPanel filters = new ArrayList<>(); - for (InstanceFilter instanceFilter : myInstanceFilters) { - if (instanceFilter.isEnabled()) { - filters.add(Long.toString(instanceFilter.getId())); - } - } + List filters = StreamEx.of(myInstanceFilters).filter(InstanceFilter::isEnabled).map(f -> Long.toString(f.getId())).toList(); if (updateText) { myInstanceFiltersField.setText(StringUtil.join(filters, " ")); } diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java b/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java index 69ed26c20f0a..ecc646dfc380 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.engine; @@ -180,12 +168,9 @@ public abstract class JSR45PositionManager implements PositionManager { // Finds exact server file name (from available in type) // This is needed because some servers (e.g. WebSphere) put not exact file name such as 'A.jsp ' private String getSourceName(final String name, final ReferenceType type) throws AbsentInformationException { - for(String sourceNameFromType: type.sourceNames(myStratumId)) { - if (sourceNameFromType.contains(name)) { - return sourceNameFromType; - } - } - return name; + return type.sourceNames(myStratumId).stream() + .filter(sourceNameFromType -> sourceNameFromType.contains(name)) + .findFirst().orElse(name); } }); } diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java b/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java index e95decf6e8ff..246041879d8b 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.engine; @@ -21,6 +9,8 @@ import com.intellij.openapi.project.DumbService; import com.intellij.openapi.util.TextRange; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + /** * During indexing, only extensions that implement {@link com.intellij.openapi.project.DumbAware} are called. * See also {@link DumbService}. diff --git a/java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java b/java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java index 5fa255b10957..fa5793b532c4 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java +++ b/java/debugger/openapi/src/com/intellij/debugger/ui/tree/NodeDescriptorNameAdjuster.java @@ -1,23 +1,13 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.ui.tree; import com.intellij.openapi.extensions.ExtensionPointName; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; + /** * @author Nikolay.Tropin */ @@ -29,9 +19,6 @@ public abstract class NodeDescriptorNameAdjuster { public abstract String fixName(String name, @NotNull NodeDescriptor descriptor); public static NodeDescriptorNameAdjuster findFor(@NotNull NodeDescriptor descriptor) { - for (NodeDescriptorNameAdjuster adjuster:EP_NAME.getExtensions()) { - if (adjuster.isApplicable(descriptor)) return adjuster; - } - return null; + return Arrays.stream(EP_NAME.getExtensions()).filter(adjuster -> adjuster.isApplicable(descriptor)).findFirst().orElse(null); } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java index a1f199423bbc..2c7e7e66cdf6 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl.breakpoints; @@ -138,13 +126,7 @@ public class BreakpointsFavoriteListProvider extends AbstractFavoritesListProvid if (node.getValue() instanceof Navigatable && ((Navigatable)node.getValue()).canNavigate()) { return true; } - Collection children = node.getChildren(); - for (AbstractTreeNode child : children) { - if (checkNavigatable(child)) { - return true; - } - } - return false; + return node.getChildren().stream().anyMatch(BreakpointsFavoriteListProvider::checkNavigatable); } @Nullable