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

feat: allow referencing properties of constructs #2909

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cb31041
feat: allow referencing properties of CDK constructs
eladb Jun 13, 2023
560a097
Merge branch 'main' into eladb/reference-cdk
eladb Jun 14, 2023
33703c7
initial capture testing!
eladb Jun 18, 2023
80aa8bc
chore: self mutation
monadabot Jun 18, 2023
2b57b16
improvements
eladb Jun 19, 2023
e27e423
deep capture of preflight fields using mangling
eladb Jun 21, 2023
bb9f22c
all capture tests pass
eladb Jun 21, 2023
82ccf78
chore: self mutation
monadabot Jun 21, 2023
7ffed08
fix(docs): broken links (#2914)
ekeren Jun 14, 2023
9e8c3fd
feat(sdk): std.util.sleep() (#2906)
ekeren Jun 14, 2023
bfd71a3
fix(vscode): missing completions in lazy-loaded jsii namespaces (#2921)
MarkMcCulloh Jun 14, 2023
0337591
chore(compiler): add 🗺️ expression for debugging symbol environments …
Chriscbr Jun 14, 2023
bc58378
feat(sdk): `util.wait` (#2918)
ekeren Jun 15, 2023
b45ded7
fix(docs): broken links (#2915)
ekeren Jun 15, 2023
b8113dc
chore(docs): remove duplicate Wing SDK spec (#2926)
Chriscbr Jun 15, 2023
c4f6d44
fix(docs): `util` module docs missing in API reference (#2932)
Chriscbr Jun 15, 2023
841cb63
feat(docs): equality semantics (#2923)
Chriscbr Jun 15, 2023
a7a7124
chore: run unit tests in parallel with build/e2e and fix e2e sharding…
MarkMcCulloh Jun 16, 2023
c6b9cc0
chore: wingsdk requires build before test (#2945)
MarkMcCulloh Jun 16, 2023
10a517f
fix: esbuild-wasm is slow via child_process (#2950)
MarkMcCulloh Jun 18, 2023
7df3600
chore(build): run Node v20 in CI tests (#2947)
Chriscbr Jun 18, 2023
cc8937b
fix(sdk): `MutJson` methods `.set()`, `.setAt()` accept `any`, not `M…
revitalbarletz Jun 18, 2023
f9680db
fix(sdk): std.utils.sleep() test (#2951)
ainvoner Jun 18, 2023
06d23c6
fix(vscode): resource keyword is obsolete (#2966)
skorfmann Jun 19, 2023
22d6efd
feat(compiler): add milliseconds, days, months and years to duration …
marciocadev Jun 19, 2023
6236270
fix: duration requires std namespace (#2955)
Jun 19, 2023
75d12bc
feat(docs): compiler targets core-concepts (#2942)
hasanaburayyan Jun 19, 2023
0e13d9e
feat(vscode): docs in completions and signature help for constructors…
MarkMcCulloh Jun 20, 2023
a5f958a
chore(sdk): website sdk tests (#2784)
tsuf239 Jun 20, 2023
c3da93e
chore: copy semantic-release from console repo (#2977)
MarkMcCulloh Jun 20, 2023
8a729dd
chore: bump-pack does not set package version during release (#2992)
MarkMcCulloh Jun 20, 2023
adb82e2
chore: use PROJEN_BUMP_VERSION for versioning (#2993)
MarkMcCulloh Jun 20, 2023
bb82986
feat(sdk): bucket onEvent second argument and more (#2725)
tsuf239 Jun 20, 2023
409c08c
feat(sdk): adding bucket event hooks to awscdk (#2309)
marciocadev Jun 20, 2023
dfd3510
chore: website sdk windows snapshot mismatch (#2994)
MarkMcCulloh Jun 20, 2023
1563bdd
fix: capture diagnostics missing from language server (#2996)
MarkMcCulloh Jun 20, 2023
51eb488
chore(docs): update categories and title casing, fix broken links (#2…
Chriscbr Jun 21, 2023
edcef1b
feat(compiler): add support for super constructor (#2905)
hasanaburayyan Jun 21, 2023
d84fb3c
fixes
eladb Jun 22, 2023
1a56a45
Merge remote-tracking branch 'origin/main' into eladb/reference-cdk
eladb Jun 22, 2023
8626093
merge
eladb Jun 22, 2023
953dc2f
chore: self mutation
monadabot Jun 22, 2023
4718386
cleanup js
eladb Jun 22, 2023
b850ca6
remove merge issue
eladb Jun 22, 2023
7c84ace
Merge remote-tracking branch 'origin/main' into eladb/reference-cdk
eladb Jun 22, 2023
b7ac06f
fix completion tests
eladb Jun 22, 2023
5c5f7a0
add test
eladb Jun 22, 2023
8c49595
fix: class env phase for inflight classes was wrong
eladb Jun 22, 2023
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
8 changes: 5 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"name": "Debug Extension",
"type": "extensionHost",
"request": "launch",
"outFiles": ["${workspaceFolder}/apps/vscode-wing/lib/**/*.js"],
"outFiles": [
"${workspaceFolder}/apps/vscode-wing/lib/**/*.js"
],
"env": {
"WING_BIN": "${workspaceFolder}/apps/wing/bin/wing",
"RUST_BACKTRACE": "1"
Expand All @@ -70,11 +72,11 @@
]
},
"args": [
"${input:wingSource}"
"${file}"
],
"sourceLanguages": [
"rust"
],
},
]
}
}
2 changes: 1 addition & 1 deletion docs/04-standard-library/01-cloud/bucket.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: cloud.Bucket
title: Bucket
id: bucket
description: A built-in resource for handling object storage in the cloud.
keywords:
Expand Down
2 changes: 1 addition & 1 deletion docs/04-standard-library/01-cloud/counter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: cloud.Counter
title: Counter
id: counter
description: A built-in resource for representing an container for numbers in the cloud.
keywords: [Wing reference, Wing language, language, Wing standard library, Wing programming language, Counter]
Expand Down
2 changes: 1 addition & 1 deletion docs/04-standard-library/01-cloud/secret.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: cloud.Secret
title: Secret
id: secret
description: A built-in resource for securely storing secrets in the cloud.
keywords: [Wing reference, Wing language, language, Wing standard library, Wing programming language, secrets]
Expand Down
2 changes: 1 addition & 1 deletion docs/04-standard-library/01-cloud/service.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: cloud.Service
title: Service
id: service
description: A built-in resource for publishing messages to subscribers.
keywords: [Wing reference, Wing language, language, Wing standard library, Wing programming language, services]
Expand Down
2 changes: 1 addition & 1 deletion docs/04-standard-library/01-cloud/topic.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: cloud.Topic
title: Topic
id: topic
description: A built-in resource for publishing messages to subscribers.
keywords: [Wing reference, Wing language, language, Wing standard library, Wing programming language, topics]
Expand Down
3 changes: 1 addition & 2 deletions examples/tests/sdk_tests/bucket/public_url.w
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
bring cloud;

let bucketProps = cloud.BucketProps{public: true};
let publicBucket = new cloud.Bucket(bucketProps) as "publicBucket";
let publicBucket = new cloud.Bucket(public: true) as "publicBucket";
let privateBucket = new cloud.Bucket() as "privateBucket";

test "publicUrl" {
Expand Down
37 changes: 31 additions & 6 deletions examples/tests/valid/bring_cdktf.w
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
bring "@cdktf/provider-aws" as aws;

new aws.s3Bucket.S3Bucket(
class MyClass {
b2: aws.s3Bucket.S3Bucket;

init() {
this.b2 = new aws.s3Bucket.S3Bucket();
}

inflight getBucketArn(): str {
return this.b2.arn;
}
Comment on lines +10 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user accesses the arn in a different way? For example:

Suggested change
inflight getBucketArn(): str {
return this.b2.arn;
}
inflight getBucketArn(): str {
let bucket = this.b2;
return bucket.arn;
}

or:

class MyClass {
  arn: str;
  init() {
    let b2 = new aws.s3Bucket.S3Bucket();
    this.arn = b2.arn;
  }
  inflight getBucketArn(): str {
    return this.arn;
  }
}

}

let b = new aws.s3Bucket.S3Bucket(
bucketPrefix: "hello",
versioning: aws.s3Bucket.S3BucketVersioning {
enabled: true,
mfaDelete: true,
},
) as "Bucket";
acl: "private",
);

let c = new MyClass();

test "capture from inflight" {
let x1 = b.arn;
assert(x1.startsWith("arn:aws:s3"));
log("b.arn=${x1}");

let x2 = b.bucketDomainName;
assert(x2.endsWith("s3.amazonaws.com"));
log("b.bucketDomainName=${x2}");

let x3 = c.getBucketArn();
assert(x3.startsWith("arn:aws:s3"));
log("c.getBucketArn=${x3}");
}
59 changes: 52 additions & 7 deletions examples/tests/valid/capture_resource_and_data.w
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@
bring cloud;

let data = {1,2,3};
let res = new cloud.Bucket();
let queue = new cloud.Queue();
class Static {
static inflight hello(): str { return "hello"; }
}

struct Foo {
bar: str;
baz: Array<num>;
}

// let data = {1,2,3};
// let res = new cloud.Bucket();
// let queue = new cloud.Queue();
let foo = Foo { bar: "hello", baz: [1,2,3] };

class Hello {
x: Foo;
b: cloud.Bucket;

init() {
this.x = Foo { bar: "aa", baz: [1] };
this.b = new cloud.Bucket();
}

inflight hello() {
this.b.put("hello", "world");
}

inflight bang() {
let localArray = [Json 123,"Hello","World"];
log(str.fromJson(localArray.at(1)));

let local = "hi";
assert(local == "hi");
assert(local.length == 2);

log(this.x.bar);
log(Static.hello());
log(std.Json.stringify(123));
this.hello();
}
}

let hello = new Hello();

test "resource and data" {
assert(data.size == 3);
// assert(data.size == 3);

// res.put("file.txt", "world");
// assert(res.get("file.txt") == "world");

// assert(foo.bar == "hello");
assert(foo.baz.at(1) == 2);

res.put("file.txt", "world");
assert(res.get("file.txt") == "world");
// queue.push("spirulina");

queue.push("spirulina");
hello.bang();
}
5 changes: 5 additions & 0 deletions examples/tests/valid/new_capture_enum.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum Goo { A, B }

test "test" {
assert(Goo.A != Goo.B);
}
12 changes: 12 additions & 0 deletions examples/tests/valid/new_capture_preflight_object.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bring cloud;

let b = new cloud.Bucket();

// test "test" {
// b.put("hello.txt", "world");
// assert(b.get("hello.txt") == "world");
// }

test "nested reference" {
assert(b.list().length == 0);
}
9 changes: 9 additions & 0 deletions examples/tests/valid/new_capture_primitive.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bring cloud;

let s = "hello";
let goodbye = "goodbye";

test "test" {
assert(s == "hello");
assert(goodbye.length == 7);
}
9 changes: 9 additions & 0 deletions examples/tests/valid/new_capture_static.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A {
static inflight b(): str {
return "my_str";
}
}

test "test" {
assert(A.b() == "my_str");
}
4 changes: 4 additions & 0 deletions examples/tests/valid/new_capture_std_static.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test "test" {
assert(num.fromStr("1234") == 1234);
assert(std.Number.fromJson(123) == 123);
}
4 changes: 4 additions & 0 deletions libs/wingc/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ impl UserDefinedType {
path
}

pub fn full_path_str_vec(&self) -> Vec<String> {
return self.full_path().iter().map(|f| f.name.clone()).collect_vec();
}

pub fn full_path_str(&self) -> String {
self.full_path().iter().join(".")
}
Expand Down
Loading