Skip to content

Commit

Permalink
put double quotes back
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j committed Nov 6, 2021
1 parent 213c5e4 commit 9dd31ba
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
52 changes: 26 additions & 26 deletions src/transformers/custom-elements-manifest/get-declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
*
* For example, mapping known exports into a list of manifest declarations.
*/
import * as tsModule from 'typescript';
import {isSimpleType, toSimpleType} from 'ts-simple-type';
import {ComponentDeclaration} from '../../analyze/types/component-declaration';
import * as tsModule from "typescript";
import {isSimpleType, toSimpleType} from "ts-simple-type";
import {ComponentDeclaration} from "../../analyze/types/component-declaration";
import {
getMixinHeritageClauses,
getSuperclassHeritageClause
} from '../../analyze/util/component-declaration-util';
import {findParent, getNodeName} from '../../analyze/util/ast-util';
import {getJsDoc} from '../../analyze/util/js-doc-util';
import {getTypeHintFromType} from '../../util/get-type-hint-from-type';
import {AnalyzerResult} from '../../analyze/types/analyzer-result';
import * as schema from 'custom-elements-manifest';
import {TransformerContext} from '../transformer-context';
} from "../../analyze/util/component-declaration-util";
import {findParent, getNodeName} from "../../analyze/util/ast-util";
import {getJsDoc} from "../../analyze/util/js-doc-util";
import {getTypeHintFromType} from "../../util/get-type-hint-from-type";
import {AnalyzerResult} from "../../analyze/types/analyzer-result";
import * as schema from "custom-elements-manifest";
import {TransformerContext} from "../transformer-context";
import {
typeToSchemaType,
getSummaryFromJsDoc,
getParameterFromJsDoc,
getReturnFromJsDoc,
getReferenceFromHeritageClause,
getInheritedFromReference
} from './utils';
} from "./utils";

/**
* Computes the exported symbols of a result (e.g. variables, functions, etc.)
Expand Down Expand Up @@ -60,7 +60,7 @@ function* getExportedDeclarationsFromResult(
const jsDoc = getJsDoc(variableStatement, tsModule);

yield {
kind: 'variable',
kind: "variable",
name: node.name.getText(),
description: jsDoc?.description,
type: typeToSchemaType(context, context.checker.getTypeAtLocation(node)),
Expand Down Expand Up @@ -101,7 +101,7 @@ function* getExportedDeclarationsFromResult(
const {description: returnDescription, typeHint: returnTypeHint} = getReturnFromJsDoc(jsDoc);

yield {
kind: 'function',
kind: "function",
name: node.name.getText(),
description: jsDoc?.description,
summary: getSummaryFromJsDoc(jsDoc),
Expand All @@ -124,11 +124,11 @@ function* getClassFieldsForComponent(
declaration: ComponentDeclaration,
context: TransformerContext
): IterableIterator<schema.ClassField> {
const visibility = context.config.visibility ?? 'public';
const visibility = context.config.visibility ?? "public";
for (const member of declaration.members) {
if (member.visibility === visibility && member.propName != null) {
yield {
kind: 'field',
kind: "field",
name: member.propName,
privacy: member.visibility,
description: member.jsDoc?.description,
Expand All @@ -151,7 +151,7 @@ function* getMethodsForComponent(
declaration: ComponentDeclaration,
context: TransformerContext
): IterableIterator<schema.ClassMethod> {
const visibility = context.config.visibility ?? 'public';
const visibility = context.config.visibility ?? "public";
for (const method of declaration.methods) {
const parameters: schema.Parameter[] = [];
const node = method.node;
Expand Down Expand Up @@ -190,7 +190,7 @@ function* getMethodsForComponent(
);

yield {
kind: 'method',
kind: "method",
name: method.name,
privacy: method.visibility,
description: method.jsDoc?.description,
Expand Down Expand Up @@ -228,20 +228,20 @@ function* getEventsFromComponent(
declaration: ComponentDeclaration,
context: TransformerContext
): IterableIterator<schema.Event> {
const visibility = context.config.visibility ?? 'public';
const visibility = context.config.visibility ?? "public";
for (const event of declaration.events) {
if (event.visibility === visibility) {
const type = event.type?.() ?? {kind: 'ANY'};
const type = event.type?.() ?? {kind: "ANY"};
const simpleType = isSimpleType(type) ? type : toSimpleType(type, context.checker);
const typeName =
simpleType.kind === 'GENERIC_ARGUMENTS' ? simpleType.target.name : simpleType.name;
simpleType.kind === "GENERIC_ARGUMENTS" ? simpleType.target.name : simpleType.name;
yield {
description: event.jsDoc?.description,
name: event.name,
inheritedFrom: getInheritedFromReference(declaration, event, context),
type:
typeName === null || typeName === undefined || simpleType.kind === 'ANY'
? {text: 'Event'}
typeName === null || typeName === undefined || simpleType.kind === "ANY"
? {text: "Event"}
: {text: typeName}
};
}
Expand All @@ -260,7 +260,7 @@ function* getSlotsFromComponent(
for (const slot of declaration.slots) {
yield {
description: slot.jsDoc?.description,
name: slot.name ?? ''
name: slot.name ?? ""
};
}
}
Expand All @@ -274,7 +274,7 @@ function* getAttributesFromComponent(
declaration: ComponentDeclaration,
context: TransformerContext
): IterableIterator<schema.Attribute> {
const visibility = context.config.visibility ?? 'public';
const visibility = context.config.visibility ?? "public";
for (const member of declaration.members) {
if (member.visibility === visibility && member.attrName) {
const type = getTypeHintFromType(
Expand Down Expand Up @@ -341,7 +341,7 @@ function getDeclarationForComponent(
result: AnalyzerResult,
context: TransformerContext
): schema.Declaration | undefined {
if (declaration.kind === 'interface') {
if (declaration.kind === "interface") {
return undefined;
}

Expand All @@ -364,7 +364,7 @@ function getDeclarationForComponent(
}

const classDecl: schema.ClassDeclaration = {
kind: 'class',
kind: "class",
name,
superclass: superClass,
mixins: mixins.length > 0 ? mixins : undefined,
Expand Down
12 changes: 6 additions & 6 deletions src/transformers/custom-elements-manifest/get-exports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {AnalyzerResult} from '../../analyze/types/analyzer-result';
import {TransformerContext} from '../transformer-context';
import * as schema from './schema';
import {getReferenceForNode} from './utils';
import {AnalyzerResult} from "../../analyze/types/analyzer-result";
import {TransformerContext} from "../transformer-context";
import * as schema from "./schema";
import {getReferenceForNode} from "./utils";

function* getCustomElementExportsFromResult(
result: AnalyzerResult,
Expand All @@ -15,7 +15,7 @@ function* getCustomElementExportsFromResult(
}

yield {
kind: 'custom-element-definition',
kind: "custom-element-definition",
name: definition.tagName,
declaration: getReferenceForNode(definition.declaration.node, context)
};
Expand All @@ -35,7 +35,7 @@ function* getExportedNamesFromResult(

for (const exp of exports) {
yield {
kind: 'js',
kind: "js",
name: exp.name,
declaration: getReferenceForNode(exp.valueDeclaration, context)
};
Expand Down
28 changes: 14 additions & 14 deletions src/transformers/custom-elements-manifest/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as tsModule from 'typescript';
import {Program, SourceFile} from 'typescript';
import {AnalyzerResult} from '../../analyze/types/analyzer-result';
import {ComponentDeclaration} from '../../analyze/types/component-declaration';
import {visitAllHeritageClauses} from '../../analyze/util/component-declaration-util';
import {TransformerConfig} from '../transformer-config';
import {TransformerFunction} from '../transformer-function';
import * as schema from './schema';
import {TransformerContext} from '../transformer-context';
import {getExportsFromResult} from './get-exports';
import {getDeclarationsFromResult} from './get-declarations';
import {getRelativePath} from './utils';
import * as tsModule from "typescript";
import {Program, SourceFile} from "typescript";
import {AnalyzerResult} from "../../analyze/types/analyzer-result";
import {ComponentDeclaration} from "../../analyze/types/component-declaration";
import {visitAllHeritageClauses} from "../../analyze/util/component-declaration-util";
import {TransformerConfig} from "../transformer-config";
import {TransformerFunction} from "../transformer-function";
import * as schema from "./schema";
import {TransformerContext} from "../transformer-context";
import {getExportsFromResult} from "./get-exports";
import {getDeclarationsFromResult} from "./get-declarations";
import {getRelativePath} from "./utils";

/**
* Transforms results to a custom elements manifest
Expand All @@ -36,7 +36,7 @@ export const transformer: TransformerFunction = (
const modules = flattenedAnalyzerResults.map((result) => resultToModule(result, context));

const manifest: schema.Package = {
schemaVersion: '1.0.0',
schemaVersion: "1.0.0",
modules
};

Expand All @@ -56,7 +56,7 @@ function resultToModule(
const declarations = [...getDeclarationsFromResult(result, context)];

return {
kind: 'javascript-module',
kind: "javascript-module",
path: getRelativePath(result.sourceFile.fileName, context),
declarations: declarations.length === 0 ? undefined : declarations,
exports: exports.length === 0 ? undefined : exports
Expand Down
26 changes: 13 additions & 13 deletions src/transformers/custom-elements-manifest/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {basename, relative} from 'path';
import {SimpleType} from 'ts-simple-type';
import {Node, SourceFile, Type} from 'typescript';
import {TransformerContext} from '../transformer-context';
import {JsDoc} from '../../analyze/types/js-doc';
import * as schema from 'custom-elements-manifest';
import {getNodeName, resolveDeclarations} from '../../analyze/util/ast-util';
import {basename, relative} from "path";
import {SimpleType} from "ts-simple-type";
import {Node, SourceFile, Type} from "typescript";
import {TransformerContext} from "../transformer-context";
import {JsDoc} from "../../analyze/types/js-doc";
import * as schema from "custom-elements-manifest";
import {getNodeName, resolveDeclarations} from "../../analyze/util/ast-util";
import {
ComponentDeclaration,
ComponentHeritageClause
} from '../../analyze/types/component-declaration';
import {ComponentFeatureBase} from '../../analyze/types/features/component-feature';
import {getTypeHintFromType} from '../../util/get-type-hint-from-type';
} from "../../analyze/types/component-declaration";
import {ComponentFeatureBase} from "../../analyze/types/features/component-feature";
import {getTypeHintFromType} from "../../util/get-type-hint-from-type";

/**
* Returns a Reference to a node
Expand Down Expand Up @@ -105,7 +105,7 @@ export function getParameterFromJsDoc(
for (const tag of jsDoc.tags) {
const parsed = tag.parsed();

if (parsed.tag === 'param' && parsed.name === name) {
if (parsed.tag === "param" && parsed.name === name) {
return {description: parsed.description, typeHint: parsed.type};
}
}
Expand All @@ -120,7 +120,7 @@ export function getParameterFromJsDoc(
export function getReturnFromJsDoc(
jsDoc: JsDoc | undefined
): {description?: string; typeHint?: string} {
const tag = jsDoc?.tags?.find((tag) => ['returns', 'return'].includes(tag.tag));
const tag = jsDoc?.tags?.find((tag) => tag.tag === "returns" || tag.tag === "return");

if (tag == null) {
return {};
Expand Down Expand Up @@ -155,7 +155,7 @@ export function typeToSchemaType(
* @param jsDoc
*/
export function getSummaryFromJsDoc(jsDoc: JsDoc | undefined): string | undefined {
const summaryTag = jsDoc?.tags?.find((tag) => tag.tag === 'summary');
const summaryTag = jsDoc?.tags?.find((tag) => tag.tag === "summary");

if (summaryTag == null) {
return undefined;
Expand Down

0 comments on commit 9dd31ba

Please sign in to comment.