From 7dc1c1cbb8262ab4e6e83ba85726dcc4501b3edc Mon Sep 17 00:00:00 2001 From: Aofei Sheng Date: Thu, 23 Jan 2025 08:59:19 +0800 Subject: [PATCH] docs: correct grammar by using "an spx" instead of "a spx" Signed-off-by: Aofei Sheng --- spx-backend/internal/copilot/system_prompt.md | 4 +-- tools/spxls/README.md | 4 +-- tools/spxls/internal/server/compile.go | 20 +++++++------- .../spxls/internal/server/diagnostic_test.go | 2 +- tools/spxls/internal/server/format.go | 4 +-- tools/spxls/internal/server/format_test.go | 24 ++++++++--------- tools/spxls/internal/server/protocol.go | 12 ++++----- tools/spxls/internal/server/rename.go | 12 ++++----- tools/spxls/internal/server/spx_resource.go | 26 +++++++++---------- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/spx-backend/internal/copilot/system_prompt.md b/spx-backend/internal/copilot/system_prompt.md index ec7b24016..811976337 100644 --- a/spx-backend/internal/copilot/system_prompt.md +++ b/spx-backend/internal/copilot/system_prompt.md @@ -151,9 +151,9 @@ Under the hood, Go+ classfiles will be compiled into Go code with `struct` and m spx is a Scratch-like 2D Game Engine for STEM education. It is designed for children to learn programming by developing games. spx is developed based on Go+ classfiles. In spx, there are two types of classes: `Game` classes and `Sprite` classes. -The `Game` class is the "project class" that represents the whole game. In a spx project, there is only one code file (named `main.spx`) for the `Game` class. We call it code for "the stage". Variables & functions declared in the stage code can be accessed by all game objects. +The `Game` class is the "project class" that represents the whole game. In an spx project, there is only one code file (named `main.spx`) for the `Game` class. We call it code for "the stage". Variables & functions declared in the stage code can be accessed by all game objects. -The `Sprite` classes are "worker classes" which are used to define game objects. In a spx project, there can be multiple code files for `Sprite` classes. Each `Sprite` class has its own code file, named after the sprite's name, e.g., `Apple.spx`, `Banana.spx`. Variables & functions declared in a sprite's code can only be accessed by that sprite. +The `Sprite` classes are "worker classes" which are used to define game objects. In an spx project, there can be multiple code files for `Sprite` classes. Each `Sprite` class has its own code file, named after the sprite's name, e.g., `Apple.spx`, `Banana.spx`. Variables & functions declared in a sprite's code can only be accessed by that sprite. In document `spx-defs.md`, you can find definitions for most APIs of spx game engine. diff --git a/tools/spxls/README.md b/tools/spxls/README.md index 4a951e19c..b253a4afc 100644 --- a/tools/spxls/README.md +++ b/tools/spxls/README.md @@ -95,7 +95,7 @@ interface ExecuteCommandParams { ```typescript /** - * Parameters to rename a spx resource in the workspace. + * Parameters to rename an spx resource in the workspace. */ interface SpxRenameResourceParams { /** @@ -217,7 +217,7 @@ interface SpxDefinitionIdentifier { ```typescript /** - * The data of a spx resource reference DocumentLink. + * The data of an spx resource reference DocumentLink. */ interface SpxResourceRefDocumentLinkData { /** diff --git a/tools/spxls/internal/server/compile.go b/tools/spxls/internal/server/compile.go index 453e7f944..40108f953 100644 --- a/tools/spxls/internal/server/compile.go +++ b/tools/spxls/internal/server/compile.go @@ -469,7 +469,7 @@ func (r *compileResult) spxResourceRefAtASTFilePosition(astFile *gopast.File, po return bestRef } -// addSpxResourceRef adds a spx resource reference to the compile result. +// addSpxResourceRef adds an spx resource reference to the compile result. func (r *compileResult) addSpxResourceRef(ref SpxResourceRef) { if r.seenSpxResourceRefs == nil { r.seenSpxResourceRefs = make(map[SpxResourceRef]struct{}) @@ -997,7 +997,7 @@ func (s *Server) inspectForSpxResourceRefs(result *compileResult) { } } -// inspectSpxResourceRefForTypeAtExpr inspects a spx resource reference for a +// inspectSpxResourceRefForTypeAtExpr inspects an spx resource reference for a // given type at an expression. func (s *Server) inspectSpxResourceRefForTypeAtExpr(result *compileResult, expr gopast.Expr, typ types.Type, spxSpriteResource *SpxSpriteResource) { switch typ.String() { @@ -1020,7 +1020,7 @@ func (s *Server) inspectSpxResourceRefForTypeAtExpr(result *compileResult, expr } } -// inspectSpxBackdropResourceRefAtExpr inspects a spx backdrop resource +// inspectSpxBackdropResourceRefAtExpr inspects an spx backdrop resource // reference at an expression. It returns the spx backdrop resource if it was // successfully retrieved. func (s *Server) inspectSpxBackdropResourceRefAtExpr(result *compileResult, expr gopast.Expr, declaredType types.Type) *SpxBackdropResource { @@ -1065,8 +1065,8 @@ func (s *Server) inspectSpxBackdropResourceRefAtExpr(result *compileResult, expr return spxBackdropResource } -// inspectSpxSpriteResourceRefAtExpr inspects a spx sprite resource reference at -// an expression. It returns the spx sprite resource if it was successfully +// inspectSpxSpriteResourceRefAtExpr inspects an spx sprite resource reference +// at an expression. It returns the spx sprite resource if it was successfully // retrieved. func (s *Server) inspectSpxSpriteResourceRefAtExpr(result *compileResult, expr gopast.Expr, declaredType types.Type) *SpxSpriteResource { documentURI := s.toDocumentURI(result.fset.Position(expr.Pos()).Filename) @@ -1174,7 +1174,7 @@ func (s *Server) inspectSpxSpriteResourceRefAtExpr(result *compileResult, expr g return spxSpriteResource } -// inspectSpxSpriteCostumeResourceRefAtExpr inspects a spx sprite costume +// inspectSpxSpriteCostumeResourceRefAtExpr inspects an spx sprite costume // resource reference at an expression. It returns the spx sprite costume // resource if it was successfully retrieved. func (s *Server) inspectSpxSpriteCostumeResourceRefAtExpr(result *compileResult, spxSpriteResource *SpxSpriteResource, expr gopast.Expr, declaredType types.Type) *SpxSpriteCostumeResource { @@ -1236,7 +1236,7 @@ func (s *Server) inspectSpxSpriteCostumeResourceRefAtExpr(result *compileResult, return spxSpriteCostumeResource } -// inspectSpxSpriteAnimationResourceRefAtExpr inspects a spx sprite animation +// inspectSpxSpriteAnimationResourceRefAtExpr inspects an spx sprite animation // resource reference at an expression. It returns the spx sprite animation // resource if it was successfully retrieved. func (s *Server) inspectSpxSpriteAnimationResourceRefAtExpr(result *compileResult, spxSpriteResource *SpxSpriteResource, expr gopast.Expr, declaredType types.Type) *SpxSpriteAnimationResource { @@ -1298,7 +1298,7 @@ func (s *Server) inspectSpxSpriteAnimationResourceRefAtExpr(result *compileResul return spxSpriteAnimationResource } -// inspectSpxSoundResourceRefAtExpr inspects a spx sound resource reference at +// inspectSpxSoundResourceRefAtExpr inspects an spx sound resource reference at // an expression. It returns the spx sound resource if it was successfully // retrieved. func (s *Server) inspectSpxSoundResourceRefAtExpr(result *compileResult, expr gopast.Expr, declaredType types.Type) *SpxSoundResource { @@ -1374,8 +1374,8 @@ func (s *Server) inspectSpxSoundResourceRefAtExpr(result *compileResult, expr go return spxSoundResource } -// inspectSpxWidgetResourceRefAtExpr inspects a spx widget resource reference at -// an expression. It returns the spx widget resource if it was successfully +// inspectSpxWidgetResourceRefAtExpr inspects an spx widget resource reference +// at an expression. It returns the spx widget resource if it was successfully // retrieved. func (s *Server) inspectSpxWidgetResourceRefAtExpr(result *compileResult, expr gopast.Expr, declaredType types.Type) *SpxWidgetResource { documentURI := s.toDocumentURI(result.fset.Position(expr.Pos()).Filename) diff --git a/tools/spxls/internal/server/diagnostic_test.go b/tools/spxls/internal/server/diagnostic_test.go index 5001a8f03..eb2c5f30a 100644 --- a/tools/spxls/internal/server/diagnostic_test.go +++ b/tools/spxls/internal/server/diagnostic_test.go @@ -628,7 +628,7 @@ run "assets", {Title: "My Game"} t.Run("NoTypeSpriteVarDeclaration", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ - "main.spx": []byte(`// A spx game. + "main.spx": []byte(`// An spx game. var ( MySprite diff --git a/tools/spxls/internal/server/format.go b/tools/spxls/internal/server/format.go index 5229376d2..15c54e140 100644 --- a/tools/spxls/internal/server/format.go +++ b/tools/spxls/internal/server/format.go @@ -19,7 +19,7 @@ func (s *Server) textDocumentFormatting(params *DocumentFormattingParams) ([]Tex return nil, fmt.Errorf("failed to get path from document uri: %w", err) } if path.Ext(spxFile) != ".spx" { - return nil, nil // Not a spx source file. + return nil, nil // Not an spx source file. } formatted, original, err := s.formatSpx(spxFile) @@ -49,7 +49,7 @@ func (s *Server) textDocumentFormatting(params *DocumentFormattingParams) ([]Tex }, nil } -// formatSpx formats a spx source file. If no change is needed, it returns `(nil, nil, nil)`. +// formatSpx formats an spx source file. If no change is needed, it returns `(nil, nil, nil)`. func (s *Server) formatSpx(spxFileName string) (formatted, original []byte, err error) { // Parse the source into AST. compileResult, err := s.compile() diff --git a/tools/spxls/internal/server/format_test.go b/tools/spxls/internal/server/format_test.go index 5fa6f52b9..56941f965 100644 --- a/tools/spxls/internal/server/format_test.go +++ b/tools/spxls/internal/server/format_test.go @@ -11,7 +11,7 @@ func TestServerTextDocumentFormatting(t *testing.T) { t.Run("Normal", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ "main.spx": []byte(` -// A spx game. +// An spx game. var ( MyAircraft MyAircraft @@ -33,7 +33,7 @@ run "assets", { Title: "Bullet (by Go+)" } Start: Position{Line: 0, Character: 0}, End: Position{Line: 9, Character: 0}, }, - NewText: `// A spx game. + NewText: `// An spx game. type Score int @@ -86,7 +86,7 @@ run "assets", {Title: "Bullet (by Go+)"} t.Run("AcceptableFormatError", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ - "main.spx": []byte(`// A spx game. + "main.spx": []byte(`// An spx game. var MyAircraft MyAircraft !InvalidSyntax @@ -104,7 +104,7 @@ var MyAircraft MyAircraft Start: Position{Line: 0, Character: 0}, End: Position{Line: 4, Character: 0}, }, - NewText: `// A spx game. + NewText: `// An spx game. var ( MyAircraft MyAircraft @@ -117,7 +117,7 @@ var ( t.Run("WithFormatSpx", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ - "main.spx": []byte(`// A spx game. + "main.spx": []byte(`// An spx game. var ( // The aircraft. @@ -160,7 +160,7 @@ var ( Start: Position{Line: 0, Character: 0}, End: Position{Line: 29, Character: 0}, }, - NewText: `// A spx game. + NewText: `// An spx game. var ( // The aircraft. @@ -191,7 +191,7 @@ var ( t.Run("NoTypeSpriteVarDeclaration", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ - "main.spx": []byte(`// A spx game. + "main.spx": []byte(`// An spx game. var ( MySprite @@ -211,7 +211,7 @@ run "assets", {Title: "My Game"} t.Run("WithImportStmt", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ - "main.spx": []byte(`// A spx game. + "main.spx": []byte(`// An spx game. import "math" onClick => { @@ -232,7 +232,7 @@ run "assets", {Title: "My Game"} t.Run("WithUnusedLambdaParams", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ - "main.spx": []byte(`// A spx game. + "main.spx": []byte(`// An spx game. onKey [KeyLeft, KeyRight], (key) => { println "key" } @@ -254,7 +254,7 @@ onKey [KeyLeft, KeyRight], (key) => { Start: Position{Line: 0, Character: 0}, End: Position{Line: 8, Character: 0}, }, - NewText: `// A spx game. + NewText: `// An spx game. onKey [KeyLeft, KeyRight], () => { println "key" } @@ -269,7 +269,7 @@ onKey [KeyLeft, KeyRight], (key) => { t.Run("WithUnusedLambdaParamsForSprite", func(t *testing.T) { s := New(newMapFSWithoutModTime(map[string][]byte{ "main.spx": {}, - "MySprite.spx": []byte(`// A spx game. + "MySprite.spx": []byte(`// An spx game. onKey [KeyLeft, KeyRight], (key) => { println "key" } @@ -296,7 +296,7 @@ onTouchStart 123, (s) => { // type mismatch Start: Position{Line: 0, Character: 0}, End: Position{Line: 13, Character: 0}, }, - NewText: `// A spx game. + NewText: `// An spx game. onKey [KeyLeft, KeyRight], () => { println "key" } diff --git a/tools/spxls/internal/server/protocol.go b/tools/spxls/internal/server/protocol.go index 98eaae235..0b0fff66a 100644 --- a/tools/spxls/internal/server/protocol.go +++ b/tools/spxls/internal/server/protocol.go @@ -32,8 +32,8 @@ func toURI(s string) *URI { return &u } -// SpxRenameResourceParams represents parameters to rename a spx resource in the -// workspace. +// SpxRenameResourceParams represents parameters to rename an spx resource in +// the workspace. type SpxRenameResourceParams struct { // The spx resource. Resource SpxResourceIdentifier `json:"resource"` @@ -41,13 +41,13 @@ type SpxRenameResourceParams struct { NewName string `json:"newName"` } -// SpxResourceIdentifier identifies a spx resource. +// SpxResourceIdentifier identifies an spx resource. type SpxResourceIdentifier struct { // The spx resource's URI. URI SpxResourceURI `json:"uri"` } -// SpxResourceURI represents a URI string for a spx resource. +// SpxResourceURI represents a URI string for an spx resource. type SpxResourceURI string // HTML returns the HTML representation of the spx resource URI. @@ -62,7 +62,7 @@ type SpxGetDefinitionsParams struct { TextDocumentPositionParams } -// SpxDefinitionIdentifier identifies a spx definition. +// SpxDefinitionIdentifier identifies an spx definition. type SpxDefinitionIdentifier struct { // Full name of source package. // If not provided, it's assumed to be kind-statement. @@ -101,7 +101,7 @@ func (id SpxDefinitionIdentifier) String() string { return s } -// SpxResourceRefDocumentLinkData represents data for a spx resource reference +// SpxResourceRefDocumentLinkData represents data for an spx resource reference // document link. type SpxResourceRefDocumentLinkData struct { // The kind of the spx resource reference. diff --git a/tools/spxls/internal/server/rename.go b/tools/spxls/internal/server/rename.go index 8161072f8..9ce932335 100644 --- a/tools/spxls/internal/server/rename.go +++ b/tools/spxls/internal/server/rename.go @@ -152,7 +152,7 @@ func (s *Server) spxRenameResourceAtRefs(result *compileResult, id SpxResourceID return changes } -// spxRenameBackdropResource renames a spx backdrop resource. +// spxRenameBackdropResource renames an spx backdrop resource. func (s *Server) spxRenameBackdropResource(result *compileResult, id SpxBackdropResourceID, newName string) (map[DocumentURI][]TextEdit, error) { if result.spxResourceSet.Backdrop(newName) != nil { return nil, fmt.Errorf("backdrop resource %q already exists", newName) @@ -160,7 +160,7 @@ func (s *Server) spxRenameBackdropResource(result *compileResult, id SpxBackdrop return s.spxRenameResourceAtRefs(result, id, newName), nil } -// spxRenameSoundResource renames a spx sound resource. +// spxRenameSoundResource renames an spx sound resource. func (s *Server) spxRenameSoundResource(result *compileResult, id SpxSoundResourceID, newName string) (map[DocumentURI][]TextEdit, error) { if result.spxResourceSet.Sound(newName) != nil { return nil, fmt.Errorf("sound resource %q already exists", newName) @@ -168,7 +168,7 @@ func (s *Server) spxRenameSoundResource(result *compileResult, id SpxSoundResour return s.spxRenameResourceAtRefs(result, id, newName), nil } -// spxRenameSpriteResource renames a spx sprite resource. +// spxRenameSpriteResource renames an spx sprite resource. func (s *Server) spxRenameSpriteResource(result *compileResult, id SpxSpriteResourceID, newName string) (map[DocumentURI][]TextEdit, error) { if result.spxResourceSet.Sprite(newName) != nil { return nil, fmt.Errorf("sprite resource %q already exists", newName) @@ -203,7 +203,7 @@ func (s *Server) spxRenameSpriteResource(result *compileResult, id SpxSpriteReso return changes, nil } -// spxRenameSpriteCostumeResource renames a spx sprite costume resource. +// spxRenameSpriteCostumeResource renames an spx sprite costume resource. func (s *Server) spxRenameSpriteCostumeResource(result *compileResult, id SpxSpriteCostumeResourceID, newName string) (map[DocumentURI][]TextEdit, error) { spxSpriteResource := result.spxResourceSet.Sprite(id.SpriteName) if spxSpriteResource == nil { @@ -217,7 +217,7 @@ func (s *Server) spxRenameSpriteCostumeResource(result *compileResult, id SpxSpr return s.spxRenameResourceAtRefs(result, id, newName), nil } -// spxRenameSpriteAnimationResource renames a spx sprite animation resource. +// spxRenameSpriteAnimationResource renames an spx sprite animation resource. func (s *Server) spxRenameSpriteAnimationResource(result *compileResult, id SpxSpriteAnimationResourceID, newName string) (map[DocumentURI][]TextEdit, error) { spxSpriteResource := result.spxResourceSet.Sprite(id.SpriteName) if spxSpriteResource == nil { @@ -231,7 +231,7 @@ func (s *Server) spxRenameSpriteAnimationResource(result *compileResult, id SpxS return s.spxRenameResourceAtRefs(result, id, newName), nil } -// spxRenameWidgetResource renames a spx widget resource. +// spxRenameWidgetResource renames an spx widget resource. func (s *Server) spxRenameWidgetResource(result *compileResult, id SpxWidgetResourceID, newName string) (map[DocumentURI][]TextEdit, error) { if result.spxResourceSet.Widget(newName) != nil { return nil, fmt.Errorf("widget resource %q already exists", newName) diff --git a/tools/spxls/internal/server/spx_resource.go b/tools/spxls/internal/server/spx_resource.go index c3029fabf..766655819 100644 --- a/tools/spxls/internal/server/spx_resource.go +++ b/tools/spxls/internal/server/spx_resource.go @@ -13,19 +13,19 @@ import ( gopast "github.com/goplus/gop/ast" ) -// SpxResourceID is the ID of a spx resource. +// SpxResourceID is the ID of an spx resource. type SpxResourceID interface { URI() SpxResourceURI } -// SpxResourceRef is a reference to a spx resource. +// SpxResourceRef is a reference to an spx resource. type SpxResourceRef struct { ID SpxResourceID Kind SpxResourceRefKind Node gopast.Node } -// SpxResourceRefKind is the kind of a spx resource reference. +// SpxResourceRefKind is the kind of an spx resource reference. type SpxResourceRefKind string const ( @@ -35,7 +35,7 @@ const ( SpxResourceRefKindConstantReference SpxResourceRefKind = "constantReference" ) -// ParseSpxResourceURI parses a spx resource URI and returns the corresponding +// ParseSpxResourceURI parses an spx resource URI and returns the corresponding // spx resource ID. func ParseSpxResourceURI(uri SpxResourceURI) (SpxResourceID, error) { u, err := url.Parse(string(uri)) @@ -227,7 +227,7 @@ type SpxBackdropResource struct { Path string `json:"path"` } -// SpxBackdropResourceID is the ID of a spx backdrop resource. +// SpxBackdropResourceID is the ID of an spx backdrop resource. type SpxBackdropResourceID struct { BackdropName string } @@ -244,7 +244,7 @@ type SpxSoundResource struct { Path string `json:"path"` } -// SpxSoundResourceID is the ID of a spx sound resource. +// SpxSoundResourceID is the ID of an spx sound resource. type SpxSoundResourceID struct { SoundName string } @@ -254,7 +254,7 @@ func (id SpxSoundResourceID) URI() SpxResourceURI { return SpxResourceURI(fmt.Sprintf("spx://resources/sounds/%s", id.SoundName)) } -// SpxSpriteResource represents a spx sprite resource. +// SpxSpriteResource represents an spx sprite resource. type SpxSpriteResource struct { ID SpxSpriteResourceID `json:"-"` Name string `json:"name"` @@ -265,7 +265,7 @@ type SpxSpriteResource struct { DefaultAnimation string `json:"defaultAnimation"` } -// SpxSpriteResourceID is the ID of a spx sprite resource. +// SpxSpriteResourceID is the ID of an spx sprite resource. type SpxSpriteResourceID struct { SpriteName string } @@ -297,7 +297,7 @@ func (sprite *SpxSpriteResource) Animation(name string) *SpxSpriteAnimationResou return &sprite.Animations[idx] } -// SpxSpriteCostumeResource represents a spx sprite costume resource. +// SpxSpriteCostumeResource represents an spx sprite costume resource. type SpxSpriteCostumeResource struct { ID SpxSpriteCostumeResourceID `json:"-"` Index int `json:"index"` @@ -305,7 +305,7 @@ type SpxSpriteCostumeResource struct { Path string `json:"path"` } -// SpxSpriteCostumeResourceID is the ID of a spx sprite costume resource. +// SpxSpriteCostumeResourceID is the ID of an spx sprite costume resource. type SpxSpriteCostumeResourceID struct { SpriteName string CostumeName string @@ -316,13 +316,13 @@ func (id SpxSpriteCostumeResourceID) URI() SpxResourceURI { return SpxResourceURI(fmt.Sprintf("spx://resources/sprites/%s/costumes/%s", id.SpriteName, id.CostumeName)) } -// SpxSpriteAnimationResource represents a spx sprite animation resource. +// SpxSpriteAnimationResource represents an spx sprite animation resource. type SpxSpriteAnimationResource struct { ID SpxSpriteAnimationResourceID `json:"-"` Name string `json:"name"` } -// SpxSpriteAnimationResourceID is the ID of a spx sprite animation resource. +// SpxSpriteAnimationResourceID is the ID of an spx sprite animation resource. type SpxSpriteAnimationResourceID struct { SpriteName string AnimationName string @@ -342,7 +342,7 @@ type SpxWidgetResource struct { Val string `json:"val"` } -// SpxWidgetResourceID is the ID of a spx widget resource. +// SpxWidgetResourceID is the ID of an spx widget resource. type SpxWidgetResourceID struct { WidgetName string }