-
Notifications
You must be signed in to change notification settings - Fork 0
Changed and broke stuff #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,111 +0,0 @@ | ||
| import { Kind, parse as parseGraphQL } from 'graphql' | ||
| import * as tsm from 'ts-morph' | ||
| import { DiagnosticSeverity } from 'vscode-languageserver-types' | ||
|
|
||
| import { lazy } from '../x/decorators' | ||
| import { err, Range_fromNode } from '../x/vscode-languageserver-types' | ||
|
|
||
| import { RWComponent } from './RWComponent' | ||
|
|
||
| export class RWCell extends RWComponent { | ||
| /** | ||
| * A "Cell" is a component that ends in `Cell.{js, jsx, tsx}`, has no | ||
| * default export AND exports `QUERY` | ||
| **/ | ||
| @lazy() get isCell() { | ||
| return !this.hasDefaultExport && this.exportedSymbols.has('QUERY') | ||
| } | ||
|
|
||
| // TODO: Move to RWCellQuery | ||
| @lazy() get queryStringNode() { | ||
| const i = this.sf.getVariableDeclaration('QUERY')?.getInitializer() | ||
| if (!i) { | ||
| return undefined | ||
| } | ||
| // TODO: do we allow other kinds of strings? or just tagged literals? | ||
| if (tsm.Node.isTaggedTemplateExpression(i)) { | ||
| const t = i.getTemplate() | ||
| if (tsm.Node.isNoSubstitutionTemplateLiteral(t)) { | ||
| return t | ||
| } | ||
| } | ||
| return undefined | ||
| } | ||
|
|
||
| // TODO: Move to RWCellQuery | ||
| @lazy() get queryString(): string | undefined { | ||
| return this.queryStringNode?.getLiteralText() | ||
| } | ||
|
|
||
| // TODO: Move to RWCellQuery | ||
| @lazy() get queryAst() { | ||
| const qs = this.queryString | ||
| if (!qs) { | ||
| return undefined | ||
| } | ||
|
|
||
| try { | ||
| return parseGraphQL(qs) | ||
| } catch (e) { | ||
| console.error("Can't parse the graphql query string in", this.filePath) | ||
| console.error(e) | ||
| return undefined | ||
| } | ||
| } | ||
|
|
||
| // TODO: Move to RWCellQuery | ||
| @lazy() get queryOperationName(): string | undefined { | ||
| const ast = this.queryAst | ||
| if (!ast) { | ||
| return undefined | ||
| } | ||
| for (const def of ast.definitions) { | ||
| if (def.kind == Kind.OPERATION_DEFINITION) { | ||
| return def?.name?.value | ||
| } | ||
| } | ||
| return undefined | ||
| } | ||
|
|
||
| *diagnostics() { | ||
| // check that QUERY and Success are exported | ||
| if (!this.exportedSymbols.has('QUERY')) { | ||
| yield err( | ||
| this.uri, | ||
| 'Every Cell MUST export a QUERY variable (GraphQL query string)', | ||
| ) | ||
| } | ||
|
|
||
| try { | ||
| if (!this.queryOperationName) { | ||
| yield { | ||
| uri: this.uri, | ||
| diagnostic: { | ||
| range: Range_fromNode(this.queryStringNode!), | ||
| message: 'We recommend that you name your query operation', | ||
| severity: DiagnosticSeverity.Warning, | ||
| }, | ||
| } | ||
| } | ||
| } catch (e: any) { | ||
| // Maybe the AST has a syntax error... | ||
| yield { | ||
| uri: this.uri, | ||
| diagnostic: { | ||
| // TODO: Try to figure out if we can point directly to the syntax error. | ||
| range: Range_fromNode(this.sf.getVariableDeclaration('QUERY')!), | ||
| message: e.message, | ||
| severity: DiagnosticSeverity.Error, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| // TODO: check that exported QUERY is semantically valid GraphQL (fields exist) | ||
| if (!this.exportedSymbols.has('Success')) { | ||
| yield err( | ||
| this.uri, | ||
| 'Every Cell MUST export a Success variable (React Component)', | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,4 @@ import type { RWProject } from './RWProject' | |
| * layouts live in the src/layouts folder | ||
| */ | ||
| export class RWLayout extends FileNode { | ||
| constructor( | ||
| public filePath: string, | ||
| public parent: RWProject, | ||
| ) { | ||
| super() | ||
| } | ||
| } | ||
| const | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line 'const' is incomplete and causes a syntax error. It should be removed or completed with a valid declaration. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,15 +14,7 @@ import { iter } from '../x/Array' | |
| import { lazy, memo } from '../x/decorators' | ||
| import { URL_file } from '../x/URL' | ||
| import type { ExtendedDiagnostic } from '../x/vscode-languageserver-types' | ||
| import { | ||
| err, | ||
| LocationLike_toLocation, | ||
| Location_fromNode, | ||
| } from '../x/vscode-languageserver-types' | ||
|
|
||
| import type { RWProject } from './RWProject' | ||
| import { RWRoute } from './RWRoute' | ||
|
|
||
| imp | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import statement on this line is incomplete and seems to be a mistake. It should be removed or completed. |
||
| /** | ||
| * one per Routes.js | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +0,0 @@ | ||
| export { RWProject } from './RWProject' | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code block is malformed, likely due to accidental deletion or corruption. This will cause a syntax error.
Suggestion: