File system can be case insensitive, so we can't invoke String#endsWith

This commit is contained in:
Max Medvedev
2016-10-14 10:03:43 +03:00
parent a2e4c35d56
commit 0dc9b9d74f
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* 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.
@@ -153,7 +153,7 @@ class FilePointerPartNode {
Pair<VirtualFile, String> fileAndUrl = myFileAndUrl;
if (fileAndUrl != null && fileAndUrl.second != null) {
String url = fileAndUrl.second;
assert url.endsWith(part) : "part is: '"+part +"' but url is: '"+url+"'";
assert endsWith(url, part) : "part is: '" + part + "' but url is: '" + url + "'";
}
boolean hasFile = fileAndUrl != null && fileAndUrl.first != null;
@@ -244,6 +244,10 @@ class FilePointerPartNode {
return indexOfFirstDifferentChar(path, start, part, 0);
}
private static boolean endsWith(@NotNull String string, @NotNull String end) {
return indexOfFirstDifferentChar(string, string.length() - end.length(), end, 0) == string.length();
}
@NotNull
// returns pair.second != null always
Pair<VirtualFile, String> update() {