(defun dojo-js-i18n-extract-process-main-top-level-stmt-node (stmt-node class) (log-i18n (format "Called process-main-top-level-stmt-node.")) (let* ((call-node (js2-expr-stmt-node-expr stmt-node))) (cond ((dojo-has-node-type call-node "js2-call-node") (let* ((name-node (js2-call-node-target call-node)) (fct-name (if (dojo-has-node-type name-node "js2-name-node") (dojo-get-name-from-name-node name-node) nil)) (arg-nodes (js2-call-node-args call-node)) (first-arg-node (nth 0 arg-nodes))) (cond ((and (string= fct-name "define") (dojo-has-node-type first-arg-node "js2-object-node")) (let* ((object-prop-nodes (js2-object-node-elems first-arg-node))) (dolist (object-prop-node object-prop-nodes) (let* ((left-node (js2-infix-node-left object-prop-node)) (prop-name (dojo-get-name-from-object-prop-left-node left-node)) (right-node (js2-infix-node-right object-prop-node))) (cond ((string= prop-name "root") (cond ((dojo-has-node-type right-node "js2-paren-node") (let* ((paren-object-node (js2-paren-node-expr right-node))) (cond ((dojo-has-node-type paren-object-node "js2-object-node") (dojo-js-i18n-extract-process-top-object-node paren-object-node class)) (t (log-i18n (format "[WARNING] Found unsupported node [%s] in inner main i18n paren node." (js2-node-short-name paren-object-node))))))) (t (log-i18n (format "[WARNING] Found unsupported node [%s] in main i18n root node." (js2-node-short-name right-node)))))) (t ())))))) (t (log-i18n (format "[WARNING] Found illegal case around top level i18n define call; fct-name [%s], first-arg-node has type [%s]" fct-name (js2-node-short-name first-arg-node))))))) (t (log-i18n (format "[WARNING] Top level call node of main i18n file has unsupported type [%s]" (js2-node-short-name call-node)))))) (log-i18n (format "Finished processing main i18n file."))) (defun dojo-js-i18n-extract-process-other-top-level-stmt-node (stmt-node class) (log-i18n (format "Called process-other-top-level-stmt-node.")) (let* ((call-node (js2-expr-stmt-node-expr stmt-node))) (cond ((dojo-has-node-type call-node "js2-call-node") (let* ((name-node (js2-call-node-target call-node)) (fct-name (if (dojo-has-node-type name-node "js2-name-node") (dojo-get-name-from-name-node name-node) nil)) (arg-nodes (js2-call-node-args call-node)) (first-arg-node (nth 0 arg-nodes))) (cond ((and (string= fct-name "define") (dojo-has-node-type first-arg-node "js2-paren-node")) (let* ((object-node (js2-paren-node-expr first-arg-node))) (cond ((dojo-has-node-type object-node "js2-object-node") (dojo-js-i18n-extract-process-top-object-node object-node class)) (t (log-i18n (format "[WARNING] Found illegal paren child node [%s] in other i18n file." (js2-node-short-name object-node))))))) (log-i18n (format "[WARNING] Found illegal case around top level i18n define call; fct-name [%s], first-arg-node has type [%s]" fct-name (js2-node-short-name first-arg-node)))))) (t (log-i18n (format "[WARNING] Top level call node of main i18n file has unsupported type [%s]" (js2-node-short-name call-node)))))) (log-i18n (format "Finished processing other i18n file."))) (defun dojo-js-i18n-extract-process-top-object-node (object-node class) (log-i18n (format "Called process-top-object-node")) (let* ((object-prop-nodes (js2-object-node-elems object-node)) (static-symbol (dojo-class-static-symbol class))) (dolist (object-prop-node object-prop-nodes) (cond ((dojo-has-node-type object-prop-node "js2-object-prop-node") (let ((symbol (dojo-js-i18n-extract-process-object-prop-node object-prop-node class))) (dojo-symbol-register-object-member (dojo-symbol-name symbol) symbol static-symbol))) (t (log-i18n (format "[WARNING] Found unsupported object property node [%s]" (js2-node-short-name object-prop-node)))))))) (defun dojo-js-i18n-extract-process-object-prop-node (object-prop-node class) (let* ((left-node (js2-infix-node-left object-prop-node)) (prop-name (dojo-get-name-from-object-prop-left-node left-node)) (right-node (js2-infix-node-right object-prop-node)) (object-prop-start (js2-node-abs-pos object-prop-node)) (object-prop-end (js2-node-abs-end object-prop-node))) (cond ((dojo-has-node-type right-node "js2-string-node") (let* ((symbol (construct-dojo-symbol dojo-current-workspace class prop-name))) (dojo-symbol-set-type symbol 'DOJO-JSTYPE-STRING) (setf (dojo-symbol-value symbol) (dojo-get-string-from-string-node right-node)) (setf (dojo-symbol-min-pos symbol) object-prop-start) (setf (dojo-symbol-max-pos symbol) object-prop-end) (if (and object-prop-start (= object-prop-start 4423)) (log-i18n (format "extract-i18n-process-object-prop: class [%s:%s:%s], symbol %s contains min-pos 4423" (dojo-class-id class) (dojo-class-project class) (dojo-class-path class) (dojo-core-util-symbol-to-short-string symbol)))) symbol)) (t (let* ((symbol (construct-dojo-symbol dojo-current-workspace class prop-name))) (setf (dojo-symbol-min-pos symbol) object-prop-start) (setf (dojo-symbol-max-pos symbol) object-prop-end) symbol))))) (provide 'dojo-js-i18n-extract)