{ "id": "115258", "key": "TIMOB-14058", "fields": { "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2016-08-24T20:00:39.000+0000", "created": "2013-05-30T23:59:00.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "qe-3.1.1", "usability" ], "versions": [ { "id": "15478", "description": "Release 3.1.1", "name": "Release 3.1.1", "archived": true, "released": true, "releaseDate": "2013-06-17" } ], "issuelinks": [ { "id": "29505", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "115805", "key": "ALOY-703", "fields": { "summary": "Less modified code generation", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "updated": "2017-03-20T20:29:58.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "13102", "name": "Code Processor", "description": "Analyzes JavaScript source" } ], "description": "h5. Problem description\r\n\r\nCode Processor results for Alloy projects are based an Analysis on the compiled code in the Resources folder.\r\nThis could generate unexpected results and parity issues for the end user whose expectations are that the Code Processor is checking his code, as included in the Alloy project 'app' folder, even if the Code Processor is actually correctly analyzing the javascript code compiled by Alloy.\r\n\r\nh5. Example:\r\n\r\nh6. \"ContextTest\" sample project\r\n(https://github.com/appcelerator/titanium-code-processor/tree/master/test_projects/ContextTest or attached here in the Jira)\r\n\r\nIn this case, the code to be analyzed is:\r\n{code}\r\n(function foo() {\r\n\tvar x = 10;\r\n\tsetTimeout(function () {\r\n\t\tconsole.log(x);\r\n\t});\r\n\r\n\tfunction bar() {\r\n\t\tconsole.log(x);\r\n\t\tx = 20;\r\n\t\trequire(x);\r\n\t}\r\n\tif (Date.now()) {\r\n\t\tbar();\r\n\t}\r\n})();\r\nconsole.log(x);\r\n{code}\r\n\r\nand the result, as expected, is that: \r\n{code}\r\n\"x\" is not defined | app.js | 16 \r\n{code}\r\n \r\n \r\n \r\n\r\nBy placing the same identical code in an Alloy project index.js controller file, the result is a bit different.\r\n\r\nAttached in the Jira there is the ContextTest sample for Alloy too.\r\n\r\nAfter being compiled, the Resources/alloy/controllers/index.js looks like this:\r\n{code}\r\nfunction Controller() {\r\n require(\"alloy/controllers/BaseController\").apply(this, Array.prototype.slice.call(arguments));\r\n arguments[0] ? arguments[0][\"__parentSymbol\"] : null;\r\n arguments[0] ? arguments[0][\"$model\"] : null;\r\n var $ = this;\r\n var exports = {};\r\n $.__views.index = Ti.UI.createWindow({\r\n backgroundColor: \"blue\",\r\n id: \"index\"\r\n });\r\n $.__views.index && $.addTopLevelView($.__views.index);\r\n exports.destroy = function() {};\r\n _.extend($, $.__views);\r\n (function() {\r\n function bar() {\r\n console.log(x);\r\n x = 20;\r\n require(x);\r\n }\r\n var x = 10;\r\n setTimeout(function() {\r\n console.log(x);\r\n });\r\n Date.now() && bar();\r\n })();\r\n console.log(x);\r\n $.index.open();\r\n _.extend($, exports);\r\n}\r\n\r\nvar Alloy = require(\"alloy\"), Backbone = Alloy.Backbone, _ = Alloy._;\r\n\r\nmodule.exports = Controller;\r\n{code}\r\n\r\nso, lines 14 to 26 are the ones regarding the code put in the controller. The code is a bit different (for example the function \"bar()\" is declared before the 'var x = 10') and the Code Analyzer result is a bit different:\r\n\r\n{code}\r\nThe module \"20\" could not be found | app/controllers/index.js | 10\r\n\"x\" is not defined | app/controllers/index.js | 17\r\n{code}\r\n\r\n\r\nIn this case the Code Processor is likely behaving correctly, in fact putting the generated code from lines 14 to 26 in a Classic Titanium project, I'm getting the same as the Alloy one.\r\n\r\nThe issue relates in the fact that from the end-user standpoint, the two results should be identical and the user could be easily confused by those results.\r\n\r\n\r\nAttached both the classic and the Alloy 'ContextTest' sample projects and the Code Analyzer Results for each. \r\n\r\n\r\n", "attachment": [ { "id": "39284", "filename": "Alloy_ContextTest_RESULT.zip", "author": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-30T23:59:01.000+0000", "size": 3967728, "mimeType": "application/zip" }, { "id": "39285", "filename": "Alloy_ContextTest.zip", "author": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-30T23:59:01.000+0000", "size": 7407552, "mimeType": "application/zip" }, { "id": "39282", "filename": "classic_ContextTest_RESULT.zip", "author": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-30T23:59:01.000+0000", "size": 44560, "mimeType": "application/zip" }, { "id": "39283", "filename": "classic_ContextTest.zip", "author": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-30T23:59:01.000+0000", "size": 3698133, "mimeType": "application/zip" } ], "flagged": false, "summary": "Code Processor - Alloy: analyzed code results can be different from the expected ones", "creator": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Appcelerator Studio 3.1.1.201305292130\r\nTitanium SDK 3.1.1.v20130529114554\r\nAlloy 1.1.3-alpha\r\nTitanium-Code-Processor 1.1.3-alpha3", "comment": { "comments": [ { "id": "255030", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~tlukasavage] Two quick questions.\n\n* Why is the order of the code slightly different in the generated version of the controller?\n* Should the source map not point us back to app.js, line 16?", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-31T00:09:13.000+0000", "updated": "2013-05-31T00:09:13.000+0000" }, { "id": "255063", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "* The order is slightly different due to the fact that each controller gets broken down into an AST and then reassembled by uglify-js into code. There are options that can impact this reassembly, but I've never dug into them that much as there's never been a need to this point. I would definitely need a ticket logged to pursue that one further.\r\n* No, the second example is in index.js, not app.js, so it is pointing to the correct file. The numbering however seems to be off by a line, but could that perhaps simply be something that happened when the code was copied to another project? I'll bet there was just an additional line break in there. It seems unlikely that numbering is off only because studio debugging has been using it for a while. \r\n\r\nBut I ama bit confused and I read the ticket a few times. What is the expectation if not for the code processor to point back to the correct location in the original controller, because that appears to me what is happening? Am I missing something?", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-31T00:44:03.000+0000", "updated": "2013-05-31T00:46:44.000+0000" }, { "id": "255098", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Federico, I agree with you in theory, but comparing an Alloy app and a non-Alloy app for code processor output will practically never happen in real world development. No one is going to write an app twice identically and then compare code processor output, except us of course. ;-)", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-31T02:37:56.000+0000", "updated": "2013-05-31T02:37:56.000+0000" }, { "id": "255514", "author": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Some quick thoughts: I think this is worth some investigation. Ideally they should produce the same output, but as Tony said there are probably some technical reasons why they may differ. It would be nice if we could really investigate these differences and see if they are worthwhile to invest to time fix, if they are possible to fix.", "updateAuthor": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-03T16:54:01.000+0000", "updated": "2013-06-03T16:54:01.000+0000" }, { "id": "255517", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~fcasali] would you mind logging a ticket in ALOY for, let's say, \"less modified\" code generation? This is by no means a panacea, and I'm not certain at this moment how similar to the current code I can keep it, but I can start investigating making less changes to the structure of the code generated by uglify-js's AST parsing. This would not be for Alloy 1.1.3 & TiSDK 3.1.1 though. Heh, version palindrome. ", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-03T17:00:21.000+0000", "updated": "2013-06-03T17:00:21.000+0000" }, { "id": "255535", "author": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "IMO, before we start logging tickets, we should investigate a little more to see if \"less modified\" code actually is the proper approach. Figure out the problem first before we dive in to fix it.", "updateAuthor": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-03T18:01:12.000+0000", "updated": "2013-06-03T18:01:12.000+0000" }, { "id": "255541", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~bhughes] this is something i've been meaning to start investigating anyway for the sake of when the debugger drops a developer into generated code. It will make for a better experience if the code more closely resembles their original source files. This was more of a \"two birds with one stone\" idea than it was an effort specifically for this ticket. Also, investigating would be part of the ticket as mentioned in my previous comment.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-03T18:13:25.000+0000", "updated": "2013-06-03T18:13:25.000+0000" }, { "id": "255545", "author": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Ah, I gotcha now. Ticket away :)", "updateAuthor": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-03T18:37:30.000+0000", "updated": "2013-06-03T18:37:30.000+0000" }, { "id": "394209", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "Code processor is dead.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2016-08-24T20:00:39.000+0000", "updated": "2016-08-24T20:00:39.000+0000" }, { "id": "413921", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as Code processor is no longer supported.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-20T20:29:58.000+0000", "updated": "2017-03-20T20:29:58.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }