@cedarjs/structure 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +19 -0
- package/dist/hosts.d.ts +23 -0
- package/dist/hosts.d.ts.map +1 -0
- package/dist/hosts.js +45 -0
- package/dist/ide.d.ts +122 -0
- package/dist/ide.d.ts.map +1 -0
- package/dist/ide.js +240 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/interactive_cli/RedwoodCommandString.d.ts +20 -0
- package/dist/interactive_cli/RedwoodCommandString.d.ts.map +1 -0
- package/dist/interactive_cli/RedwoodCommandString.js +72 -0
- package/dist/interactive_cli/command_builder.d.ts +10 -0
- package/dist/interactive_cli/command_builder.d.ts.map +1 -0
- package/dist/interactive_cli/command_builder.js +196 -0
- package/dist/interactive_cli/dry_run.d.ts +28 -0
- package/dist/interactive_cli/dry_run.d.ts.map +1 -0
- package/dist/interactive_cli/dry_run.js +101 -0
- package/dist/interactive_cli/ui.d.ts +32 -0
- package/dist/interactive_cli/ui.d.ts.map +1 -0
- package/dist/interactive_cli/ui.js +84 -0
- package/dist/language_server/RWLanguageServer.d.ts +30 -0
- package/dist/language_server/RWLanguageServer.d.ts.map +1 -0
- package/dist/language_server/RWLanguageServer.js +201 -0
- package/dist/language_server/commands.d.ts +14 -0
- package/dist/language_server/commands.d.ts.map +1 -0
- package/dist/language_server/commands.js +122 -0
- package/dist/language_server/diagnostics.d.ts +10 -0
- package/dist/language_server/diagnostics.d.ts.map +1 -0
- package/dist/language_server/diagnostics.js +61 -0
- package/dist/language_server/outline.d.ts +7 -0
- package/dist/language_server/outline.d.ts.map +1 -0
- package/dist/language_server/outline.js +37 -0
- package/dist/language_server/start.d.ts +2 -0
- package/dist/language_server/start.d.ts.map +1 -0
- package/dist/language_server/start.js +4 -0
- package/dist/language_server/xmethods.d.ts +11 -0
- package/dist/language_server/xmethods.d.ts.map +1 -0
- package/dist/language_server/xmethods.js +42 -0
- package/dist/model/RWCell.d.ts +22 -0
- package/dist/model/RWCell.d.ts.map +1 -0
- package/dist/model/RWCell.js +111 -0
- package/dist/model/RWComponent.d.ts +11 -0
- package/dist/model/RWComponent.d.ts.map +1 -0
- package/dist/model/RWComponent.js +42 -0
- package/dist/model/RWEnvHelper.d.ts +64 -0
- package/dist/model/RWEnvHelper.d.ts.map +1 -0
- package/dist/model/RWEnvHelper.js +295 -0
- package/dist/model/RWFunction.d.ts +11 -0
- package/dist/model/RWFunction.d.ts.map +1 -0
- package/dist/model/RWFunction.js +19 -0
- package/dist/model/RWLayout.d.ts +11 -0
- package/dist/model/RWLayout.d.ts.map +1 -0
- package/dist/model/RWLayout.js +19 -0
- package/dist/model/RWPage.d.ts +13 -0
- package/dist/model/RWPage.d.ts.map +1 -0
- package/dist/model/RWPage.js +60 -0
- package/dist/model/RWProject.d.ts +61 -0
- package/dist/model/RWProject.d.ts.map +1 -0
- package/dist/model/RWProject.js +170 -0
- package/dist/model/RWRoute.d.ts +58 -0
- package/dist/model/RWRoute.d.ts.map +1 -0
- package/dist/model/RWRoute.js +416 -0
- package/dist/model/RWRouter.d.ts +30 -0
- package/dist/model/RWRouter.d.ts.map +1 -0
- package/dist/model/RWRouter.js +186 -0
- package/dist/model/RWSDL.d.ts +21 -0
- package/dist/model/RWSDL.d.ts.map +1 -0
- package/dist/model/RWSDL.js +89 -0
- package/dist/model/RWSDLField.d.ts +31 -0
- package/dist/model/RWSDLField.d.ts.map +1 -0
- package/dist/model/RWSDLField.js +132 -0
- package/dist/model/RWService.d.ts +26 -0
- package/dist/model/RWService.d.ts.map +1 -0
- package/dist/model/RWService.js +76 -0
- package/dist/model/RWServiceFunction.d.ts +20 -0
- package/dist/model/RWServiceFunction.d.ts.map +1 -0
- package/dist/model/RWServiceFunction.js +100 -0
- package/dist/model/RWTOML.d.ts +12 -0
- package/dist/model/RWTOML.d.ts.map +1 -0
- package/dist/model/RWTOML.js +56 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +13 -0
- package/dist/model/util/advanced_path_parser.d.ts +12 -0
- package/dist/model/util/advanced_path_parser.d.ts.map +1 -0
- package/dist/model/util/advanced_path_parser.js +38 -0
- package/dist/model/util/process_env.d.ts +23 -0
- package/dist/model/util/process_env.d.ts.map +1 -0
- package/dist/model/util/process_env.js +76 -0
- package/dist/outline/index.d.ts +3 -0
- package/dist/outline/index.d.ts.map +1 -0
- package/dist/outline/index.js +31 -0
- package/dist/outline/outline.d.ts +4 -0
- package/dist/outline/outline.d.ts.map +1 -0
- package/dist/outline/outline.js +260 -0
- package/dist/outline/types.d.ts +88 -0
- package/dist/outline/types.d.ts.map +1 -0
- package/dist/outline/types.js +73 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +34 -0
- package/dist/x/Array.d.ts +4 -0
- package/dist/x/Array.d.ts.map +1 -0
- package/dist/x/Array.js +26 -0
- package/dist/x/URL.d.ts +15 -0
- package/dist/x/URL.d.ts.map +1 -0
- package/dist/x/URL.js +99 -0
- package/dist/x/child_process.d.ts +15 -0
- package/dist/x/child_process.d.ts.map +1 -0
- package/dist/x/child_process.js +51 -0
- package/dist/x/decorators.d.ts +3 -0
- package/dist/x/decorators.d.ts.map +1 -0
- package/dist/x/decorators.js +26 -0
- package/dist/x/path.d.ts +6 -0
- package/dist/x/path.d.ts.map +1 -0
- package/dist/x/path.js +53 -0
- package/dist/x/prisma.d.ts +19 -0
- package/dist/x/prisma.d.ts.map +1 -0
- package/dist/x/prisma.js +65 -0
- package/dist/x/ts-morph.d.ts +10 -0
- package/dist/x/ts-morph.d.ts.map +1 -0
- package/dist/x/ts-morph.js +56 -0
- package/dist/x/vscode-languageserver-types.d.ts +93 -0
- package/dist/x/vscode-languageserver-types.d.ts.map +1 -0
- package/dist/x/vscode-languageserver-types.js +421 -0
- package/dist/x/vscode-languageserver.d.ts +12 -0
- package/dist/x/vscode-languageserver.d.ts.map +1 -0
- package/dist/x/vscode-languageserver.js +61 -0
- package/dist/x/vscode.d.ts +126 -0
- package/dist/x/vscode.d.ts.map +1 -0
- package/dist/x/vscode.js +294 -0
- package/package.json +67 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWSDL = void 0;
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
12
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
13
|
+
var _path = require("path");
|
|
14
|
+
var _graphql = require("graphql");
|
|
15
|
+
var _parser = require("graphql/language/parser");
|
|
16
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
17
|
+
var _errors = require("../errors");
|
|
18
|
+
var _ide = require("../ide");
|
|
19
|
+
var _Array = require("../x/Array");
|
|
20
|
+
var _decorators = require("../x/decorators");
|
|
21
|
+
var _vscodeLanguageserverTypes = require("../x/vscode-languageserver-types");
|
|
22
|
+
var _RWSDLField = require("./RWSDLField");
|
|
23
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class;
|
|
24
|
+
let RWSDL = exports.RWSDL = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _dec6 = (0, _decorators.lazy)(), _class = class RWSDL extends _ide.FileNode {
|
|
25
|
+
constructor(filePath, parent) {
|
|
26
|
+
super();
|
|
27
|
+
this.filePath = filePath;
|
|
28
|
+
this.parent = parent;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The Template Literal node (string) that contains the schema
|
|
32
|
+
*/
|
|
33
|
+
get schemaStringNode() {
|
|
34
|
+
const i = this.sf.getVariableDeclaration('schema')?.getInitializer();
|
|
35
|
+
if (!i) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
// TODO: do we allow other kinds of strings? or just tagged literals?
|
|
39
|
+
if (tsm.Node.isTaggedTemplateExpression(i)) {
|
|
40
|
+
const t = i.getTemplate(); //?
|
|
41
|
+
if (tsm.Node.isNoSubstitutionTemplateLiteral(t)) {
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
get schemaString() {
|
|
48
|
+
return this.schemaStringNode?.getLiteralText();
|
|
49
|
+
}
|
|
50
|
+
get serviceFilePath() {
|
|
51
|
+
return this.parent.servicesFilePath(this.name);
|
|
52
|
+
}
|
|
53
|
+
get service() {
|
|
54
|
+
var _context;
|
|
55
|
+
return (0, _find.default)(_context = this.parent.services).call(_context, s => s.name === this.name);
|
|
56
|
+
}
|
|
57
|
+
get name() {
|
|
58
|
+
// TODO: support TS
|
|
59
|
+
const base = (0, _path.basename)(this.filePath);
|
|
60
|
+
return base.substr(0, base.length - '.sdl.js'.length);
|
|
61
|
+
}
|
|
62
|
+
get implementableFields() {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
64
|
+
const self = this;
|
|
65
|
+
return (0, _Array.iter)(function* () {
|
|
66
|
+
if (!self.schemaString) {
|
|
67
|
+
return;
|
|
68
|
+
} //?
|
|
69
|
+
const ast = (0, _parser.parse)(self.schemaString);
|
|
70
|
+
for (const def of ast.definitions) {
|
|
71
|
+
if (def.kind === _graphql.Kind.OBJECT_TYPE_DEFINITION) {
|
|
72
|
+
if (def.name.value === 'Query' || def.name.value === 'Mutation') {
|
|
73
|
+
for (const field of def.fields ?? []) {
|
|
74
|
+
yield new _RWSDLField.RWSDLField(def, field, self);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
children() {
|
|
82
|
+
return [...this.implementableFields];
|
|
83
|
+
}
|
|
84
|
+
*diagnostics() {
|
|
85
|
+
if (!this.schemaStringNode) {
|
|
86
|
+
yield (0, _vscodeLanguageserverTypes.err)(this.uri, "Each SDL file must export a variable named 'schema' with a GraphQL schema string", _errors.RWError.SCHEMA_NOT_DEFINED);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "schemaStringNode", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "schemaStringNode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "schemaString", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "schemaString"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "serviceFilePath", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "serviceFilePath"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "service", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "service"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "implementableFields", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "implementableFields"), _class.prototype), _class);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FieldDefinitionNode, ObjectTypeDefinitionNode } from 'graphql/language/ast';
|
|
2
|
+
import type { CodeAction, Location } from 'vscode-languageserver-types';
|
|
3
|
+
import type { Implementation } from '../ide';
|
|
4
|
+
import { BaseNode } from '../ide';
|
|
5
|
+
import type { ExtendedDiagnostic } from '../x/vscode-languageserver-types';
|
|
6
|
+
import type { RWSDL } from './RWSDL';
|
|
7
|
+
import type { RWServiceFunction } from './RWServiceFunction';
|
|
8
|
+
export declare class RWSDLField extends BaseNode {
|
|
9
|
+
objectTypeDef: ObjectTypeDefinitionNode;
|
|
10
|
+
field: FieldDefinitionNode;
|
|
11
|
+
parent: RWSDL;
|
|
12
|
+
constructor(objectTypeDef: ObjectTypeDefinitionNode, field: FieldDefinitionNode, parent: RWSDL);
|
|
13
|
+
get id(): string;
|
|
14
|
+
/**
|
|
15
|
+
* The location of this field.
|
|
16
|
+
* Calculating this is slightly complicated since it is embedded within a TaggedTemplateLiteral
|
|
17
|
+
*/
|
|
18
|
+
get location(): Location;
|
|
19
|
+
get name(): string;
|
|
20
|
+
get argumentNames(): string[];
|
|
21
|
+
ideInfo(): Generator<Implementation, void, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* TODO: describe in prose what is going on here.
|
|
24
|
+
* this is an important rule
|
|
25
|
+
*/
|
|
26
|
+
get impl(): RWServiceFunction | undefined;
|
|
27
|
+
private get defaultImplSnippet();
|
|
28
|
+
get quickFix_addImplementation(): CodeAction;
|
|
29
|
+
diagnostics(): Generator<ExtendedDiagnostic, void, unknown>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=RWSDLField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RWSDLField.d.ts","sourceRoot":"","sources":["../../src/model/RWSDLField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAQvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAM1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,qBAAa,UAAW,SAAQ,QAAQ;IAE7B,aAAa,EAAE,wBAAwB;IACvC,KAAK,EAAE,mBAAmB;IAC1B,MAAM,EAAE,KAAK;gBAFb,aAAa,EAAE,wBAAwB,EACvC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,KAAK;IAItB,IAAY,EAAE,WAIb;IACD;;;OAGG;IACH,IAAY,QAAQ,IAAI,QAAQ,CAQ/B;IACD,IAAY,IAAI,WAEf;IACD,IAAY,aAAa,aAExB;IACA,OAAO;IASR;;;OAGG;IACH,IAAY,IAAI,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAEO,OAAO,KAAK,kBAAkB,GAOrC;IAED,IAAY,0BAA0B,IAAI,UAAU,CAuBnD;IAEA,WAAW;CAeb"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.RWSDLField = void 0;
|
|
9
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
12
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
13
|
+
var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
|
|
14
|
+
var _errors = require("../errors");
|
|
15
|
+
var _ide = require("../ide");
|
|
16
|
+
var _decorators = require("../x/decorators");
|
|
17
|
+
var _URL = require("../x/URL");
|
|
18
|
+
var _vscodeLanguageserverTypes2 = require("../x/vscode-languageserver-types");
|
|
19
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class;
|
|
20
|
+
let RWSDLField = exports.RWSDLField = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _class = class RWSDLField extends _ide.BaseNode {
|
|
21
|
+
constructor(objectTypeDef, field, parent) {
|
|
22
|
+
super();
|
|
23
|
+
this.objectTypeDef = objectTypeDef;
|
|
24
|
+
this.field = field;
|
|
25
|
+
this.parent = parent;
|
|
26
|
+
}
|
|
27
|
+
get id() {
|
|
28
|
+
return this.parent.id + ' ' + this.objectTypeDef.name.value + '.' + this.name;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The location of this field.
|
|
32
|
+
* Calculating this is slightly complicated since it is embedded within a TaggedTemplateLiteral
|
|
33
|
+
*/
|
|
34
|
+
get location() {
|
|
35
|
+
let {
|
|
36
|
+
start,
|
|
37
|
+
end
|
|
38
|
+
} = this.field.loc;
|
|
39
|
+
const node = this.parent.schemaStringNode;
|
|
40
|
+
start += node.getPos() + 1; // we add one to account for the quote (`)
|
|
41
|
+
end += node.getPos() + 1;
|
|
42
|
+
const startPos = (0, _vscodeLanguageserverTypes2.Position_fromTSMorphOffset)(start, node.getSourceFile());
|
|
43
|
+
const endPos = (0, _vscodeLanguageserverTypes2.Position_fromTSMorphOffset)(end, node.getSourceFile());
|
|
44
|
+
return {
|
|
45
|
+
uri: this.parent.uri,
|
|
46
|
+
range: {
|
|
47
|
+
start: startPos,
|
|
48
|
+
end: endPos
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
get name() {
|
|
53
|
+
return this.field.name.value;
|
|
54
|
+
}
|
|
55
|
+
get argumentNames() {
|
|
56
|
+
var _context;
|
|
57
|
+
return (0, _map.default)(_context = this.field.arguments ?? []).call(_context, a => a.name.value);
|
|
58
|
+
}
|
|
59
|
+
*ideInfo() {
|
|
60
|
+
if (this.impl) {
|
|
61
|
+
yield {
|
|
62
|
+
kind: 'Implementation',
|
|
63
|
+
location: this.location,
|
|
64
|
+
target: (0, _vscodeLanguageserverTypes2.Location_fromNode)(this.impl.node)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* TODO: describe in prose what is going on here.
|
|
70
|
+
* this is an important rule
|
|
71
|
+
*/
|
|
72
|
+
get impl() {
|
|
73
|
+
var _context2;
|
|
74
|
+
return (0, _find.default)(_context2 = this.parent.service?.funcs ?? []).call(_context2, f => f.name === this.name);
|
|
75
|
+
}
|
|
76
|
+
// TODO: improve snippet
|
|
77
|
+
get defaultImplSnippet() {
|
|
78
|
+
const args = this.field.arguments ?? [];
|
|
79
|
+
const params = (0, _map.default)(args).call(args, a => a.name.value).join(',');
|
|
80
|
+
return `
|
|
81
|
+
export const ${this.field.name.value} = ({${params}}) => {
|
|
82
|
+
// TODO: implement
|
|
83
|
+
}`;
|
|
84
|
+
}
|
|
85
|
+
get quickFix_addImplementation() {
|
|
86
|
+
const {
|
|
87
|
+
service
|
|
88
|
+
} = this.parent;
|
|
89
|
+
const change = new _vscodeLanguageserverTypes.WorkspaceChange({
|
|
90
|
+
documentChanges: []
|
|
91
|
+
});
|
|
92
|
+
let insertPosition = _vscodeLanguageserverTypes.Position.create(0, 0);
|
|
93
|
+
let uri = (0, _URL.URL_file)(this.parent.serviceFilePath);
|
|
94
|
+
if (service) {
|
|
95
|
+
// we'll insert into the end of an existing file
|
|
96
|
+
const lastLine = service.sf.getEndLineNumber();
|
|
97
|
+
insertPosition = _vscodeLanguageserverTypes.Position.create(lastLine, 0);
|
|
98
|
+
uri = service.uri;
|
|
99
|
+
} else {
|
|
100
|
+
// file doesn't exist
|
|
101
|
+
// create the service file before inserting
|
|
102
|
+
change.createFile(uri);
|
|
103
|
+
}
|
|
104
|
+
// insert
|
|
105
|
+
change.getTextEditChange({
|
|
106
|
+
uri,
|
|
107
|
+
version: null
|
|
108
|
+
}).insert(insertPosition, this.defaultImplSnippet);
|
|
109
|
+
return {
|
|
110
|
+
title: 'Add implementation',
|
|
111
|
+
edit: change.edit
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
*diagnostics() {
|
|
115
|
+
if (!this.impl) {
|
|
116
|
+
const {
|
|
117
|
+
uri,
|
|
118
|
+
range
|
|
119
|
+
} = this.location;
|
|
120
|
+
yield {
|
|
121
|
+
uri,
|
|
122
|
+
diagnostic: {
|
|
123
|
+
range,
|
|
124
|
+
message: 'Service Not Implemented',
|
|
125
|
+
severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
|
|
126
|
+
code: _errors.RWError.SERVICE_NOT_IMPLEMENTED
|
|
127
|
+
},
|
|
128
|
+
quickFix: async () => this.quickFix_addImplementation
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "location", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "location"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "argumentNames", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "argumentNames"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "impl", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "impl"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "defaultImplSnippet", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "defaultImplSnippet"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "quickFix_addImplementation", [_dec7], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "quickFix_addImplementation"), _class.prototype), _class);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FileNode } from '../ide';
|
|
2
|
+
import type { RWProject } from './RWProject';
|
|
3
|
+
import type { RWSDL } from './RWSDL';
|
|
4
|
+
import { RWServiceFunction } from './RWServiceFunction';
|
|
5
|
+
export declare class RWService extends FileNode {
|
|
6
|
+
filePath: string;
|
|
7
|
+
parent: RWProject;
|
|
8
|
+
constructor(filePath: string, parent: RWProject);
|
|
9
|
+
/**
|
|
10
|
+
* The name of this service:
|
|
11
|
+
* services/todos/todos.js --> todos
|
|
12
|
+
*/
|
|
13
|
+
get name(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the SDL associated with this service (if any).
|
|
16
|
+
* Match is performed by name.
|
|
17
|
+
*/
|
|
18
|
+
get sdl(): RWSDL | undefined;
|
|
19
|
+
children(): RWServiceFunction[];
|
|
20
|
+
/**
|
|
21
|
+
* All the exported functions declared in this service file.
|
|
22
|
+
* They can be both ArrowFunctions (with name) or FunctionDeclarations (with name)
|
|
23
|
+
*/
|
|
24
|
+
get funcs(): RWServiceFunction[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=RWService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RWService.d.ts","sourceRoot":"","sources":["../../src/model/RWService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAKjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,qBAAa,SAAU,SAAQ,QAAQ;IAE5B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAI1B;;;OAGG;IACH,IAAY,IAAI,WAEf;IAED;;;OAGG;IAEH,IAAY,GAAG,IAAI,KAAK,GAAG,SAAS,CAEnC;IAED,QAAQ;IAIR;;;OAGG;IAEH,IAAY,KAAK,wBAuBhB;CACF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWService = void 0;
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
12
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
13
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
14
|
+
var _ide = require("../ide");
|
|
15
|
+
var _Array = require("../x/Array");
|
|
16
|
+
var _decorators = require("../x/decorators");
|
|
17
|
+
var _path = require("../x/path");
|
|
18
|
+
var _RWServiceFunction = require("./RWServiceFunction");
|
|
19
|
+
var _dec, _dec2, _dec3, _class;
|
|
20
|
+
let RWService = exports.RWService = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _class = class RWService extends _ide.FileNode {
|
|
21
|
+
constructor(filePath, parent) {
|
|
22
|
+
super();
|
|
23
|
+
this.filePath = filePath;
|
|
24
|
+
this.parent = parent;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The name of this service:
|
|
28
|
+
* services/todos/todos.js --> todos
|
|
29
|
+
*/
|
|
30
|
+
get name() {
|
|
31
|
+
return (0, _path.basenameNoExt)(this.filePath);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the SDL associated with this service (if any).
|
|
36
|
+
* Match is performed by name.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
get sdl() {
|
|
40
|
+
var _context;
|
|
41
|
+
return (0, _find.default)(_context = this.parent.sdls).call(_context, sdl => sdl.name === this.name);
|
|
42
|
+
}
|
|
43
|
+
children() {
|
|
44
|
+
return [...this.funcs];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* All the exported functions declared in this service file.
|
|
49
|
+
* They can be both ArrowFunctions (with name) or FunctionDeclarations (with name)
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
get funcs() {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
54
|
+
const self = this;
|
|
55
|
+
return (0, _Array.iter)(function* () {
|
|
56
|
+
// export const foo = () => {}
|
|
57
|
+
for (const vd of self.sf.getVariableDeclarations()) {
|
|
58
|
+
if (vd.isExported()) {
|
|
59
|
+
const init = vd.getInitializerIfKind(tsm.SyntaxKind.ArrowFunction);
|
|
60
|
+
if (init) {
|
|
61
|
+
yield new _RWServiceFunction.RWServiceFunction(vd.getName(), init, self);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// export function foo(){}
|
|
66
|
+
for (const fd of self.sf.getFunctions()) {
|
|
67
|
+
if (fd.isExported() && !fd.isDefaultExport()) {
|
|
68
|
+
const nn = fd.getNameNode();
|
|
69
|
+
if (nn) {
|
|
70
|
+
yield new _RWServiceFunction.RWServiceFunction(nn.getText(), fd, self);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sdl", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sdl"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "funcs", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "funcs"), _class.prototype), _class);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as tsm from 'ts-morph';
|
|
2
|
+
import { BaseNode } from '../ide';
|
|
3
|
+
import type { ExtendedDiagnostic } from '../x/vscode-languageserver-types';
|
|
4
|
+
import type { RWSDLField } from './RWSDLField';
|
|
5
|
+
import type { RWService } from './RWService';
|
|
6
|
+
export declare class RWServiceFunction extends BaseNode {
|
|
7
|
+
name: string;
|
|
8
|
+
node: tsm.FunctionDeclaration | tsm.ArrowFunction;
|
|
9
|
+
parent: RWService;
|
|
10
|
+
constructor(name: string, node: tsm.FunctionDeclaration | tsm.ArrowFunction, parent: RWService);
|
|
11
|
+
get id(): string;
|
|
12
|
+
/**
|
|
13
|
+
* The SDL field that this function implements, if any
|
|
14
|
+
* TODO: describe this in prose.
|
|
15
|
+
*/
|
|
16
|
+
get sdlField(): RWSDLField | undefined;
|
|
17
|
+
get parameterNames(): string[];
|
|
18
|
+
diagnostics(): Generator<ExtendedDiagnostic, void, unknown>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=RWServiceFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RWServiceFunction.d.ts","sourceRoot":"","sources":["../../src/model/RWServiceFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAG1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,iBAAkB,SAAQ,QAAQ;IAEpC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,GAAG,CAAC,mBAAmB,GAAG,GAAG,CAAC,aAAa;IACjD,MAAM,EAAE,SAAS;gBAFjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,GAAG,CAAC,mBAAmB,GAAG,GAAG,CAAC,aAAa,EACjD,MAAM,EAAE,SAAS;IAK1B,IAAY,EAAE,WAGb;IAED;;;OAGG;IAEH,IAAY,QAAQ,IAAI,UAAU,GAAG,SAAS,CAI7C;IAED,IAAY,cAAc,aAczB;IAEA,WAAW;CAwCb"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWServiceFunction = void 0;
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
|
|
11
|
+
var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/bind"));
|
|
12
|
+
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/sort"));
|
|
13
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
14
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
15
|
+
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
16
|
+
var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
|
|
17
|
+
var _ide = require("../ide");
|
|
18
|
+
var _Array = require("../x/Array");
|
|
19
|
+
var _decorators = require("../x/decorators");
|
|
20
|
+
var _vscodeLanguageserverTypes2 = require("../x/vscode-languageserver-types");
|
|
21
|
+
var _dec, _dec2, _dec3, _class;
|
|
22
|
+
let RWServiceFunction = exports.RWServiceFunction = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _class = class RWServiceFunction extends _ide.BaseNode {
|
|
23
|
+
constructor(name, node, parent) {
|
|
24
|
+
super();
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.node = node;
|
|
27
|
+
this.parent = parent;
|
|
28
|
+
}
|
|
29
|
+
get id() {
|
|
30
|
+
// This is a compound ID (because it points to an internal node - one within a file)
|
|
31
|
+
return this.parent.id + ' ' + this.name;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The SDL field that this function implements, if any
|
|
36
|
+
* TODO: describe this in prose.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
get sdlField() {
|
|
40
|
+
var _context, _context2;
|
|
41
|
+
return ((_context = this.parent.sdl?.implementableFields) == null ? void 0 : (0, _bind.default)(_context2 = Function.call).call(_context2, (0, _find.default)(_context), _context))?.(f => f.name === this.name);
|
|
42
|
+
}
|
|
43
|
+
get parameterNames() {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
45
|
+
const self = this;
|
|
46
|
+
return (0, _Array.iter)(function* () {
|
|
47
|
+
for (const p of self.node.getParameters()) {
|
|
48
|
+
const nn = p.getNameNode();
|
|
49
|
+
if (nn instanceof tsm.ObjectBindingPattern) {
|
|
50
|
+
for (const element of nn.getElements()) {
|
|
51
|
+
yield element.getNameNode().getText();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// TODO: handle other cases
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
*diagnostics() {
|
|
59
|
+
if (this.sdlField) {
|
|
60
|
+
var _context3, _context4;
|
|
61
|
+
// this service function is implementing a field
|
|
62
|
+
// parameter names should match
|
|
63
|
+
const p1 = (0, _sort.default)(_context3 = this.sdlField.argumentNames).call(_context3).join(' '); //?
|
|
64
|
+
const p2 = (0, _sort.default)(_context4 = this.parameterNames).call(_context4).join(' '); //?
|
|
65
|
+
if (p1 !== p2) {
|
|
66
|
+
const locationNode = this.node.getParameters()[0] ?? this.node;
|
|
67
|
+
const {
|
|
68
|
+
uri,
|
|
69
|
+
range
|
|
70
|
+
} = (0, _vscodeLanguageserverTypes2.Location_fromNode)(locationNode);
|
|
71
|
+
const message = `Parameter mismatch between SDL and implementation ("${p1}" !== "${p2}")`;
|
|
72
|
+
const diagnostic = {
|
|
73
|
+
uri,
|
|
74
|
+
diagnostic: {
|
|
75
|
+
range,
|
|
76
|
+
message,
|
|
77
|
+
severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
|
|
78
|
+
// add related information so developers can jump to the SDL definition
|
|
79
|
+
relatedInformation: [{
|
|
80
|
+
location: this.sdlField.location,
|
|
81
|
+
message: 'SDL field is defined here'
|
|
82
|
+
}]
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
// comment out for now (see https://github.com/redwoodjs/redwood/issues/943)
|
|
86
|
+
|
|
87
|
+
// comment out for now (see https://github.com/redwoodjs/redwood/issues/943)
|
|
88
|
+
// eslint-disable-next-line no-constant-condition
|
|
89
|
+
if (false) {
|
|
90
|
+
yield diagnostic;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// TODO: check that types match
|
|
95
|
+
// to do this it is probably easier to leverage a graphql code generator and the typescript compiler
|
|
96
|
+
// the trick is to create a source file with an interface assignment that will fail if there is a mismatch
|
|
97
|
+
// we then simply "bubble up" the type errors from the typescript compiler
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "sdlField", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "sdlField"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "parameterNames", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "parameterNames"), _class.prototype), _class);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as toml from 'smol-toml';
|
|
2
|
+
import { FileNode } from '../ide';
|
|
3
|
+
import type { RWProject } from './RWProject';
|
|
4
|
+
export declare class RWTOML extends FileNode {
|
|
5
|
+
filePath: string;
|
|
6
|
+
parent: RWProject;
|
|
7
|
+
constructor(filePath: string, parent: RWProject);
|
|
8
|
+
get parsedTOML(): Record<string, toml.TomlPrimitive>;
|
|
9
|
+
get web_includeEnvironmentVariables(): string[] | undefined;
|
|
10
|
+
diagnostics(): Generator<import("../x/vscode-languageserver-types").ExtendedDiagnostic, void, unknown>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=RWTOML.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RWTOML.d.ts","sourceRoot":"","sources":["../../src/model/RWTOML.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAGjC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAIjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,MAAO,SAAQ,QAAQ;IAEzB,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAQ1B,IAAY,UAAU,uCAErB;IACD,IAAY,+BAA+B,IAAI,MAAM,EAAE,GAAG,SAAS,CAElE;IACA,WAAW;CAgBb"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWTOML = void 0;
|
|
10
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
11
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
12
|
+
var toml = _interopRequireWildcard(require("smol-toml"));
|
|
13
|
+
var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
|
|
14
|
+
var _ide = require("../ide");
|
|
15
|
+
var _decorators = require("../x/decorators");
|
|
16
|
+
var _vscodeLanguageserverTypes2 = require("../x/vscode-languageserver-types");
|
|
17
|
+
var _dec, _dec2, _class;
|
|
18
|
+
let RWTOML = exports.RWTOML = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _class = class RWTOML extends _ide.FileNode {
|
|
19
|
+
constructor(filePath, parent) {
|
|
20
|
+
super();
|
|
21
|
+
this.filePath = filePath;
|
|
22
|
+
this.parent = parent;
|
|
23
|
+
}
|
|
24
|
+
// @lazy() get content(): TOML.JsonMap {
|
|
25
|
+
// return TOML.parse(this.text)
|
|
26
|
+
// }
|
|
27
|
+
// TODO: diagnostics
|
|
28
|
+
get parsedTOML() {
|
|
29
|
+
return toml.parse(this.text);
|
|
30
|
+
}
|
|
31
|
+
get web_includeEnvironmentVariables() {
|
|
32
|
+
return this.parsedTOML?.web?.['includeEnvironmentVariables'] ?? [];
|
|
33
|
+
}
|
|
34
|
+
*diagnostics() {
|
|
35
|
+
try {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
37
|
+
this.parsedTOML;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
const pos = {
|
|
40
|
+
line: e.line - 1,
|
|
41
|
+
character: e.column - 1
|
|
42
|
+
};
|
|
43
|
+
const range = _vscodeLanguageserverTypes.Range.create(pos, pos);
|
|
44
|
+
// Forward the TOML parse error with correct location information
|
|
45
|
+
yield (0, _vscodeLanguageserverTypes2.err)({
|
|
46
|
+
uri: this.uri,
|
|
47
|
+
range
|
|
48
|
+
}, 'TOML Parser Error: ' + e.message);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// at this point we know that the TOML was parsed successfully
|
|
52
|
+
//this.parsedTOML //?
|
|
53
|
+
//const allowedTopElements = ['web', 'api']
|
|
54
|
+
// TODO: check that schema is correct
|
|
55
|
+
}
|
|
56
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "parsedTOML", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "parsedTOML"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "web_includeEnvironmentVariables", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "web_includeEnvironmentVariables"), _class.prototype), _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
_Object$defineProperty(exports, "RWProject", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _RWProject.RWProject;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _RWProject = require("./RWProject");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A route path parser with positional information.
|
|
3
|
+
* Used to enable decorations
|
|
4
|
+
* @param route
|
|
5
|
+
*/
|
|
6
|
+
export declare function advanced_path_parser(route: string): {
|
|
7
|
+
punctuationIndexes: number[];
|
|
8
|
+
slashIndexes: number[];
|
|
9
|
+
paramRanges: [number, number][];
|
|
10
|
+
paramTypeRanges: [number, number][];
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=advanced_path_parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced_path_parser.d.ts","sourceRoot":"","sources":["../../../src/model/util/advanced_path_parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM;;;;;EAejD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.advanced_path_parser = advanced_path_parser;
|
|
9
|
+
require("core-js/modules/es.array.push.js");
|
|
10
|
+
var _matchAll = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/match-all"));
|
|
11
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
|
|
12
|
+
/**
|
|
13
|
+
* A route path parser with positional information.
|
|
14
|
+
* Used to enable decorations
|
|
15
|
+
* @param route
|
|
16
|
+
*/
|
|
17
|
+
function advanced_path_parser(route) {
|
|
18
|
+
var _context, _context2;
|
|
19
|
+
const paramRanges = [];
|
|
20
|
+
const paramTypeRanges = [];
|
|
21
|
+
for (const param of (0, _matchAll.default)(route).call(route, /\{([^}]+)\}/g)) {
|
|
22
|
+
const [paramName, paramType] = param[1].split(':');
|
|
23
|
+
const index = param.index + 1;
|
|
24
|
+
paramRanges.push([index, index + paramName.length]);
|
|
25
|
+
if (paramType) {
|
|
26
|
+
const typeIndex = index + paramName.length + 2;
|
|
27
|
+
paramTypeRanges.push([typeIndex, typeIndex + paramType.length]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const punctuationIndexes = (0, _map.default)(_context = [...(0, _matchAll.default)(route).call(route, /[{}:]/g)]).call(_context, x => x.index);
|
|
31
|
+
const slashIndexes = (0, _map.default)(_context2 = [...(0, _matchAll.default)(route).call(route, /[\/]/g)]).call(_context2, x => x.index);
|
|
32
|
+
return {
|
|
33
|
+
punctuationIndexes,
|
|
34
|
+
slashIndexes,
|
|
35
|
+
paramRanges,
|
|
36
|
+
paramTypeRanges
|
|
37
|
+
};
|
|
38
|
+
}
|