mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
json schema, rename to exported definitions
This commit is contained in:
@@ -79,7 +79,7 @@ public class JsonSchemaMappingsProjectConfiguration extends JsonSchemaMappingsCo
|
||||
if (schemaFile != null) mySchemaFiles.put(schemaFile, info);
|
||||
}
|
||||
if (refreshStaticProviders) {
|
||||
ServiceManager.getService(myProject, JsonSchemaService.class).refreshCrossDefinitions();
|
||||
ServiceManager.getService(myProject, JsonSchemaService.class).refreshExportedDefinitions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ import java.util.List;
|
||||
|
||||
public interface JsonSchemaService {
|
||||
|
||||
void refreshCrossDefinitions();
|
||||
void refreshExportedDefinitions();
|
||||
|
||||
void ensureCrossDefinitionsInitialized();
|
||||
void ensureExportedDefinitionsInitialized();
|
||||
|
||||
class Impl {
|
||||
|
||||
|
||||
+5
-5
@@ -29,15 +29,15 @@ import static com.jetbrains.jsonSchema.impl.JsonSchemaReader.LOG;
|
||||
/**
|
||||
* @author Irina.Chernushina on 3/28/2016.
|
||||
*/
|
||||
public class JsonSchemaCrossDefinitions {
|
||||
public class JsonSchemaExportedDefinitions {
|
||||
private final Map<String, Map<String, JsonSchemaObject>> myMap;
|
||||
private final Project myProject;
|
||||
|
||||
public static JsonSchemaCrossDefinitions getInstance(final Project project) {
|
||||
return ServiceManager.getService(project, JsonSchemaCrossDefinitions.class);
|
||||
public static JsonSchemaExportedDefinitions getInstance(final Project project) {
|
||||
return ServiceManager.getService(project, JsonSchemaExportedDefinitions.class);
|
||||
}
|
||||
|
||||
public JsonSchemaCrossDefinitions(@NotNull final Project project) {
|
||||
public JsonSchemaExportedDefinitions(@NotNull final Project project) {
|
||||
myProject = project;
|
||||
myMap = Collections.synchronizedMap(new HashMap<>());
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class JsonSchemaCrossDefinitions {
|
||||
}
|
||||
|
||||
public JsonSchemaObject findDefinition(@NotNull final String url, @NotNull final String relativePart, @NotNull final JsonSchemaObject rootObject) {
|
||||
ServiceManager.getService(myProject, JsonSchemaService.class).ensureCrossDefinitionsInitialized();
|
||||
ServiceManager.getService(myProject, JsonSchemaService.class).ensureExportedDefinitionsInitialized();
|
||||
final Map<String, JsonSchemaObject> map = myMap.get(url);
|
||||
if (map != null) {
|
||||
return JsonSchemaReader.findDefinition(myProject, relativePart, rootObject, map, false);
|
||||
@@ -64,7 +64,7 @@ public class JsonSchemaReader {
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerObjectsForCrossDefinitions(@Nullable final Project project, @NotNull final JsonSchemaObject object) {
|
||||
public static void registerObjectsExportedDefinitions(@Nullable final Project project, @NotNull final JsonSchemaObject object) {
|
||||
String id = object.getId();
|
||||
if (!StringUtil.isEmptyOrSpaces(id)) {
|
||||
id = id.endsWith("#") ? id.substring(0, id.length() - 1) : id;
|
||||
@@ -91,7 +91,7 @@ public class JsonSchemaReader {
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
map.putAll(convertor.convert("#/properties/", properties));
|
||||
}
|
||||
JsonSchemaCrossDefinitions.getInstance(project).register(id, map);
|
||||
JsonSchemaExportedDefinitions.getInstance(project).register(id, map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class JsonSchemaReader {
|
||||
if (!processCrossReferences) return null;
|
||||
final String url = ref.substring(0, idx);
|
||||
final String relative = ref.substring(idx);
|
||||
return JsonSchemaCrossDefinitions.getInstance(project).findDefinition(url, relative, root);
|
||||
return JsonSchemaExportedDefinitions.getInstance(project).findDefinition(url, relative, root);
|
||||
}
|
||||
ref = ref.substring(2);
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ public class JsonSchemaServiceImpl implements JsonSchemaService {
|
||||
@Nullable
|
||||
private final Project myProject;
|
||||
private final ConcurrentMap<JsonSchemaFileProvider, JsonSchemaObjectCodeInsightWrapper> myWrappers = ContainerUtil.newConcurrentMap();
|
||||
private final AtomicBoolean myCrossDefinitionsInitialized;
|
||||
private final AtomicBoolean myExportedDefinitionsInitialized;
|
||||
|
||||
public JsonSchemaServiceImpl(@Nullable Project project) {
|
||||
myProject = project;
|
||||
myCrossDefinitionsInitialized = new AtomicBoolean();
|
||||
myExportedDefinitionsInitialized = new AtomicBoolean();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -135,14 +135,14 @@ public class JsonSchemaServiceImpl implements JsonSchemaService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshCrossDefinitions() {
|
||||
myCrossDefinitionsInitialized.getAndSet(false);
|
||||
ensureCrossDefinitionsInitialized();
|
||||
public void refreshExportedDefinitions() {
|
||||
myExportedDefinitionsInitialized.getAndSet(false);
|
||||
ensureExportedDefinitionsInitialized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureCrossDefinitionsInitialized() {
|
||||
if (myCrossDefinitionsInitialized.get()) return;
|
||||
public void ensureExportedDefinitionsInitialized() {
|
||||
if (myExportedDefinitionsInitialized.get()) return;
|
||||
final JsonSchemaProviderFactory[] factories = getProviderFactories();
|
||||
for (JsonSchemaProviderFactory factory : factories) {
|
||||
for (JsonSchemaFileProvider provider : factory.getProviders(myProject)) {
|
||||
@@ -150,14 +150,14 @@ public class JsonSchemaServiceImpl implements JsonSchemaService {
|
||||
if (reader == null) continue;
|
||||
try {
|
||||
final JsonSchemaObject resultObject = new JsonSchemaReader(myProject).read(reader, false);
|
||||
JsonSchemaReader.registerObjectsForCrossDefinitions(myProject, resultObject);
|
||||
JsonSchemaReader.registerObjectsExportedDefinitions(myProject, resultObject);
|
||||
}
|
||||
catch (IOException e) {
|
||||
logException(provider, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
myCrossDefinitionsInitialized.getAndSet(true);
|
||||
myExportedDefinitionsInitialized.getAndSet(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
instance="com.jetbrains.jsonSchema.JsonSchemaMappingsConfigurable" nonDefaultProject="true"/>
|
||||
<projectService serviceInterface="com.jetbrains.jsonSchema.ide.JsonSchemaService"
|
||||
serviceImplementation="com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl"/>
|
||||
<projectService serviceImplementation="com.jetbrains.jsonSchema.impl.JsonSchemaCrossDefinitions"/>
|
||||
<projectService serviceImplementation="com.jetbrains.jsonSchema.impl.JsonSchemaExportedDefinitions"/>
|
||||
<annotator language="JSON" implementationClass="com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator"/>
|
||||
<completion.contributor order="last, before JsonSchemaCompletionContributor" language="JSON" implementationClass="com.jetbrains.jsonSchema.ide.JsonSchemaCompletionContributor"/>
|
||||
<lang.documentationProvider language="JSON"
|
||||
|
||||
Reference in New Issue
Block a user