mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-51398
- decode should not return null
This commit is contained in:
+28
-29
@@ -163,40 +163,39 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
|
||||
}
|
||||
else {
|
||||
final String decoded = decode(text);
|
||||
if (decoded != null) {
|
||||
|
||||
if (context instanceof PackagePrefixFileSystemItem) {
|
||||
context = ((PackagePrefixFileSystemItem)context).getDirectory();
|
||||
if (context instanceof PackagePrefixFileSystemItem) {
|
||||
context = ((PackagePrefixFileSystemItem)context).getDirectory();
|
||||
}
|
||||
|
||||
if (context instanceof PsiDirectory && caseSensitivityApplies((PsiDirectory)context, caseSensitive)) {
|
||||
// optimization: do not load all children into VFS
|
||||
PsiDirectory directory = (PsiDirectory)context;
|
||||
PsiFileSystemItem child = directory.findFile(decoded);
|
||||
if (child == null) child = directory.findSubdirectory(decoded);
|
||||
if (child != null) {
|
||||
result.add(new PsiElementResolveResult(getOriginalFile(child)));
|
||||
}
|
||||
|
||||
if (context instanceof PsiDirectory && caseSensitivityApplies((PsiDirectory)context, caseSensitive)) {
|
||||
// optimization: do not load all children into VFS
|
||||
PsiDirectory directory = (PsiDirectory)context;
|
||||
PsiFileSystemItem child = directory.findFile(decoded);
|
||||
if (child == null) child = directory.findSubdirectory(decoded);
|
||||
if (child != null) {
|
||||
result.add(new PsiElementResolveResult(getOriginalFile(child)));
|
||||
}
|
||||
else {
|
||||
processVariants(context, new PsiFileSystemItemProcessor() {
|
||||
@Override
|
||||
public boolean acceptItem(String name, boolean isDirectory) {
|
||||
return caseSensitive ? decoded.equals(name) : decoded.compareToIgnoreCase(name) == 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
processVariants(context, new PsiFileSystemItemProcessor() {
|
||||
@Override
|
||||
public boolean acceptItem(String name, boolean isDirectory) {
|
||||
return caseSensitive ? decoded.equals(name) : decoded.compareToIgnoreCase(name) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiFileSystemItem element) {
|
||||
result.add(new PsiElementResolveResult(getOriginalFile(element)));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiFileSystemItem element) {
|
||||
result.add(new PsiElementResolveResult(getOriginalFile(element)));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getFileNameToCreate() {
|
||||
return decode(getCanonicalText());
|
||||
}
|
||||
@@ -218,8 +217,8 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
|
||||
!myFileReferenceSet.isEndingSlashNotAllowed() && myIndex > 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String decode(final String text) {
|
||||
@NotNull
|
||||
public String decode(@NotNull final String text) {
|
||||
// strip http get parameters
|
||||
String _text = text;
|
||||
if (text.indexOf('?') >= 0) {
|
||||
@@ -228,7 +227,7 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
|
||||
|
||||
if (myFileReferenceSet.isUrlEncoded()) {
|
||||
try {
|
||||
return new URI(_text).getPath();
|
||||
return StringUtil.notNullize(new URI(_text).getPath(), text);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return text;
|
||||
@@ -504,7 +503,7 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
|
||||
public String getUnresolvedMessagePattern() {
|
||||
return LangBundle.message("error.cannot.resolve")
|
||||
+ " " + (isLast() ? LangBundle.message("terms.file") : LangBundle.message("terms.directory"))
|
||||
+ " '" + StringUtil.escapePattern(StringUtil.notNullize(decode(getCanonicalText()))) + "'";
|
||||
+ " '" + StringUtil.escapePattern(decode(getCanonicalText())) + "'";
|
||||
}
|
||||
|
||||
public final boolean isLast() {
|
||||
|
||||
Reference in New Issue
Block a user