cleanup: use streams

This commit is contained in:
Egor Ushakov
2017-12-21 12:18:29 +03:00
parent 50ce4ec7a6
commit f5b9eaffb9
16 changed files with 50 additions and 288 deletions
@@ -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<Scope> 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);
}
});
}
@@ -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}.
@@ -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);
}
}