mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
improve error handling
This commit is contained in:
1 parent
b41ad227c1
commit
794c5d1ad8
7 files changed
+46
-24
No files matched your search
@@ -277,9 +277,8 @@ define(function (require, exports, module) {
|
||||
}
|
||||
|
||||
request.done(function (fnType) {
|
||||
var cm = session.editor._codeMirror;
|
||||
|
||||
var pos = cm.charCoords(functionInfo.functionCallPos);
|
||||
var cm = session.editor._codeMirror,
|
||||
pos = cm.charCoords(functionInfo.functionCallPos);
|
||||
|
||||
formatHint(functionInfo);
|
||||
|
||||
@@ -290,6 +289,8 @@ define(function (require, exports, module) {
|
||||
|
||||
$(session.editor).on("cursorActivity", handleCursorActivity);
|
||||
$deferredPopUp.resolveWith(null);
|
||||
}).fail(function () {
|
||||
hintState.functionCallPos = null;
|
||||
});
|
||||
|
||||
return $deferredPopUp;
|
||||
|
||||
@@ -674,10 +674,13 @@ define(function (require, exports, module) {
|
||||
properties = response.properties,
|
||||
fnType = response.fnType,
|
||||
type = response.type,
|
||||
error = response.error,
|
||||
$deferredHints = getPendingRequest(file, offset, type);
|
||||
|
||||
if ($deferredHints) {
|
||||
if (completions) {
|
||||
if (error) {
|
||||
$deferredHints.reject();
|
||||
} else if (completions) {
|
||||
$deferredHints.resolveWith(null, [{completions: completions}]);
|
||||
} else if (properties) {
|
||||
$deferredHints.resolveWith(null, [{properties: properties}]);
|
||||
|
||||
@@ -677,6 +677,13 @@ define(function (require, exports, module) {
|
||||
if (node.type === "SequenceExpression") {
|
||||
node = node.expressions[0];
|
||||
}
|
||||
if (node.type === "BinaryExpression") {
|
||||
if (node.left.type === "CallExpression") {
|
||||
node = node.left;
|
||||
} else if (node.right.type === "CallExpression") {
|
||||
node = node.right;
|
||||
}
|
||||
}
|
||||
if (node.type === "CallExpression") {
|
||||
var args = node["arguments"],
|
||||
i,
|
||||
|
||||
@@ -407,7 +407,7 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
type = inferType.args[i];
|
||||
|
||||
if (name === undefined) {
|
||||
name = 'param' + (i + 1);
|
||||
name = "param" + (i + 1);
|
||||
}
|
||||
|
||||
if (name[name.length - 1] === "?") {
|
||||
@@ -425,16 +425,9 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
|
||||
if (newFnType && newFnType.indexOf("fn(") === 0) {
|
||||
var params = Infer.withContext(ternServer.cx, function () {
|
||||
|
||||
try {
|
||||
var typeParser = new Infer.def.TypeParser(newFnType, null, null, true),
|
||||
inferType = typeParser.parseType("", true);
|
||||
return processInferFnTypeParameters(inferType);
|
||||
} catch (e) {
|
||||
_log(e.message);
|
||||
return [{name: e.message, type: ''}];
|
||||
}
|
||||
|
||||
var typeParser = new Infer.def.TypeParser(newFnType, null, null, true),
|
||||
inferType = typeParser.parseType("", true);
|
||||
return processInferFnTypeParameters(inferType);
|
||||
});
|
||||
|
||||
return params;
|
||||
@@ -459,22 +452,29 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
|
||||
var request = buildRequest(fileInfo, "type", offset);
|
||||
|
||||
request.preferFunction = true;
|
||||
|
||||
request.query.preferFunction = true;
|
||||
|
||||
//_log("request " + dir + " " + file + " " + offset /*+ " " + text */);
|
||||
ternServer.request(request, function (error, data) {
|
||||
var fnType = "";
|
||||
if (error) {
|
||||
_log("Error returned from Tern 'type' request: " + error);
|
||||
} else {
|
||||
fnType = getParameters(data.type);
|
||||
try {
|
||||
fnType = getParameters(data.type);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
_log("Error thrown by Tern in getParameters: " + error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Post a message back to the main thread with the completions
|
||||
self.postMessage({type: MessageIds.TERN_CALLED_FUNC_TYPE_MSG,
|
||||
file: fileInfo.name,
|
||||
offset: offset,
|
||||
fnType: fnType
|
||||
fnType: fnType,
|
||||
error: error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
Submodule src/extensions/default/JavaScriptCodeHints/thirdparty/tern updated: fb2bb83134...09f92ccebc.
@@ -164,7 +164,7 @@ require(["MyModule"], function (myModule) {
|
||||
/**
|
||||
* Test record type google annoations.
|
||||
*
|
||||
* @param {{index: number, type: string}} t
|
||||
* @param {{index: number, name: string}} t
|
||||
*/
|
||||
function testRecordTypeAnnotation(t) {
|
||||
'use strict';
|
||||
@@ -203,7 +203,7 @@ testArrayAnnotation();
|
||||
/**
|
||||
* Test multiple optional args
|
||||
*
|
||||
* @param {string=} a
|
||||
* @param {number=} a
|
||||
* @param {string=} b
|
||||
*
|
||||
*/
|
||||
@@ -213,6 +213,7 @@ function testOptionalArgs(a, b) {
|
||||
}
|
||||
|
||||
testOptionalArgs();
|
||||
|
||||
/* Add large comment to make this test over 250 lines which will trigger
|
||||
* partial updates to be used.
|
||||
*
|
||||
|
||||
@@ -1199,13 +1199,23 @@ define(function (require, exports, module) {
|
||||
});
|
||||
});
|
||||
|
||||
// log a bug against Tern. Tern can't parse its own function hint.
|
||||
// Tern issue #207. Tern can't parse its own function hint.
|
||||
xit("should list parameter hint for record type annotation", function () {
|
||||
var testPos = { line: 178, ch: 25 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
runs(function () {
|
||||
expectParameterHint([{name: "t", type: "{index: Number, type: String}"}], -1);
|
||||
expectParameterHint([{name: "t", type: "{index: Number, name: String}"}], -1);
|
||||
});
|
||||
});
|
||||
|
||||
// Tern issue #208. Fixed in the latest tern
|
||||
xit("should list parameter hint for optional parameters", function () {
|
||||
var testPos = { line: 214, ch: 17 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
runs(function () {
|
||||
expectParameterHint([{name: "a", type: "Number", isOptional: true}, {name: "b", type: "String", isOptional: true}], 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user