Skip to content
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

docs: correct grammar by using "an spx" instead of "a spx" #1261

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spx-backend/internal/copilot/system_prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions tools/spxls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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 {
/**
Expand Down
20 changes: 10 additions & 10 deletions tools/spxls/internal/server/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down Expand Up @@ -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() {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/spxls/internal/server/diagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/spxls/internal/server/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
24 changes: 12 additions & 12 deletions tools/spxls/internal/server/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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 => {
Expand All @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"
}
Expand Down
12 changes: 6 additions & 6 deletions tools/spxls/internal/server/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ 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"`
// The new name of the spx resource.
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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions tools/spxls/internal/server/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,23 @@ 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)
}
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)
}
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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
Loading
Loading