Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Fix #2813 - Go to Definition can't find toString() methods #2816

Merged
merged 2 commits into from
Feb 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/editor/CodeHintList.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ define(function (require, exports, module) {
* Computes top left location for hint list so that the list is not clipped by the window
*
* @private
* @return {Object.<left: number, top: number> }
* @return {{left: number, top: number}}
*/
CodeHintList.prototype._calcHintListLocation = function () {
var cursor = this.editor._codeMirror.cursorCoords(),
Expand Down
5 changes: 2 additions & 3 deletions src/extensions/default/HTMLCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ define(function (require, exports, module) {

/**
* Helper function for search(). Create a list of urls to existing files based on the query.
* @param {Object.<queryStr: string, ...} query -- a query object with a required property queryStr
* that will be used to filter out code hints
* @param {{queryStr: string}} query -- a query object, used to filter the code hints
* @return {Array.<string>}
*/
AttrHints.prototype._getUrlList = function (query) {
Expand Down Expand Up @@ -341,7 +340,7 @@ define(function (require, exports, module) {
/**
* Helper function that determins the possible value hints for a given html tag/attribute name pair
*
* @param {String} query
* @param {{queryStr: string}} query
* The current query
*
* @param {String} tagName
Expand Down
13 changes: 6 additions & 7 deletions src/language/JSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ define(function (require, exports, module) {

/**
* @private
* Return an Array with names and offsets for all functions in the specified text
* Return an object mapping function name to offset info for all functions in the specified text.
* Offset info is an array, since multiple functions of the same name can exist.
* @param {!string} text Document text
* @return {Object.<string, Array.<{offsetStart: number, offsetEnd: number}>}
*/
Expand Down Expand Up @@ -258,13 +259,11 @@ define(function (require, exports, module) {
// Filter for documents that contain the named function
var result = new $.Deferred(),
matchedDocuments = [],
rangeResults = [],
functionsInDocument;
rangeResults = [];

docEntries.forEach(function (docEntry) {
functionsInDocument = docEntry.functions[functionName];

if (functionsInDocument) {
if (docEntry.functions.hasOwnProperty(functionName)) {
var functionsInDocument = docEntry.functions[functionName];
matchedDocuments.push({doc: docEntry.doc, fileInfo: docEntry.fileInfo, functions: functionsInDocument});
}
});
Expand Down Expand Up @@ -359,7 +358,7 @@ define(function (require, exports, module) {
}

/**
* Return all functions that have the specified name.
* Return all functions that have the specified name, searching across all the given files.
*
* @param {!String} functionName The name to match.
* @param {!Array.<FileIndexManager.FileInfo>} fileInfos The array of files to search.
Expand Down
23 changes: 16 additions & 7 deletions src/utils/StringMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,24 @@ define(function (require, exports, module) {
// We keep track of the last query to know when we need to invalidate.
this._lastQuery = null;

// The specials information does not change for a given string, so we can cache it
// easily.
this._specialsCache = {};

// If we find that a string doesn't match a query, we know that it won't match for
// any queries with the same prefix, so we cache those non-matches.
this._noMatchCache = {};
}

/**
* Map from search-result string to the findSpecialCharacters() result for that string - easy to cache
* since this info doesn't change as the query changes.
* @type {Object.<string, {specials:Array.<number>, lastSegmentSpecialsIndex:number}>}
*/
StringMatcher.prototype._specialsCache = null;

/**
* Set of search-result strings that we know don't match the query _lastQuery - or any other query with
* that prefix.
* @type {Object.<string, boolean>}
*/
StringMatcher.prototype._noMatchCache = null;

/**
* Performs a single match using the stringMatch function. See stringMatch for full documentation.
*
Expand All @@ -789,12 +798,12 @@ define(function (require, exports, module) {
this._lastQuery = query;

// Check for a known non-matching string.
if (this._noMatchCache[str]) {
if (this._noMatchCache.hasOwnProperty(str)) {
return undefined;
}

// Load up the cached specials information (or build it if this is our first time through).
var special = this._specialsCache[str];
var special = this._specialsCache.hasOwnProperty(str) ? this._specialsCache[str] : undefined;
if (special === undefined) {
special = findSpecialCharacters(str);
this._specialsCache[str] = special;
Expand Down
6 changes: 0 additions & 6 deletions test/spec/JSUtils-test-files/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,3 @@ function\u0009unicodeTabBefore () {

function unicodeTabAfter\u0009() {
}


// test for issue #1390
MyClass.prototype.length = function () {
return 1;
}
9 changes: 9 additions & 0 deletions test/spec/JSUtils-test-files/tricky.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This function's name collides with an Object.prototype member
function toString() {
return "";
}

// This function's name collides with an Array.prototype member
function length() {
return 0;
}
Loading