ChartJsonOptionCompletion.fromReference constructor

ChartJsonOptionCompletion.fromReference(
  1. ChartJsonOptionFieldReference reference, {
  2. required String containerPath,
})

Implementation

factory ChartJsonOptionCompletion.fromReference(
  ChartJsonOptionFieldReference reference, {
  required String containerPath,
}) {
  final normalizedContainer = ChartJsonOptionPaths.normalizeContainer(
    containerPath,
  );
  final jsonPath = ChartJsonOptionPaths.fieldPath(
    normalizedContainer,
    reference.canonicalField,
  );
  return ChartJsonOptionCompletion(
    schemaName: reference.schemaName,
    canonicalField: reference.canonicalField,
    containerPath: normalizedContainer,
    jsonPath: jsonPath,
    label: reference.canonicalField,
    insertText: reference.canonicalField,
    aliases: reference.aliases,
    kind: reference.kind,
    description: reference.description,
    valueHint: ChartJsonOptionValueHint.forKind(
      reference.kind,
      canonicalField: reference.canonicalField,
    ),
    preferred: ChartJsonOptionPaths.sameContainer(
      normalizedContainer,
      reference.preferredContainer,
    ),
  );
}