-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure macros, add getAllComponents
- Loading branch information
1 parent
d50a5dc
commit 5576552
Showing
13 changed files
with
102 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
import { CallMacro } from "../macro"; | ||
import { ComponentMethodMacro } from "./componentMethodMacro"; | ||
import { DependencyMacro } from "./dependencyMacro"; | ||
import { FlameworkAddPathsMacro } from "./flameworkAddPathsMacro"; | ||
import { FlameworkCreateEventMacro } from "./flameworkCreateEventMacro"; | ||
import { FlameworkCreateGuardMacro } from "./flameworkCreateGuardMacro"; | ||
import { FlameworkHashMacro } from "./flameworkHashMacro"; | ||
import { FlameworkIdMacro } from "./flameworkIdMacro"; | ||
import { FlameworkImplementsMacro } from "./flameworkImplementsMacro"; | ||
import { NetworkingConnectMacro } from "./networkingConnectMacro"; | ||
import { NetworkingPredictMacro } from "./networkingPredictMacro"; | ||
import { TestingPatchDependencyMacro } from "./testingPatchDependencyMacro"; | ||
import { ComponentGetAllComponentsMacro } from "./components/getAllComponentsMacro"; | ||
import { ComponentMethodMacro } from "./components/methodMacro"; | ||
import { DependencyMacro } from "./core/dependencyMacro"; | ||
import { FlameworkAddPathsMacro } from "./core/flamework/addPathsMacro"; | ||
import { NetworkingCreateEventMacro } from "./networking/createEventMacro"; | ||
import { FlameworkCreateGuardMacro } from "./core/flamework/createGuardMacro"; | ||
import { FlameworkHashMacro } from "./core/flamework/hashMacro"; | ||
import { FlameworkIdMacro } from "./core/flamework/flameworkIdMacro"; | ||
import { FlameworkImplementsMacro } from "./core/flamework/implementsMacro"; | ||
import { NetworkingConnectMacro } from "./networking/connectMacro"; | ||
import { NetworkingPredictMacro } from "./networking/predictMacro"; | ||
import { TestingPatchDependencyMacro } from "./core/flamework/testingPatchDependencyMacro"; | ||
|
||
export const CALL_MACROS = new Array<CallMacro>( | ||
DependencyMacro, | ||
|
||
// @flamework/components | ||
ComponentMethodMacro, | ||
ComponentGetAllComponentsMacro, | ||
|
||
// @flamework/networking | ||
NetworkingConnectMacro, | ||
NetworkingPredictMacro, | ||
NetworkingCreateEventMacro, | ||
|
||
TestingPatchDependencyMacro, | ||
|
||
// @flamework/core | ||
DependencyMacro, | ||
FlameworkIdMacro, | ||
FlameworkHashMacro, | ||
FlameworkAddPathsMacro, | ||
FlameworkCreateGuardMacro, | ||
FlameworkCreateEventMacro, | ||
FlameworkImplementsMacro, | ||
FlameworkHashMacro, | ||
FlameworkCreateGuardMacro, | ||
TestingPatchDependencyMacro, | ||
); |
41 changes: 41 additions & 0 deletions
41
src/transformations/macros/call/components/getAllComponentsMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import ts from "typescript"; | ||
import { Diagnostics } from "../../../../classes/diagnostics"; | ||
import { f } from "../../../../util/factory"; | ||
import { CallMacro } from "../../macro"; | ||
|
||
export const ComponentGetAllComponentsMacro: CallMacro = { | ||
getSymbol(state) { | ||
const symbols = state.symbolProvider; | ||
if (!symbols.components) return []; | ||
|
||
return symbols.components.get("getAllComponents"); | ||
}, | ||
|
||
transform(state, node) { | ||
const firstType = node.typeArguments?.[0]; | ||
if (firstType) { | ||
if (!f.is.referenceType(firstType)) Diagnostics.error(firstType, `Expected type reference`); | ||
|
||
const declaration = state.getSymbol(firstType.typeName)?.declarations?.[0]; | ||
if (!declaration) Diagnostics.error(firstType, `Could not find declaration`); | ||
|
||
return f.update.call(node, state.transform(node.expression), [ | ||
f.as(f.string(state.getUid(declaration)), f.keywordType(ts.SyntaxKind.NeverKeyword)), | ||
]); | ||
} else { | ||
const specifier = node.arguments[1]; | ||
if (!specifier) Diagnostics.error(node, `No specifier found`); | ||
|
||
const symbol = state.getSymbol(specifier); | ||
if (!symbol) Diagnostics.error(specifier, `Symbol could not be found`); | ||
if (!state.classes.has(symbol)) return state.transform(node); | ||
|
||
const declaration = symbol?.declarations?.[0]; | ||
if (!declaration) Diagnostics.error(specifier, `Declaration could not be found`); | ||
|
||
return f.update.call(node, state.transform(node.expression), [ | ||
f.as(f.string(state.getUid(declaration)), f.keywordType(ts.SyntaxKind.NeverKeyword)), | ||
]); | ||
} | ||
}, | ||
}; |
6 changes: 3 additions & 3 deletions
6
...tions/macros/call/componentMethodMacro.ts → ...ons/macros/call/components/methodMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...formations/macros/call/dependencyMacro.ts → ...tions/macros/call/core/dependencyMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ons/macros/call/flameworkAddPathsMacro.ts → ...cros/call/core/flamework/addPathsMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
.../macros/call/flameworkCreateGuardMacro.ts → ...s/call/core/flamework/createGuardMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ormations/macros/call/flameworkIdMacro.ts → ...s/call/core/flamework/flameworkIdMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...mations/macros/call/flameworkHashMacro.ts → ...s/macros/call/core/flamework/hashMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...s/macros/call/flameworkImplementsMacro.ts → ...os/call/core/flamework/implementsMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...acros/call/testingPatchDependencyMacro.ts → .../flamework/testingPatchDependencyMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ons/macros/call/networkingConnectMacro.ts → ...ns/macros/call/networking/connectMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
.../macros/call/flameworkCreateEventMacro.ts → ...acros/call/networking/createEventMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ons/macros/call/networkingPredictMacro.ts → ...ns/macros/call/networking/predictMacro.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters