Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4db8493

Browse files
feat: refactor type model (#194)
Removed the maps in the typemodel class and created a TypeNode object
1 parent 6b4543a commit 4db8493

File tree

11 files changed

+604
-606
lines changed

11 files changed

+604
-606
lines changed

‎libraries/analysis-javascript/lib/type/resolving/InferenceTypeModelFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class InferenceTypeModelFactory extends TypeModelFactory {
6060
}
6161

6262
createNewTypeProbability(id: string, bindingId: string) {
63-
this._typeModel.addId(bindingId);
63+
this._typeModel.createTypeNode(bindingId);
6464

6565
if (id === bindingId) {
6666
// don't set if the id and binding are equal

‎libraries/analysis-javascript/lib/type/resolving/Type.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
export interface ObjectType {
19+
export class ObjectType {
2020
// name -> id
2121
properties: Map<string, string>;
2222

@@ -31,6 +31,35 @@ export interface ObjectType {
3131
parameterNames: Map<number, string>;
3232
// id
3333
return: Set<string>;
34+
35+
constructor() {
36+
this.properties = new Map();
37+
this.elements = new Set();
38+
this.parameters = new Map();
39+
this.parameterNames = new Map();
40+
this.return = new Set();
41+
}
42+
43+
public merge(other: ObjectType): ObjectType {
44+
const combined = new ObjectType();
45+
46+
combined.properties = new Map([
47+
...this.properties.entries(),
48+
...other.properties.entries(),
49+
]);
50+
combined.elements = new Set(...this.elements, ...other.elements);
51+
combined.parameters = new Map([
52+
...this.parameters.entries(),
53+
...other.parameters.entries(),
54+
]);
55+
combined.parameterNames = new Map([
56+
...this.parameterNames.entries(),
57+
...other.parameterNames.entries(),
58+
]);
59+
combined.return = new Set(...this.return, ...other.return);
60+
61+
return combined;
62+
}
3463
}
3564

3665
export const functionProperties = new Set([

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /