Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pkedy committed Feb 20, 2022
1 parent f5bdd39 commit 562ece3
Show file tree
Hide file tree
Showing 9 changed files with 4,648 additions and 7,503 deletions.
12,095 changes: 4,620 additions & 7,475 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apexlang/core",
"version": "0.0.13",
"version": "0.0.14",
"description": "Apex language JavaScript library",
"keywords": [
"apex",
Expand Down
12 changes: 6 additions & 6 deletions src/ast/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { Document } from "./document";
import { Annotation, Name } from "./nodes";
import autoBind from "../auto-bind";
import { WidlError } from "../error/error";
import { ApexError } from "../error/error";
import { Kind } from "./kinds";

export class Writer {
Expand Down Expand Up @@ -57,13 +57,13 @@ interface NamedParameters {
}

class ErrorHolder {
errors: WidlError[];
errors: ApexError[];

constructor() {
this.errors = new Array<WidlError>();
this.errors = new Array<ApexError>();
}

reportError(error: WidlError): void {
reportError(error: ApexError): void {
this.errors.push(error);
}
}
Expand Down Expand Up @@ -267,11 +267,11 @@ export class Context {
});
}

reportError(error: WidlError): void {
reportError(error: ApexError): void {
this.errors.reportError(error);
}

getErrors(): WidlError[] {
getErrors(): ApexError[] {
return this.errors.errors;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/blockstring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Produces the value of a block string from its parsed raw value, similar to
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
*
* This implements the WIDL spec's BlockStringValue() static algorithm.
* This implements the Apex spec's BlockStringValue() static algorithm.
*
* @internal
*/
Expand Down
14 changes: 7 additions & 7 deletions src/error/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Node, Source } from "../ast";

export class WidlError extends Error {
export class ApexError extends Error {
nodes: Array<Node> | Node | undefined;
source: Source | undefined;
positions: Array<number> | undefined;
Expand All @@ -25,8 +25,8 @@ export function syntaxError(
source: Source,
position: number,
description: string
): WidlError {
return new WidlError(
): ApexError {
return new ApexError(
`Syntax Error: ${description}`,
undefined,
source,
Expand All @@ -35,13 +35,13 @@ export function syntaxError(
);
}

export function importError(node: Node, description: string): WidlError {
export function importError(node: Node, description: string): ApexError {
const loc = node.getLoc();
var source: Source | undefined;
if (loc != undefined) {
source = loc.source;
}
return new WidlError(
return new ApexError(
`Import Error: ${description}`,
node,
source,
Expand All @@ -50,13 +50,13 @@ export function importError(node: Node, description: string): WidlError {
);
}

export function validationError(node: Node, description: string): WidlError {
export function validationError(node: Node, description: string): ApexError {
const loc = node.getLoc();
var source: Source | undefined;
if (loc != undefined) {
source = loc.source;
}
return new WidlError(
return new ApexError(
`Validation Error: ${description}`,
node,
source,
Expand Down
16 changes: 8 additions & 8 deletions src/parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TokenKind } from "./token_kind";
import { Lexer, getTokenDesc, getTokenKindDesc } from "./lexer";
import { importError, syntaxError, WidlError } from "./error";
import { importError, syntaxError, ApexError } from "./error";
import autoBind from "./auto-bind";
import {
Location,
Expand Down Expand Up @@ -66,8 +66,8 @@ export type ParseOptions = {
export type Resolver = (location: string, from: string) => string;

/**
* Given a WIDL source, parses it into a Document.
* Throws WidlError if a syntax error is encountered.
* Given a Apex source, parses it into a Document.
* Throws ApexError if a syntax error is encountered.
*/
export function parse(
source: string,
Expand All @@ -79,12 +79,12 @@ export function parse(
}

/**
* Given a string containing a WIDL value (ex. `[42]`), parse the AST for
* Given a string containing a Apex value (ex. `[42]`), parse the AST for
* that value.
* Throws WidlError if a syntax error is encountered.
* Throws ApexError if a syntax error is encountered.
*
* This is useful within tools that operate upon WIDL Values directly and
* in isolation of complete WIDL documents.
* This is useful within tools that operate upon Apex Values directly and
* in isolation of complete Apex documents.
*
* Consider providing the results to the utility function: valueFromAST().
*/
Expand Down Expand Up @@ -1184,7 +1184,7 @@ class Parser {
* Helper function for creating an error when an unexpected lexed token
* is encountered.
*/
unexpected(atToken?: Token): WidlError {
unexpected(atToken?: Token): ApexError {
const token = atToken ?? this._lexer.token;
return syntaxError(
this._lexer.source,
Expand Down
4 changes: 2 additions & 2 deletions src/validator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Context, Document, MultiVisitor } from "./ast";
import { WidlError } from "./error";
import { ApexError } from "./error";
import { ValidationRule } from "./rules";

export function validate(
doc: Document,
...rules: ValidationRule[]
): WidlError[] {
): ApexError[] {
const context = new Context({});

const ruleVisitors = rules.map((r) => new r());
Expand Down
4 changes: 2 additions & 2 deletions templates/module/.template
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: module
description: A WIDL codegen project
description: A Apex codegen project
variables:

- name: module
description: The module name
prompt: Please enter the module name (e.g. @apexlang/mymodule)
prompt: Please enter the module name (e.g. @myorg/mymodule)

- name: description
description: The module description
Expand Down
2 changes: 1 addition & 1 deletion templates/module/package.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"release:preflight": "npm pack --dry-run"
},
"dependencies": {
"@apexlang/core": "^0.0.6"
"@apexlang/core": "^0.0.14"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.1.0",
Expand Down

0 comments on commit 562ece3

Please sign in to comment.