[extract method] IDEA-318013: check explicit parent of identifier instead of search

GitOrigin-RevId: d632f6dfffdbfe8912882f30c9bd203e95362a54
This commit is contained in:
Alexandr Suhinin
2023-04-14 11:04:02 +03:00
committed by intellij-monorepo-bot
parent fe6f93dcc9
commit f2ff1ff151
4 changed files with 56 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
package org.example;
import java.io.File;
import java.util.Collection;
class Parent {
public boolean test(Collection<File> files) {
return false;
}
}
class Child extends Parent {
@Override
public boolean test(Collection<File> files) {
return files.stream().allMatch(file -> {
String name = file.getName();
return <selection>name.endsWith("jar") || name.endsWith("tar")</selection>;
});
}
}

View File

@@ -0,0 +1,25 @@
package org.example;
import java.io.File;
import java.util.Collection;
class Parent {
public boolean test(Collection<File> files) {
return false;
}
}
class Child extends Parent {
@Override
public boolean test(Collection<File> files) {
return files.stream().allMatch(file -> {
String name = file.getName();
return isaBoolean(name);
});
}
private static boolean isaBoolean(String name) {
return name.endsWith("jar") || name.endsWith("tar");
}
}