jsgui3-server 0.0.75 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/client-side-popup-menu-button.html +93 -93
- package/examples/controls/_html-server-color-palette.js +114 -114
- package/examples/controls/html-server-combo-box.js +104 -104
- package/examples/controls/html-server-list.js +98 -98
- package/examples/controls/html-server-popup-menu-button.js +114 -114
- package/examples/controls/html-server-start-stop-toggle-button.js +146 -146
- package/examples/controls/scs-arrow-button.js +36 -36
- package/examples/controls/scs-date-picker.js +157 -157
- package/examples/controls/scs-file-browser.js +82 -82
- package/examples/controls/scs-item.js +159 -159
- package/examples/controls/scs-month-arrow-selector.js +126 -126
- package/examples/controls/scs-month-view.js +95 -95
- package/examples/controls/scs-start-stop-toggle-button.js +40 -40
- package/examples/controls/scs-tree.js +49 -49
- package/examples/controls/scs-year-arrow-selector.js +127 -127
- package/examples/demos/date-picker.js +119 -119
- package/examples/demos/explain-encapsulation.js +9 -9
- package/examples/demos/resizing.js +35 -35
- package/examples/demos/server_time.js +6 -6
- package/examples/demos/square_box.js +324 -324
- package/examples/html-rendering.js +20 -20
- package/examples/html-server.js +100 -100
- package/fs2.js +1836 -1836
- package/module.js +21 -21
- package/old/single-control-server.js +418 -418
- package/package.json +44 -42
- package/publishing/function-publisher.js +202 -202
- package/publishing/notes.md +5 -5
- package/publishing/observable-publisher.js +118 -118
- package/publishing/resource-publisher.js +306 -306
- package/resources/data-resource.js +104 -104
- package/resources/fs-resource.js +148 -148
- package/resources/jsbuilder/Abstract_Single_Declaration.js +105 -0
- package/resources/jsbuilder/Abstract_Single_Declaration_Sequence.js +43 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Abstract_Node.js +62 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Abstract_Node_Group.js +42 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Group_Shared.js +62 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node.js +94 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +228 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_1-Babel.js +338 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_10-Changing.js +40 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.1-Child.js +97 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.2-Parent.js +38 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.3-Ancestor.js +62 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.2-Inner.js +44 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.3-All.js +73 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.4-Sibling.js +93 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.5-Available_In_Scope.js +29 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.9-Signature.js +116 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3-Basics.js +160 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.0-Basics_First.js +179 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.1-Basics_Second.js +88 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.99-Basics_Last.js +92 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.1-Basics_Each.js +137 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.1.5-Basics_Count.js +74 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.2-Basics_Filter.js +40 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.3-Basics_Collect.js +86 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.4-Basics_Select.js +43 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.5-Basics_Find.js +41 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.6-Basics_Callmap.js +55 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_4.0-Index_Indexes.js +46 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_4.1-Index.js +344 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.0-Category.js +39 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.1-Category_Identifier.js +31 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.2-Category_Literal.js +29 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.3-Category_Expression.js +27 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.4-Category_Pattern.js +9 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.5-Category_Declaration.js +44 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.6-Category_Statement.js +22 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.0-Type.js +87 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.1-Type_Class_Declaration.js +9 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.2-Type_Variable_Declaration.js +28 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.3-Type_Variable_Declarator.js +29 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_7-Query.js +737 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_8-Features.js +65 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_9-Planning.js +32 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Arrangement.js +15 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Declared_Object.js +306 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature.js +78 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declaration.js +249 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declarator.js +139 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature.js +10 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exported.js +101 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exports.js +61 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Interpreted.js +180 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/_JSGUI_Root_Node_Interpreted.js +43 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/special_case_objectassign_to_object.js +12 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Group.js +35 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Operation.js +11 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Operation_On_Relationship.js +32 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Ordered_Relationship_Node_To_Group.js +38 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Ordinal.js +40 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Ordinal_Relationship.js +25 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_To_Group.js +201 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_Within_Group_To_Node.js +44 -0
- package/resources/jsbuilder/JS_AST/_JS_AST_Node_3.8-Query_Features.js +77 -0
- package/resources/jsbuilder/JS_AST/query/all.js +0 -0
- package/resources/jsbuilder/JS_AST/query/enable_array_as_queryable.js +228 -0
- package/resources/jsbuilder/JS_AST/query/find_object_keys.js +405 -0
- package/resources/jsbuilder/JS_AST/query/node_queries.js +9 -0
- package/resources/jsbuilder/JS_AST/query/root_queries.js +0 -0
- package/resources/jsbuilder/JS_AST/query/root_query_identidy.js +12 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JSGUI_Singular_Declaration.js +86 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Declaration.js +124 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended.js +88 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended_0-Core.js +11 -0
- package/resources/jsbuilder/JS_Builder.js +10 -36
- package/resources/jsbuilder/JS_File/Feature/JS_File_Declared_Object.js +32 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Exported_Object_Info.js +26 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Exports.js +79 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Feature.js +18 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Imported_Object_Info.js +26 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Imports.js +9 -0
- package/resources/jsbuilder/JS_File/JS_File.js +12 -0
- package/resources/jsbuilder/JS_File/JS_File_0-Core.js +202 -0
- package/resources/jsbuilder/JS_File/JS_File_1-Early_Parse.js +175 -0
- package/resources/jsbuilder/JS_File/JS_File_2-Babel.js +81 -0
- package/resources/jsbuilder/JS_File/JS_File_3-JS_AST_Node.js +86 -0
- package/resources/jsbuilder/JS_File/JS_File_4-Query.js +414 -0
- package/resources/jsbuilder/JS_File/JS_File_4.1-Query_Features.js +415 -0
- package/resources/jsbuilder/JS_File/JS_File_5-Planning.js +59 -0
- package/resources/jsbuilder/JS_File/JS_File_6-Changing.js +24 -0
- package/resources/jsbuilder/JS_File/JS_File_Export_Reference.js +12 -0
- package/resources/jsbuilder/JS_File/JS_File_Import_Reference.js +24 -0
- package/resources/jsbuilder/JS_File/JS_File_Import_References.js +32 -0
- package/resources/jsbuilder/JS_File/JS_File_Processor.js +16 -0
- package/resources/jsbuilder/JS_File/JS_Files.js +16 -0
- package/resources/jsbuilder/Module.js +14 -0
- package/resources/jsbuilder/Platform.js +13 -53
- package/resources/jsbuilder/Platforms.js +69 -15
- package/resources/jsbuilder/Project.js +109 -0
- package/resources/jsbuilder/Reference.js +1 -1
- package/resources/jsbuilder/Reference_Sequence.js +16 -7
- package/resources/jsbuilder/Scope.js +30 -0
- package/resources/jsbuilder/Variable_Name_Provider.js +43 -0
- package/resources/jsbuilder/_JS_File.js +226 -0
- package/resources/jsbuilder/ast_query.js +21 -0
- package/resources/jsbuilder/babel/babel_consts.js +150 -0
- package/resources/jsbuilder/babel/babel_node_tools.js +542 -0
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +604 -0
- package/resources/jsbuilder/build.js +16 -0
- package/resources/jsbuilder/platform_notes.md +66 -0
- package/resources/jsbuilder/test/test_ast_node.js +451 -0
- package/resources/jsbuilder/test/test_js_file.js +303 -11
- package/resources/jsbuilder/test/test_project.js +157 -0
- package/resources/local-server-info-resource.js +78 -78
- package/resources/process-js.js +537 -537
- package/resources/server-resource-pool.js +84 -84
- package/resources/website-css-resource.js +411 -411
- package/resources/website-javascript-resource.js +761 -751
- package/resources/website-resource.js +390 -390
- package/resources/website-static-html-resource.js +196 -196
- package/server.js +170 -170
- package/single-control-server.js +398 -398
- package/single-page-app.js +129 -129
- package/resources/jsbuilder/Declaration.js +0 -15
- package/resources/jsbuilder/Declaration_Sequence.js +0 -15
- package/resources/jsbuilder/JS_File.js +0 -77
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
// A bunch of local variables get defined within each platform.
|
|
3
|
+
|
|
4
|
+
// Make a platform about providing variables. These variables will correspond with what a module exports.
|
|
5
|
+
|
|
6
|
+
// Auto-detecting platform levels?
|
|
7
|
+
|
|
8
|
+
// Downloading the files from npm?
|
|
9
|
+
|
|
10
|
+
// Defining platforms using files
|
|
11
|
+
// Reads the file into JS_File object.
|
|
12
|
+
// Which of the functions are inline?
|
|
13
|
+
// as in don't have any references, or use anythin out of scope.
|
|
14
|
+
|
|
15
|
+
// Tightly scoped functions... how to find them?
|
|
16
|
+
|
|
17
|
+
// Or, a system of adding functions / functionality to the platform?
|
|
18
|
+
// Would be fine for building jsgui but prefer it to be more automated.
|
|
19
|
+
|
|
20
|
+
// Lowest level platforms can not require modules of their own (I think).
|
|
21
|
+
// A platform can have ordering - things later in the order can require things previous in the order - it everything is declared in order as a const.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// Should be able to give it a name, for shorthand usage later on.
|
|
25
|
+
//this.add_file_content(path, content, name);
|
|
26
|
+
//this.add_file(path, name);
|
|
27
|
+
|
|
28
|
+
// This will mean that the files can be built together in a way where lang-mini will have function names that are shorter...?
|
|
29
|
+
// But how to do that?
|
|
30
|
+
// Localising variables from the module within the platform.
|
|
31
|
+
// Localising what gets exported.
|
|
32
|
+
// Everything else runs within a closure.
|
|
33
|
+
// Go for some really short variable names all over the place.
|
|
34
|
+
// Should make for mega-compressed code.
|
|
35
|
+
|
|
36
|
+
// This looks like it will be essential for building jsgui in the way that takes less space for the client.
|
|
37
|
+
|
|
38
|
+
// Or make this all about assigning variables / declarations in platforms.
|
|
39
|
+
|
|
40
|
+
// So a platform has a sequence of declarations.
|
|
41
|
+
|
|
42
|
+
// Detect if a function / object has anythin out of scope...?
|
|
43
|
+
|
|
44
|
+
// Platform gets js files loaded into it.
|
|
45
|
+
// When that happens, declarations get loaded from that jsfile.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// Basically want to load functions sequentially into the platform.
|
|
49
|
+
// Would also be a nice basis for an API documentation and a useful ordering to know.
|
|
50
|
+
// Maybe it's ordering that won't be generated automatically (yet).
|
|
51
|
+
|
|
52
|
+
//platform.load_fn
|
|
53
|
+
// or a bunch of functions
|
|
54
|
+
|
|
55
|
+
// Load DECLARATIONS.
|
|
56
|
+
|
|
57
|
+
// platform.load(declaration);
|
|
58
|
+
// platform.load(js_file); // and that will need to load all the declarations needed by it recursively?
|
|
59
|
+
// could raise a missing declaration event...?
|
|
60
|
+
|
|
61
|
+
// be able to evaluate an expression to see if it is all inline.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
|
|
2
|
+
// Should have more specific tests for JS_AST_Node.
|
|
3
|
+
// Such as getting the source but with renamed local variables.
|
|
4
|
+
|
|
5
|
+
// Maybe need more tests and fixes for deconstructing expressions.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// Load a JS file into an OO structure
|
|
11
|
+
|
|
12
|
+
const JS_File = require('..//JS_File/JS_File');
|
|
13
|
+
//const JS_File_Comprehension = require('../JS_File_Comprehension');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const Project = require('../Project');
|
|
17
|
+
const {each} = require('lang-mini');
|
|
18
|
+
|
|
19
|
+
//const JS_AST_Node = require('../JS_AST/JS_AST_Node');
|
|
20
|
+
const JS_AST_Node = require('../JS_AST_Node_Extended/JS_AST_Node_Extended');
|
|
21
|
+
|
|
22
|
+
const test_js_ast_node = () => {
|
|
23
|
+
|
|
24
|
+
// That's a simple declaration.
|
|
25
|
+
//const test_script_1 = 'const firstname = "James", surname = "Vickers", name = firstname + " " + surname, [a, b, c] = [1, 2, 3];';
|
|
26
|
+
//const test_script_2 = 'module.exports = lang_mini;';
|
|
27
|
+
const test_script_1 = 'const [a, b, c] = [1, 2, 3], [d, e, f] = [4, 5, 6];';
|
|
28
|
+
//const test_script_1 = 'const [a, b, c] = [1, 2, 3];';
|
|
29
|
+
|
|
30
|
+
//const test_script_3 = 'const {a, b, c} = propertied_object;'
|
|
31
|
+
|
|
32
|
+
const test_script_4 = 'const obj = {"a": 1, "b": 2, "c": 3}';
|
|
33
|
+
|
|
34
|
+
// Item declared as an array.
|
|
35
|
+
// Still a single declared item, even though it's composed of multiple things.
|
|
36
|
+
// Would could as an Abstract_Single_Declaration???
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
//const test_script_1 = 'const a = [1, 2, 3];';
|
|
40
|
+
|
|
41
|
+
// Root node by default?
|
|
42
|
+
// Makes sense as that's the likely context the developer would use it.
|
|
43
|
+
// If it has no parent_node.
|
|
44
|
+
|
|
45
|
+
const spec = {
|
|
46
|
+
source: test_script_1
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const js_ast_node = JS_AST_Node.from_spec(spec);
|
|
50
|
+
|
|
51
|
+
console.log('js_ast_node', js_ast_node);
|
|
52
|
+
console.log('js_ast_node.source', js_ast_node.source);
|
|
53
|
+
|
|
54
|
+
console.log('js_ast_node.child.count', js_ast_node.child.count);
|
|
55
|
+
|
|
56
|
+
console.log('js_ast_node.query.count.all.exe()', js_ast_node.query.count.all.exe());
|
|
57
|
+
|
|
58
|
+
// mapcall_deep_iterate
|
|
59
|
+
// mapcall_child_nodes
|
|
60
|
+
// deep_iterate_mapcall
|
|
61
|
+
|
|
62
|
+
// mapped call ?
|
|
63
|
+
|
|
64
|
+
const direct_calling = () => {
|
|
65
|
+
js_ast_node.callmap_deep_iterate(node => node.signature, {
|
|
66
|
+
'ArE(NumL,NumL,NumL)': (node) => {
|
|
67
|
+
console.log('are 3 numlit node', node);
|
|
68
|
+
},
|
|
69
|
+
'ArP(ID,ID,ID)': (node) => {
|
|
70
|
+
console.log('arp 3 id node', node);
|
|
71
|
+
}
|
|
72
|
+
}, node => {
|
|
73
|
+
console.log('default node', node);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
js_ast_node.signature_callmap_deep_iterate({
|
|
77
|
+
'ArE(NumL,NumL,NumL)': (node) => {
|
|
78
|
+
console.log('* are 3 numlit node', node);
|
|
79
|
+
},
|
|
80
|
+
'ArP(ID,ID,ID)': (node) => {
|
|
81
|
+
console.log('* arp 3 id node', node);
|
|
82
|
+
}
|
|
83
|
+
}, node => {
|
|
84
|
+
console.log('* default node', node);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const callmap_calling = () => {
|
|
89
|
+
js_ast_node.query.callmap.exe(node => node.signature, {
|
|
90
|
+
'ArE(NumL,NumL,NumL)': (node) => {
|
|
91
|
+
console.log('are 3 numlit node', node);
|
|
92
|
+
},
|
|
93
|
+
'ArP(ID,ID,ID)': (node) => {
|
|
94
|
+
console.log('arp 3 id node', node);
|
|
95
|
+
}
|
|
96
|
+
}, node => {
|
|
97
|
+
console.log('default node', node);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
js_ast_node.query.callmap.by.signature.exe({
|
|
101
|
+
'ArE(NumL,NumL,NumL)': (node) => {
|
|
102
|
+
console.log('!!are 3 numlit node', node);
|
|
103
|
+
},
|
|
104
|
+
'ArP(ID,ID,ID)': (node) => {
|
|
105
|
+
console.log('!!arp 3 id node', node);
|
|
106
|
+
}
|
|
107
|
+
}, node => {
|
|
108
|
+
console.log('!!default node', node);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// And it works... now to get it into query.
|
|
117
|
+
|
|
118
|
+
// callmap_deep_iterate
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// Let's do a bit more work on getting object declared keys.
|
|
122
|
+
// .query.collect.objectproperty.exe().query.find.child.identifier.exe().query('name');
|
|
123
|
+
|
|
124
|
+
const used_tests = () => {
|
|
125
|
+
const var_decltrs = js_ast_node.query.collect.child.variabledeclarator.exe();
|
|
126
|
+
console.log('var_decltrs', var_decltrs);
|
|
127
|
+
|
|
128
|
+
// .id property of the var declarators?
|
|
129
|
+
//
|
|
130
|
+
|
|
131
|
+
const decr_id_names = js_ast_node.query.collect.child.variabledeclarator.exe().query.collect.first.child.name.exe();
|
|
132
|
+
console.log('decr_id_names', decr_id_names);
|
|
133
|
+
|
|
134
|
+
//const key_id_names = js_ast_node.query.collect.objectproperty.exe().query.collect.child.identifier.exe().query.collect.name.exe();
|
|
135
|
+
//console.log('key_id_names', key_id_names);
|
|
136
|
+
|
|
137
|
+
// OPr
|
|
138
|
+
|
|
139
|
+
// .query.select.by.t.exe('OPr');
|
|
140
|
+
|
|
141
|
+
const oprs = js_ast_node.query.select.by.t.exe('OPr');
|
|
142
|
+
console.log('oprs', oprs);
|
|
143
|
+
|
|
144
|
+
const oprslits = js_ast_node.query.select.by.t.exe('OPr').query.collect.child.literal.exe();
|
|
145
|
+
console.log('oprslits', oprslits);
|
|
146
|
+
|
|
147
|
+
const opr_first_child_nodes = js_ast_node.query.select.by.t.exe('OPr').query.collect.first.child.exe(); // working nicely.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
// Best to keep this syntax for the moment, the need for query collect and exe make it explicit and simpler to follow.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
// .t.collect('OPr').first.child.node.exe();
|
|
155
|
+
console.log('opr_first_child_nodes', opr_first_child_nodes);
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
//const sl_values = opr_first_child_nodes.map(node => node.babel.node.value)
|
|
159
|
+
const sl_values = js_ast_node.query.select.by.t.exe('OPr').query.collect.first.child.value.exe();
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
console.log('sl_values', sl_values);
|
|
163
|
+
|
|
164
|
+
if (js_ast_node.declaration) {
|
|
165
|
+
console.log('js_ast_node.declaration.declared.keys', js_ast_node.declaration.declared.keys);
|
|
166
|
+
|
|
167
|
+
// js_ast_node.query.collect.declared.keys.exe();
|
|
168
|
+
|
|
169
|
+
const dc2 = js_ast_node.query.collect.own.declared.keys.exe();
|
|
170
|
+
console.log('dc2', dc2);
|
|
171
|
+
|
|
172
|
+
// and the corresponding assigned values.
|
|
173
|
+
// declaration.assigned.values
|
|
174
|
+
// declaration.declared, declaration.assigned
|
|
175
|
+
|
|
176
|
+
console.log('js_ast_node.declaration.assigned.values', js_ast_node.declaration.assigned.values);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// .query.collect.own.assigned.values
|
|
180
|
+
// .query.collect.own.declaration.assigned.value
|
|
181
|
+
// .query.collect.own.declaration.value
|
|
182
|
+
// .query.collect.declaration.value
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
const various_tests_including_new_query_api = () => {
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
console.log('js_ast_node.category', js_ast_node.category);
|
|
194
|
+
console.log('');
|
|
195
|
+
console.log('js_ast_node.source\n' + js_ast_node.source);
|
|
196
|
+
console.log('');
|
|
197
|
+
|
|
198
|
+
console.log('js_ast_node', js_ast_node);
|
|
199
|
+
console.log('js_ast_node.child.count', js_ast_node.child.count);
|
|
200
|
+
console.log('js_ast_node.child.shared.type', js_ast_node.child.shared.type);
|
|
201
|
+
console.log('js_ast_node.child.shared.t', js_ast_node.child.shared.t);
|
|
202
|
+
console.log('js_ast_node.type', js_ast_node.type);
|
|
203
|
+
console.log('js_ast_node.declaration', js_ast_node.declaration);
|
|
204
|
+
|
|
205
|
+
console.log('js_ast_node.declaration.keys', js_ast_node.declaration.keys);
|
|
206
|
+
|
|
207
|
+
const q = js_ast_node.query;
|
|
208
|
+
|
|
209
|
+
const qeach = q.each;
|
|
210
|
+
|
|
211
|
+
console.log('q', q);
|
|
212
|
+
console.log('qeach', qeach);
|
|
213
|
+
console.log('qeach.text', qeach.text);
|
|
214
|
+
|
|
215
|
+
//const q2 = js_ast_node.query.each.child.node;
|
|
216
|
+
const q2 = js_ast_node.query.first.child.node;
|
|
217
|
+
console.log('q2', q2);
|
|
218
|
+
console.log('q2.qstring', q2.qstring); // .qtext? or .querytext? .toString()? qstring for the moment.
|
|
219
|
+
const vdr = q2.exe();
|
|
220
|
+
const vdrcn2 = vdr.query.second.child.exe();
|
|
221
|
+
//console.log('q2.exe()', q2.exe());
|
|
222
|
+
console.log('vdr', vdr);
|
|
223
|
+
console.log('vdrcn2', vdrcn2);
|
|
224
|
+
console.log('js_ast_node', js_ast_node);
|
|
225
|
+
|
|
226
|
+
// .query.select.exec
|
|
227
|
+
// .query.select.by.type.exe('ObjectProperty');
|
|
228
|
+
|
|
229
|
+
const oprs = js_ast_node.query.select.by.type.exe('ObjectProperty');
|
|
230
|
+
console.log('oprs', oprs);
|
|
231
|
+
|
|
232
|
+
const oprns = js_ast_node.query.select.by.type.exe('ObjectProperty').query.collect.child.identifier.name.exe();
|
|
233
|
+
|
|
234
|
+
console.log('oprns', oprns);
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
// Just a simple test to get the structure there for query result .each queries.
|
|
238
|
+
js_ast_node.query.select.by.type.exe('ObjectProperty').query.each.child.exe(cn => {
|
|
239
|
+
console.log('cn', cn);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
js_ast_node.query.select.by.type.exe('ObjectProperty').query.each.child.identifier.exe(cn => {
|
|
243
|
+
console.log('cn', cn);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
const ids = js_ast_node.query.collect.identifier.exe();
|
|
248
|
+
console.log('ids', ids);
|
|
249
|
+
|
|
250
|
+
const csigs = js_ast_node.query.collect.child.signature.exe();
|
|
251
|
+
console.log('csigs', csigs);
|
|
252
|
+
|
|
253
|
+
console.log('js_ast_node.query.count.child.exe()', js_ast_node.query.count.child.exe());
|
|
254
|
+
console.log('js_ast_node.query.count.identifier.exe()', js_ast_node.query.count.identifier.exe());
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
// still for the moment will be clear about the verb used.
|
|
258
|
+
|
|
259
|
+
// Pattern category....
|
|
260
|
+
|
|
261
|
+
// query.collect.by.category('Pattern');
|
|
262
|
+
|
|
263
|
+
//const patterns = js_ast_node.query.select.by.category.exe('Pattern');
|
|
264
|
+
|
|
265
|
+
const patterns = js_ast_node.query.collect.pattern.exe();
|
|
266
|
+
|
|
267
|
+
console.log('patterns', patterns);
|
|
268
|
+
|
|
269
|
+
const oprops = patterns.query.collect.property.exe();
|
|
270
|
+
console.log('oprops', oprops);
|
|
271
|
+
|
|
272
|
+
const cfcs = js_ast_node.query.collect.child.exe().query.collect.first.child.exe();
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
console.log('cfcs', cfcs);
|
|
276
|
+
console.log('cfcs.length', cfcs.length);
|
|
277
|
+
|
|
278
|
+
console.log('cfcs.query', cfcs.query);
|
|
279
|
+
|
|
280
|
+
const cfc = cfcs[0];
|
|
281
|
+
const cfc_child_types = cfc.query.collect.child.type.exe()
|
|
282
|
+
const cfc_child_child_counts = cfc.query.collect.child.exe().query.collect.child.count.exe()
|
|
283
|
+
|
|
284
|
+
console.log('cfc_child_types', cfc_child_types);
|
|
285
|
+
console.log('cfc_child_child_counts', cfc_child_child_counts);
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
// query.collect.pattern.inner.identifier.exe()
|
|
296
|
+
// query.collect.pattern.child.property.exe()
|
|
297
|
+
|
|
298
|
+
// query.collect.pattern.exe().query.collect.child.property.exe();
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
// Nice, being able to query the results is good.
|
|
305
|
+
// But will get it working with more verbs than just collect.
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
// .string?
|
|
312
|
+
// .qstring
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
//const q2res = q2.exe(cn => {
|
|
316
|
+
// console.log('cn', cn);
|
|
317
|
+
//});
|
|
318
|
+
|
|
319
|
+
// each child declaration
|
|
320
|
+
// identifier
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
// .exe function executes the query.
|
|
324
|
+
|
|
325
|
+
// Could load in various query handling modules in a tree.
|
|
326
|
+
|
|
327
|
+
// .each.child.declaration
|
|
328
|
+
|
|
329
|
+
// Then a fairly large OO query system could do it.
|
|
330
|
+
// Consider if that's best.
|
|
331
|
+
// Seems best, considering usage of various objects such as relationships.
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
// then can use specific (level 2) properties when we have a Declaration of VariableDeclaration
|
|
343
|
+
|
|
344
|
+
// let's put it in the VariableDeclaration class.
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
// declaration.left_terms?
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
const earlier_tests = () => {
|
|
354
|
+
|
|
355
|
+
console.log('js_ast_node.category', js_ast_node.category);
|
|
356
|
+
console.log('js_ast_node.source', js_ast_node.source);
|
|
357
|
+
console.log('js_ast_node', js_ast_node);
|
|
358
|
+
console.log('');
|
|
359
|
+
//console.log('js_ast_node.babel.node', js_ast_node.babel.node);
|
|
360
|
+
|
|
361
|
+
//console.log('js_ast_node', js_ast_node);
|
|
362
|
+
//console.log('js_ast_node.path', js_ast_node.path);
|
|
363
|
+
//console.log('js_ast_node.depth', js_ast_node.depth);
|
|
364
|
+
//console.log('js_ast_node.is_root', js_ast_node.is_root);
|
|
365
|
+
//console.log('js_ast_node.is_declaration', js_ast_node.is_declaration);
|
|
366
|
+
//console.log('js_ast_node.child_nodes.length', js_ast_node.child_nodes.length);
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
//js_ast_node.inner;
|
|
370
|
+
|
|
371
|
+
console.log('js_ast_node.inner', js_ast_node.inner);
|
|
372
|
+
console.log('js_ast_node.inner.count', js_ast_node.inner.count);
|
|
373
|
+
console.log('js_ast_node.all.count', js_ast_node.all.count);
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
// .collect.identifier
|
|
378
|
+
|
|
379
|
+
// inner.declaration
|
|
380
|
+
|
|
381
|
+
// inner.node
|
|
382
|
+
|
|
383
|
+
// js_ast_node.collect.all()
|
|
384
|
+
|
|
385
|
+
// collect.all.declaration
|
|
386
|
+
// seems like that could be built on top of the select syntax.
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
const o_select_all = js_ast_node.select.all;
|
|
390
|
+
console.log('o_select_all', o_select_all);
|
|
391
|
+
|
|
392
|
+
const decs = js_ast_node.select.all(node => node.is_declaration);
|
|
393
|
+
console.log('decs', decs);
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
// js_ast_node.collect.all.identifier
|
|
400
|
+
|
|
401
|
+
// and then .all should use .collect but work as a property.
|
|
402
|
+
// do that later.
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
const ids = js_ast_node.select.all(node => node.is_identifier);
|
|
406
|
+
console.log('ids', ids);
|
|
407
|
+
|
|
408
|
+
console.log('js_ast_node.child', js_ast_node.child);
|
|
409
|
+
console.log('js_ast_node.child.shared.type', js_ast_node.child.shared.type);
|
|
410
|
+
console.log('js_ast_node.child.count', js_ast_node.child.count);
|
|
411
|
+
|
|
412
|
+
// child.filter(fn)
|
|
413
|
+
|
|
414
|
+
const ids2 = js_ast_node.collect.inner.identifier();
|
|
415
|
+
console.log('ids2', ids2);
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
console.log('js_ast_node.collect.all.identifier', js_ast_node.collect.all.identifier());
|
|
419
|
+
|
|
420
|
+
// .each.identifier
|
|
421
|
+
|
|
422
|
+
// .iterate.all.identifier?
|
|
423
|
+
js_ast_node.each.identifier(id => {
|
|
424
|
+
console.log('id.source', id.source);
|
|
425
|
+
console.log('id.sibling.count', id.sibling.count);
|
|
426
|
+
|
|
427
|
+
console.log('id.sibling.previous.count', id.sibling.previous.count);
|
|
428
|
+
console.log('id.sibling.post.count', id.sibling.post.count);
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
// Find out how many declarators it has.
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
// Does it have its mirror structure loaded?
|
|
442
|
+
// The mirror structure is made out of these JS_AST_Nodes.
|
|
443
|
+
// Would prefer for it to load automatically and not be part of the API.
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
test_js_ast_node();
|