Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed parser for Javascript (used in Java app) to get basic property value information about Ext.define objects
    primarykey
    data
    text
    <p>I have hundreds of small javascript files that follow the following format where Ext.define defines a javascript class. I need to be able to parse these files in a Java app and get the "SOMECLASSNAME" and the values for various properties like "extend" and "requires". I want to ignore comments and I don't care about the functions.</p> <p>I have actually already implemented this using regular expressions and it works. However, it's fairly brittle. I've already dealt with issues like files that use " instead of ' and inconveniently placed comments which break the regexes. I would really like to do this using a less brittle solution and that means using a javascript parser.</p> <p>I've searched using various searches like "java javascript ast parser", but nothing seems to fit what I'm trying to do. The closest I've found is <a href="https://stackoverflow.com/questions/15546601/using-scriptengine-in-java-how-can-i-extract-function-list">Using ScriptEngine in java, How can I extract function list?</a> but that seems to require that the script be runnable and each of these files isn't runnable by itself.</p> <pre><code>Ext.define('SOMECLASSNAME', { extend: 'JSCommon.remoting.RESTService', alternateClassName: 'AccountSettingService', requires: [ 'JSCommon.security.Privilege', 'JSCommon.security.PrivilegeConstants', 'JSCommon.security.store.UIPrivilege', 'JSCommon.util.StringUtil' ], statics: { /** * Creates and returns a new instance of the ReportsService */ getNewInstance: function() { return Ext.create('JSCommon.acctSetting.AccountSettingService'); } }, config: { customer: 'abc', service: 'companySetting' }, constructor: function(config) { this.initConfig(config); return this; }, getCompanyID: function() { return PlatformCache.getCompanyContextByAttribute('id'); }, getAccountSetting: function(onResult, onFault) { var me = this; var svc = RESTService.getNewInstance(); var ops = Ext.create('JSCommon.remoting.URLElements'); var params = Ext.create('JSCommon.remoting.URLParams'); params.add('action', 'find'); var postbody = { }; svc.sendGETRequest(svc.getURL(this.getCustomer(), me.getCompanyID(), me.getService(), ops, params), postbody, onResult, onFault); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload