mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Fix issue where "<no parameters>" would be hinted when Tern could not parse the jsdoc.
Fix issue where Session.getFunctionInfo could return 'inFunctionCall' as true but 'functionCallPos' would be undefined. Fix many jsdoc problems.
This commit is contained in:
1 parent
4969b7785f
commit
c994eafc36
7 files changed
+39
-39
No files matched your search
@@ -38,11 +38,11 @@ define(function (require, exports, module) {
|
||||
* parameters, syntax for optional parameters, and the order of the
|
||||
* parameter type and parameter name.
|
||||
*
|
||||
* @param {!Array.<name: {string}, type: {string},
|
||||
* isOptional: {boolean}>} params - array of parameter descriptors
|
||||
* @param {!Array.<{name: string, type: string, isOptional: boolean}>} params -
|
||||
* array of parameter descriptors
|
||||
* @param {function(string)=} appendSeparators - callback function to append separators.
|
||||
* The separator is passed to the callback.
|
||||
* @param {function(string, number)} appendParameter - callback function to append parameter.
|
||||
* @param {function(string, number)=} appendParameter - callback function to append parameter.
|
||||
* The formatted parameter type and name is passed to the callback along with the
|
||||
* current index of the parameter.
|
||||
* @param {boolean=} typesOnly - only show parameter types. The
|
||||
|
||||
@@ -50,7 +50,7 @@ define(function (require, exports, module) {
|
||||
$hintContent, // function hint content holder
|
||||
|
||||
/** @type {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number},
|
||||
* fnType: {Array.<Object>}}
|
||||
* fnType: Array.<Object}}
|
||||
*/
|
||||
hintState = {},
|
||||
hintStack = [], // stack for previous function hint to restore
|
||||
@@ -77,7 +77,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Test if a function hint is being displayed.
|
||||
*
|
||||
* @returns {boolean} - true if a function hint is being displayed, false
|
||||
* @return {boolean} - true if a function hint is being displayed, false
|
||||
* otherwise.
|
||||
*/
|
||||
function isHintDisplayed() {
|
||||
@@ -130,9 +130,9 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Bold the parameter at the caret.
|
||||
*
|
||||
* @param {{inFunctionCall: boolean, functionCallPos: {{line: number, ch: number}}}
|
||||
* functionInfo - tells if the caret is in a function call and the position
|
||||
* of the function call.
|
||||
* @param {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number}}} functionInfo -
|
||||
* tells if the caret is in a function call and the position
|
||||
* of the function call.
|
||||
*/
|
||||
function formatHint(functionInfo) {
|
||||
var hints = session.getParameterHint(functionInfo.functionCallPos),
|
||||
@@ -174,7 +174,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Restore the state of the previous function hint.
|
||||
*
|
||||
* @returns {boolean} - true the a parameter hint has been pushed, false otherwise.
|
||||
* @return {boolean} - true the a parameter hint has been pushed, false otherwise.
|
||||
*/
|
||||
function popHintFromStack() {
|
||||
if (hintStack.length > 0) {
|
||||
@@ -198,7 +198,7 @@ define(function (require, exports, module) {
|
||||
* function hint.
|
||||
*
|
||||
* @param functionCallPos
|
||||
* @returns {boolean}
|
||||
* @return {boolean}
|
||||
*/
|
||||
function hasFunctionCallPosChanged(functionCallPos) {
|
||||
var oldFunctionCallPos = hintState.functionCallPos;
|
||||
@@ -232,7 +232,7 @@ define(function (require, exports, module) {
|
||||
* to push the hint.
|
||||
* @param {string=} hint - function hint string from tern.
|
||||
* @param {{inFunctionCall: boolean, functionCallPos:
|
||||
* {{line: number, ch: number}}=} functionInfo -
|
||||
* {line: number, ch: number}}=} functionInfo -
|
||||
* if the functionInfo is already known, it can be passed in to avoid
|
||||
* figuring it out again.
|
||||
* @return {jQuery.Promise} - The promise will not complete until the
|
||||
@@ -409,7 +409,7 @@ define(function (require, exports, module) {
|
||||
exports.PUSH_EXISTING_HINT = PUSH_EXISTING_HINT;
|
||||
exports.addCommands = addCommands;
|
||||
exports.dismissHint = dismissHint;
|
||||
exports.installListeners = installListeners;
|
||||
exports.installListeners = installListeners;
|
||||
exports.isHintDisplayed = isHintDisplayed;
|
||||
exports.popUpHint = popUpHint;
|
||||
exports.setSession = setSession;
|
||||
|
||||
@@ -172,7 +172,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Get the regular expression for excluded directories.
|
||||
*
|
||||
* @returns {?RegExp} Regular expression matching the directories that should
|
||||
* @return {?RegExp} Regular expression matching the directories that should
|
||||
* be excluded. Returns null if no directories are excluded.
|
||||
*/
|
||||
Preferences.prototype.getExcludedDirectories = function () {
|
||||
@@ -182,7 +182,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Get the regular expression for excluded files.
|
||||
*
|
||||
* @returns {?RegExp} Regular expression matching the files that should
|
||||
* @return {?RegExp} Regular expression matching the files that should
|
||||
* be excluded. Returns null if no files are excluded.
|
||||
*/
|
||||
Preferences.prototype.getExcludedFiles = function () {
|
||||
@@ -192,7 +192,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Get the maximum number of files that will be analyzed.
|
||||
*
|
||||
* @returns {number}
|
||||
* @return {number}
|
||||
*/
|
||||
Preferences.prototype.getMaxFileCount = function () {
|
||||
return this._maxFileCount;
|
||||
@@ -202,7 +202,7 @@ define(function (require, exports, module) {
|
||||
* Get the maximum size of a file that will be analyzed. Files that are
|
||||
* larger will be ignored.
|
||||
*
|
||||
* @returns {number}
|
||||
* @return {number}
|
||||
*/
|
||||
Preferences.prototype.getMaxFileSize = function () {
|
||||
return this._maxFileSize;
|
||||
|
||||
@@ -65,7 +65,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* An array of library names that contain JavaScript builtins definitions.
|
||||
*
|
||||
* @returns {Array.<string>} - array of library names.
|
||||
* @return {Array.<string>} - array of library names.
|
||||
*/
|
||||
function getBuiltins() {
|
||||
return builtinLibraryNames;
|
||||
@@ -228,7 +228,7 @@ define(function (require, exports, module) {
|
||||
* Test if the directory should be excluded from analysis.
|
||||
*
|
||||
* @param {!string} path - full directory path.
|
||||
* @returns {boolean} true if excluded, false otherwise.
|
||||
* @return {boolean} true if excluded, false otherwise.
|
||||
*/
|
||||
function isDirectoryExcluded(path) {
|
||||
var excludes = preferences.getExcludedDirectories();
|
||||
@@ -247,7 +247,7 @@ define(function (require, exports, module) {
|
||||
* Test if the file should be excluded from analysis.
|
||||
*
|
||||
* @param {!string} path - full directory path.
|
||||
* @returns {boolean} true if excluded, false otherwise.
|
||||
* @return {boolean} true if excluded, false otherwise.
|
||||
*/
|
||||
function isFileExcluded(path) {
|
||||
var excludes = preferences.getExcludedFiles();
|
||||
@@ -497,7 +497,7 @@ define(function (require, exports, module) {
|
||||
*
|
||||
* @param {!Session} session - the current session
|
||||
* @param {{line: number, ch: number}} start - the starting position of the changes
|
||||
* @returns {{type: string, name: string, offsetLines: number, text: string}}
|
||||
* @return {{type: string, name: string, offsetLines: number, text: string}}
|
||||
*/
|
||||
function getFragmentAround(session, start) {
|
||||
var minIndent = null,
|
||||
@@ -566,7 +566,7 @@ define(function (require, exports, module) {
|
||||
* changes are reset.
|
||||
*
|
||||
* @param {!Session} session - the current session
|
||||
* @returns {{type: string, name: {string}, offsetLines: {number}, text: {string}}
|
||||
* @return {{type: string, name: {string}, offsetLines: {number}, text: {string}}
|
||||
*/
|
||||
function getFileInfo(session) {
|
||||
var start = session.getCursor(),
|
||||
@@ -610,7 +610,7 @@ define(function (require, exports, module) {
|
||||
* and the text is empty.
|
||||
* @param {{line: number, ch: number}=} offset - the default offset (optional). Will
|
||||
* use the cursor if not provided.
|
||||
* @returns {{line: number, ch: number}}
|
||||
* @return {{line: number, ch: number}}
|
||||
*/
|
||||
function getOffset(session, fileInfo, offset) {
|
||||
var newOffset;
|
||||
@@ -757,7 +757,7 @@ define(function (require, exports, module) {
|
||||
* Determine whether the current set of files are using modules to pull in
|
||||
* additional files.
|
||||
*
|
||||
* @returns {boolean} - true if more files than the current directory have
|
||||
* @return {boolean} - true if more files than the current directory have
|
||||
* been read in.
|
||||
*/
|
||||
function usingModules() {
|
||||
@@ -1097,7 +1097,7 @@ define(function (require, exports, module) {
|
||||
* already been added to tern.
|
||||
*
|
||||
* @param {string} newFile - full path of new file being opened in the editor.
|
||||
* @returns {boolean} - true if tern initialization should be skipped,
|
||||
* @return {boolean} - true if tern initialization should be skipped,
|
||||
* false otherwise.
|
||||
*/
|
||||
function canSkipTernInitialization(newFile) {
|
||||
|
||||
@@ -55,7 +55,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Get the builtin libraries tern is using.
|
||||
*
|
||||
* @returns {Array.<string>} - array of library names.
|
||||
* @return {Array.<string>} - array of library names.
|
||||
* @private
|
||||
*/
|
||||
Session.prototype._getBuiltins = function () {
|
||||
@@ -324,9 +324,8 @@ define(function (require, exports, module) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{line: number, ch: number}} cursor - the cursor position
|
||||
* at which to retrieve a token
|
||||
* @returns {*} - the lexical state of the token
|
||||
* @param {Object} cursor - a CodeMirror token
|
||||
* @return {*} - the lexical state of the token
|
||||
*/
|
||||
function getLexicalState(token) {
|
||||
if (token.state.lexical) {
|
||||
@@ -343,10 +342,11 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Determine if the caret is either within a function call or on the function call itself.
|
||||
*
|
||||
* @returns {{inFunctionCall: boolean, functionCallPos: {{line: number, ch: number}}}
|
||||
* @return {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number}}}
|
||||
* inFunctionCall - true if the caret if either within a function call or on the
|
||||
* function call itself.
|
||||
* functionCallPos - the offset of the '(' character of the function call.
|
||||
* functionCallPos - the offset of the '(' character of the function call if inFunctionCall
|
||||
* is true, otherwise undefined.
|
||||
*/
|
||||
Session.prototype.getFunctionInfo = function () {
|
||||
var inFunctionCall = false,
|
||||
@@ -412,7 +412,6 @@ define(function (require, exports, module) {
|
||||
}
|
||||
|
||||
if (foundCall) {
|
||||
inFunctionCall = true;
|
||||
// we need to find the location of the called function so that we can request the functions type.
|
||||
// the token's lexical info will contain the column where the open "(" for the
|
||||
// function call occurs, but for whatever reason it does not have the line, so
|
||||
@@ -439,6 +438,7 @@ define(function (require, exports, module) {
|
||||
}
|
||||
|
||||
if (found) {
|
||||
inFunctionCall = true;
|
||||
functionCallPos = {line: line, ch: col};
|
||||
}
|
||||
}
|
||||
@@ -517,7 +517,7 @@ define(function (require, exports, module) {
|
||||
*
|
||||
* @param {string} query - the query prefix
|
||||
* @param {StringMatcher} matcher - the class to find query matches and sort the results
|
||||
* @returns {hints: Array.<string>, needGuesses: boolean} - array of
|
||||
* @return {hints: Array.<string>, needGuesses: boolean} - array of
|
||||
* matching hints. If needGuesses is true, then the caller needs to
|
||||
* request guesses and call getHints again.
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Get the value of current session.
|
||||
* Used for unit testing.
|
||||
* @returns {Session} - the current session.
|
||||
* @return {Session} - the current session.
|
||||
*/
|
||||
function getSession() {
|
||||
return session;
|
||||
@@ -283,7 +283,7 @@ define(function (require, exports, module) {
|
||||
/**
|
||||
* Create a new StringMatcher instance, if needed.
|
||||
*
|
||||
* @returns {StringMatcher} - a StringMatcher instance.
|
||||
* @return {StringMatcher} - a StringMatcher instance.
|
||||
*/
|
||||
function getStringMatcher() {
|
||||
if (!matcher) {
|
||||
@@ -299,7 +299,7 @@ define(function (require, exports, module) {
|
||||
* Check if a hint response is pending.
|
||||
*
|
||||
* @param {jQuery.Deferred} deferredHints - deferred hint response
|
||||
* @returns {boolean} - true if deferred hints are pending, false otherwise.
|
||||
* @return {boolean} - true if deferred hints are pending, false otherwise.
|
||||
*/
|
||||
function hintsArePending(deferredHints) {
|
||||
return (deferredHints && !deferredHints.hasOwnProperty("hints") &&
|
||||
|
||||
@@ -300,7 +300,7 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
* a parameter.
|
||||
*
|
||||
* @param {String} newFnType - Tern formatted function type string.
|
||||
* @returns {Array<{name: string, type: string, isOptional: boolean}>} where each entry in the array is a parameter.
|
||||
* @return {Array<{name: string, type: string, isOptional: boolean}>} where each entry in the array is a parameter.
|
||||
*/
|
||||
function getParameters(newFnType) {
|
||||
|
||||
@@ -395,7 +395,7 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
* Convert an infer function type to string.
|
||||
*
|
||||
* @param {*} inferType - one of the Infer's types; infer.Fn, infer.Prim, infer.Arr, infer.ANull
|
||||
* @returns {Array<{name: string, type: string, isOptional: boolean}>} where each entry in the array is a parameter.
|
||||
* @return {Array<{name: string, type: string, isOptional: boolean}>} where each entry in the array is a parameter.
|
||||
*/
|
||||
processInferFnTypeParameters = function (inferType) {
|
||||
var params = [],
|
||||
@@ -432,7 +432,7 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
|
||||
return params;
|
||||
} else {
|
||||
return [];
|
||||
throw new Error("No parameter hint found in '" + newFnType + "'");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -464,7 +464,7 @@ importScripts("thirdparty/requirejs/require.js");
|
||||
fnType = getParameters(data.type);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
_log("Error thrown by Tern in getParameters: " + error);
|
||||
_log("Error thrown in tern_worker, getParameters: " + error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user