Titanium JIRA Archive
Alloy (ALOY)

[ALOY-710] Alloy: Line number reported in the 'Errors' report is not always accurate if referring to a compiled file in the 'Resources' folder.

GitHub Issuen/a
TypeBug
PriorityMedium
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sAlloy 1.5.0
ComponentsRuntime
Labelsqe-3.1.1, qe-manualtest
ReporterFederico Casali
AssigneeTim Poulsen
Created2013-06-13T00:44:28.000+0000
Updated2014-12-03T22:29:45.000+0000

Description

Problem description

Report errors relative to Resources compiled code could display an incorrect Line position. In the following sample, an wrong function name is used inside a Titanium UI object defined in the Markup .XML. The function does not exist, Alloy still compile the code and the Code Analyzer completes the analysis. The function is detected as an error, however the number Line is in this case wrong.

Steps to reproduce

1. Use the following sample code

index.js

<Alloy>
	<Window class="container">
		<Label id="label" onClick="foobar">Hello, World</Label>
	</Window>
</Alloy>

index.tss

"Window":{
	backgroundColor: 'white'
}

"Label":{
	width: Ti.UI.SIZE,
	height: Ti.UI.SIZE,
	color: "#000"
}

index.js

$.index.open();
2. Run the Code Analyzer 3. Results: "foobar" is correctly reported as not defined. However, the Line position looks wrong. Attaching screenshot and 'Resources/alloy/controllers/index.js'.
function Controller() {
    require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
    arguments[0] ? arguments[0]["__parentSymbol"] : null;
    arguments[0] ? arguments[0]["$model"] : null;
    var $ = this;
    var exports = {};
    var __defers = {};
    $.__views.index = Ti.UI.createWindow({
        backgroundColor: "white",
        id: "index"
    });
    $.__views.index && $.addTopLevelView($.__views.index);
    $.__views.label = Ti.UI.createLabel({
        width: Ti.UI.SIZE,
        height: Ti.UI.SIZE,
        color: "#000",
        text: "Hello, World",
        id: "label"
    });
    $.__views.index.add($.__views.label);
    foobar ? $.__views.label.addEventListener("click", foobar) : __defers["$.__views.label!click!foobar"] = true;
    exports.destroy = function() {};
    _.extend($, $.__views);
    $.index.open();
    __defers["$.__views.label!click!foobar"] && $.__views.label.addEventListener("click", foobar);
    _.extend($, exports);
}

var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._;

module.exports = Controller;
Reports errors on line 30, 30 and 43.

Attachments

FileDateSize
index.js2013-06-13T00:44:28.000+00001105
Screen Shot 2013-06-12 at 5.34.11 PM.png2013-06-13T00:44:28.000+000023551
StudioDetects.png2014-08-28T23:11:58.000+000021605

Comments

  1. Federico Casali 2013-06-13

    Adding a clarification: The Line number reported in the Errors report is not always accurate if is referring to a compiled file in the Resources folder (for example 'Resource/alloy/controllers/index.js'). When the Error is relative to an Alloy file included in the 'app' folder (for example: app/controllers/index.js), the Line number is accurate.
  2. Tim Poulsen 2014-06-25

    Using both Appcelerator Studio 3.2.3.201404181520 and the CLI (with the code analyzer installed), I do not get code error information included in the output. Perhaps that feature we removed since this ticket was filed. Please note that the error that would result from the app described in this ticket would be encountered at runtime. The JavaScript engine would throw an error when it reached the end of the controller file without being able to find the missing function. Because the error comes from the JS interpreter, I don't see an easy way to catch the error to have it output source-file line numbers rather than compiled (runtime) file line numbers.
  3. Ewan Harris 2014-08-28

    Unable to reproduce the issue using: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201408270900 Titanium SDK build: 3.4.0.v20140827165712 Titanium CLI, build: 3.4.0-dev Alloy: 1.5.0-dev Titanium Code Processor 1.1.1 I added the sample code and then ran the code analysis. There was no error information included in the output, when I ran the code to an Android device I encountered a runtime error for this as predicted by Tim.

    Note

    Studio does pick this up and *warns* the user to there not being a definition for the method 'foobar'.
  4. Federico Casali 2014-10-17

  5. Federico Casali 2014-12-03

JSON Source