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(jsii): Re-implemented jsii to support --watch and produce better error reporting #188

Merged
merged 6 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export PATH=node_modules/.bin:$PATH

echo "============================================================================================="
echo "building..."
lerna run build
lerna run build --stream

echo "============================================================================================="
echo "testing..."
lerna run test
lerna run test --stream

touch $BUILD_INDICATOR
1 change: 1 addition & 0 deletions packages/jsii-calc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"scripts": {
"build": "jsii",
"watch": "jsii -w",
"test": "node test/test.calc.js && diff-test test/assembly.jsii .jsii"
},
"bundledDependencies": [
Expand Down
8 changes: 7 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -2827,9 +2827,15 @@
"kind": "enum",
"members": [
{
"docs": {
"comment": "Normal string expression "
},
"name": "Normal"
},
{
"docs": {
"comment": "Decorated string expression "
},
"name": "Decorated"
}
],
Expand All @@ -2838,5 +2844,5 @@
}
},
"version": "0.6.4",
"fingerprint": "J/33pyDX7y9AI1Vizdu+HEO/87ED05WoSxg41CSYHtw="
"fingerprint": "A6PSlMkLYrySPqgKflMrn2U4DjO6HO+VAJrO66IcSlo="
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void UnionTypes()
IDictionary<string, object> map = new Dictionary<string, object>();
map["Foo"] = new Multiply(new Number(2), new Number(00));
types.UnionMapProperty = map;


// array
types.UnionArrayProperty = new object[] { "Hello", 123, new Number(3) };
Expand Down Expand Up @@ -571,7 +571,7 @@ public void InterfaceBuilder()
throw new NotImplementedException();
}


[Fact(DisplayName = Prefix + nameof(SyncOverrides_SyncOverrides))]
public void SyncOverrides_SyncOverrides()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ private JsiiObject createNative(final String fqn) {
} catch (NoSuchMethodException e) {
throw new JsiiException("Cannot create native object of type "
+ klass.getName()
+ " without a constructor that accepts an InitializationMode argument");
+ " without a constructor that accepts an InitializationMode argument", e);

} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
throw new JsiiException("Unable to instantiate a new object for FQN " + fqn + ": "
+ e.getMessage());
+ e.getMessage(), e);
}
} catch (ClassNotFoundException e) {
System.err.println("WARNING: Cannot find the class: " + fqn + ". Defaulting to JsiiObject");
Expand Down
2 changes: 2 additions & 0 deletions packages/jsii-pacmak/test/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated C# code will have CRLF line endings, making git pretty awkward
.cs eol=crlf
Original file line number Diff line number Diff line change
Expand Up @@ -2827,9 +2827,15 @@
"kind": "enum",
"members": [
{
"docs": {
"comment": "Normal string expression "
},
"name": "Normal"
},
{
"docs": {
"comment": "Decorated string expression "
},
"name": "Decorated"
}
],
Expand All @@ -2838,5 +2844,5 @@
}
},
"version": "0.6.4",
"fingerprint": "J/33pyDX7y9AI1Vizdu+HEO/87ED05WoSxg41CSYHtw="
"fingerprint": "A6PSlMkLYrySPqgKflMrn2U4DjO6HO+VAJrO66IcSlo="
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ namespace Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation
[JsiiEnum(typeof(CompositionStringStyle), "jsii-calc.composition.CompositeOperation.CompositionStringStyle")]
public enum CompositionStringStyle
{
/// <summary>Normal string expression </summary>
[JsiiEnumMember("Normal")]
Normal,
/// <summary>Decorated string expression </summary>
[JsiiEnumMember("Decorated")]
Decorated
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ public void setStringStyle(final software.amazon.jsii.tests.calculator.compositi
*/
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.composition.CompositeOperation.CompositionStringStyle")
public enum CompositionStringStyle {
/**
* Normal string expression
*/
Normal,
/**
* Decorated string expression
*/
Decorated,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2627,8 +2627,14 @@ CompositeOperation

.. py:data:: Normal

Normal string expression


.. py:data:: Decorated

Decorated string expression





Expand Down
30 changes: 15 additions & 15 deletions packages/jsii-spec/lib/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ export interface NamedTypeReference extends TypeReferenceBase {
*/
fqn: string;
}
export function isNamedTypeReference(ref: TypeReference): ref is NamedTypeReference {
return !!(ref as NamedTypeReference).fqn;
export function isNamedTypeReference(ref: TypeReference | undefined): ref is NamedTypeReference {
return ref != null && !!(ref as NamedTypeReference).fqn;
}

/**
Expand All @@ -242,8 +242,8 @@ export interface PrimitiveTypeReference extends TypeReferenceBase {
*/
primitive: PrimitiveType;
}
export function isPrimitiveTypeReference(ref: TypeReference): ref is PrimitiveTypeReference {
return !!(ref as PrimitiveTypeReference).primitive;
export function isPrimitiveTypeReference(ref: TypeReference | undefined): ref is PrimitiveTypeReference {
return ref != null && !!(ref as PrimitiveTypeReference).primitive;
}

/**
Expand All @@ -262,8 +262,8 @@ export interface CollectionTypeReference extends TypeReferenceBase {
elementtype: TypeReference;
};
}
export function isCollectionTypeReference(ref: TypeReference): ref is CollectionTypeReference {
return !!(ref as CollectionTypeReference).collection;
export function isCollectionTypeReference(ref: TypeReference | undefined): ref is CollectionTypeReference {
return ref != null && !!(ref as CollectionTypeReference).collection;
}

/**
Expand All @@ -281,8 +281,8 @@ export interface UnionTypeReference extends TypeReferenceBase {
types: TypeReference[];
}
}
export function isUnionTypeReference(ref: TypeReference): ref is UnionTypeReference {
return !!(ref as UnionTypeReference).union;
export function isUnionTypeReference(ref: TypeReference | undefined): ref is UnionTypeReference {
return ref != null && !!(ref as UnionTypeReference).union;
}

/**
Expand Down Expand Up @@ -497,8 +497,8 @@ export interface ClassType extends TypeBase {
interfaces?: NamedTypeReference[];
}

export function isClassType(type: Type): type is ClassType {
return type.kind === TypeKind.Class;
export function isClassType(type: Type | undefined): type is ClassType {
return type != null && type.kind === TypeKind.Class;
}

export interface InterfaceType extends TypeBase {
Expand Down Expand Up @@ -529,8 +529,8 @@ export interface InterfaceType extends TypeBase {
datatype?: boolean;
}

export function isInterfaceType(type: Type): type is InterfaceType {
return type.kind === TypeKind.Interface;
export function isInterfaceType(type: Type | undefined): type is InterfaceType {
return type != null && type.kind === TypeKind.Interface;
}

/**
Expand All @@ -555,14 +555,14 @@ export interface EnumType extends TypeBase {
members: EnumMember[];
}

export function isEnumType(type: Type): type is EnumType {
return type.kind === TypeKind.Enum;
export function isEnumType(type: Type | undefined): type is EnumType {
return type != null && type.kind === TypeKind.Enum;
}

/**
* Return whether this type is a class or interface type
*/
export function isClassOrInterfaceType(type: Type): type is (InterfaceType | ClassType) {
export function isClassOrInterfaceType(type: Type | undefined): type is (InterfaceType | ClassType) {
return isClassType(type) || isInterfaceType(type);
}

Expand Down
63 changes: 0 additions & 63 deletions packages/jsii-spec/test/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/jsii/.npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Don't include original .ts files when doing `npm pack`
*.ts
*
!*.js
!*.d.ts
Loading