mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-32698 JSON Schema selection menu should work for JSON fragm. editor
This commit is contained in:
@@ -43,7 +43,7 @@ public class JsonSchemaMappingsProjectConfiguration implements PersistentStateCo
|
||||
if (pattern.pattern || pattern.directory) continue;
|
||||
String path = pattern.path.replace('\\', '/');
|
||||
VirtualFile relativeFile = VfsUtil.findRelativeFile(projectBaseDir, StringUtil.split(path, "/").toArray(ArrayUtil.EMPTY_STRING_ARRAY));
|
||||
if (Objects.equals(relativeFile, file)) {
|
||||
if (Objects.equals(relativeFile, file) || file.getUrl().equals(path)) {
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,14 @@ public class JsonSchemaPatternComparator {
|
||||
}
|
||||
|
||||
private ThreeState comparePaths(UserDefinedJsonSchemaConfiguration.Item left, UserDefinedJsonSchemaConfiguration.Item right) {
|
||||
final File leftFile = new File(myProject.getBasePath(), left.getPath());
|
||||
final File rightFile = new File(myProject.getBasePath(), right.getPath());
|
||||
String leftPath = left.getPath();
|
||||
String rightPath = right.getPath();
|
||||
|
||||
if (leftPath.startsWith("mock:///") || rightPath.startsWith("mock:///")) {
|
||||
return leftPath.equals(rightPath) ? ThreeState.YES : ThreeState.NO;
|
||||
}
|
||||
final File leftFile = new File(myProject.getBasePath(), leftPath);
|
||||
final File rightFile = new File(myProject.getBasePath(), rightPath);
|
||||
|
||||
if (left.isDirectory()) {
|
||||
if (FileUtil.isAncestor(leftFile, rightFile, true)) return ThreeState.YES;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class UserDefinedJsonSchemaConfiguration {
|
||||
});
|
||||
}
|
||||
else {
|
||||
result.add((project, vfile) -> vfile.equals(getRelativeFile(project, patternText)));
|
||||
result.add((project, vfile) -> vfile.equals(getRelativeFile(project, patternText)) || vfile.getUrl().equals(patternText.path));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -106,8 +106,9 @@ class JsonSchemaInfoPopupStep extends BaseListPopupStep<JsonSchemaInfo> {
|
||||
UserDefinedJsonSchemaConfiguration mappingForFile = mappingsConf.findMappingForFile(myVirtualFile);
|
||||
if (mappingForFile == null) {
|
||||
UserDefinedJsonSchemaConfiguration configuration = configurable.addProjectSchema();
|
||||
String relativePath = VfsUtilCore.getRelativePath(myVirtualFile, myProject.getBaseDir());
|
||||
configuration.patterns.add(new UserDefinedJsonSchemaConfiguration.Item(
|
||||
VfsUtilCore.getRelativePath(myVirtualFile, myProject.getBaseDir()), false, false));
|
||||
relativePath == null ? myVirtualFile.getUrl() : relativePath, false, false));
|
||||
mappingForFile = configuration;
|
||||
}
|
||||
|
||||
@@ -128,7 +129,8 @@ class JsonSchemaInfoPopupStep extends BaseListPopupStep<JsonSchemaInfo> {
|
||||
UserDefinedJsonSchemaConfiguration mappingForFile = configuration.findMappingForFile(virtualFile);
|
||||
if (mappingForFile != null) {
|
||||
for (UserDefinedJsonSchemaConfiguration.Item pattern : mappingForFile.patterns) {
|
||||
if (Objects.equals(VfsUtil.findRelativeFile(projectBaseDir, pattern.path), virtualFile)) {
|
||||
if (Objects.equals(VfsUtil.findRelativeFile(projectBaseDir, pattern.path), virtualFile)
|
||||
|| virtualFile.getUrl().equals(pattern.path)) {
|
||||
mappingForFile.patterns.remove(pattern);
|
||||
if (mappingForFile.patterns.size() == 0) {
|
||||
configuration.removeConfiguration(mappingForFile);
|
||||
@@ -144,6 +146,9 @@ class JsonSchemaInfoPopupStep extends BaseListPopupStep<JsonSchemaInfo> {
|
||||
if (selectedValue == null) return;
|
||||
|
||||
String path = VfsUtilCore.getRelativePath(virtualFile, projectBaseDir);
|
||||
if (path == null) {
|
||||
path = virtualFile.getUrl();
|
||||
}
|
||||
|
||||
UserDefinedJsonSchemaConfiguration existing = configuration.findMappingBySchemaInfo(selectedValue);
|
||||
UserDefinedJsonSchemaConfiguration.Item item = new UserDefinedJsonSchemaConfiguration.Item(path, false, false);
|
||||
|
||||
Reference in New Issue
Block a user