This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Smallish cleanups to docs & unit tests; improve a few tests #3429
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5dc6489
Cleanups, mainly to unit tests:
peterflynn 045fae6
Cleanups:
peterflynn f59be5a
Merge remote-tracking branch 'origin/master' into pflynn/unit-test-cl…
peterflynn 7250b96
Fix JSLint/JSHint errors (some of which were on master).
peterflynn 8d94d0d
Merge remote-tracking branch 'origin/master' into pflynn/unit-test-cl…
peterflynn 98f23f2
Code review fixes - tweak docs, cleanup vars, convert for to forEach()
peterflynn 9df7830
Code review: some more small JSDoc fixes
peterflynn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,7 @@ define(function (require, exports, module) { | |
/** | ||
* Resolves a language ID to a Language object. | ||
* File names have a higher priority than file extensions. | ||
* @param {!string} id Identifier for this language, use only letters a-z or digits 0-9 and _ inbetween (i.e. "cpp", "foo_bar", "c99") | ||
* @param {!string} id Identifier for this language: lowercase letters and digits with _ separators (e.g. "cpp", "foo_bar", "c99") | ||
* @return {Language} The language with the provided identifier or undefined | ||
*/ | ||
function getLanguage(id) { | ||
|
@@ -320,7 +320,7 @@ define(function (require, exports, module) { | |
|
||
/** | ||
* Sets the identifier for this language or prints an error to the console. | ||
* @param {!string} id Identifier for this language, use only letters a-z or digits 0-9, and _ inbetween (i.e. "cpp", "foo_bar", "c99") | ||
* @param {!string} id Identifier for this language: lowercase letters and digits with _ separators (e.g. "cpp", "foo_bar", "c99") | ||
* @return {boolean} Whether the ID was valid and set or not | ||
*/ | ||
Language.prototype._setId = function (id) { | ||
|
@@ -348,7 +348,7 @@ define(function (require, exports, module) { | |
|
||
/** | ||
* Sets the human-readable name of this language or prints an error to the console. | ||
* @param {!string} name Human-readable name of the language, as it's commonly referred to (i.e. "C++") | ||
* @param {!string} name Human-readable name of the language, as it's commonly referred to (e.g. "C++") | ||
* @return {boolean} Whether the name was valid and set or not | ||
*/ | ||
Language.prototype._setName = function (name) { | ||
|
@@ -371,7 +371,7 @@ define(function (require, exports, module) { | |
/** | ||
* Loads a mode and sets it for this language. | ||
* | ||
* @param {string|Array.<string>} mode CodeMirror mode (i.e. "htmlmixed"), optionally with a MIME mode defined by that mode ["clike", "text/x-c++src"] | ||
* @param {string|Array.<string>} mode CodeMirror mode (e.g. "htmlmixed"), optionally with a MIME mode defined by that mode ["clike", "text/x-c++src"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
* Unless the mode is located in thirdparty/CodeMirror2/mode/<name>/<name>.js, you need to first load it yourself. | ||
* | ||
* @return {$.Promise} A promise object that will be resolved when the mode is loaded and set | ||
|
@@ -523,7 +523,7 @@ define(function (require, exports, module) { | |
/** | ||
* Sets the prefixes to use for line comments in this language or prints an error to the console. | ||
* @param {!string|Array.<string>} prefix Prefix string or and array of prefix strings | ||
* to use for line comments (i.e. "//" or ["//", "#"]) | ||
* to use for line comments (e.g. "//" or ["//", "#"]) | ||
* @return {boolean} Whether the syntax was valid and set or not | ||
*/ | ||
Language.prototype.setLineCommentSyntax = function (prefix) { | ||
|
@@ -641,13 +641,14 @@ define(function (require, exports, module) { | |
/** | ||
* Defines a language. | ||
* | ||
* @param {!string} id Unique identifier for this language, use only letters a-z or digits 0-9, and _ inbetween (i.e. "cpp", "foo_bar", "c99") | ||
* @param {!string} id Unique identifier for this language: lowercase letters and digits with _ separators (e.g. "cpp", "foo_bar", "c99") | ||
* @param {!Object} definition An object describing the language | ||
* @param {!string} definition.name Human-readable name of the language, as it's commonly referred to (i.e. "C++") | ||
* @param {Array.<string>} definition.fileExtensions List of file extensions used by this language (i.e. ["php", "php3"]) | ||
* @param {Array.<string>} definition.blockComment Array with two entries defining the block comment prefix and suffix (i.e. ["<!--", "-->"]) | ||
* @param {string|Array.<string>} definition.lineComment Line comment prefixes (i.e. "//" or ["//", "#"]) | ||
* @param {string|Array.<string>} definition.mode CodeMirror mode (i.e. "htmlmixed"), optionally with a MIME mode defined by that mode ["clike", "text/x-c++src"] | ||
* @param {!string} definition.name Human-readable name of the language, as it's commonly referred to (e.g. "C++") | ||
* @param {Array.<string>} definition.fileExtensions List of file extensions used by this language (e.g. ["php", "php3"]). May contain periods (e.g. ["coffee.md"]) | ||
* @param {Array.<string>} definition.fileNames List of file names (e.g. ["Makefile"] or ["package.json]) | ||
* @param {Array.<string>} definition.blockComment Array with two entries defining the block comment prefix and suffix (e.g. ["<!--", "-->"]) | ||
* @param {string|Array.<string>} definition.lineComment Line comment prefixes (e.g. "//" or ["//", "#"]) | ||
* @param {string|Array.<string>} definition.mode CodeMirror mode (e.g. "htmlmixed"), optionally with a MIME mode defined by that mode ["clike", "text/x-c++src"] | ||
* Unless the mode is located in thirdparty/CodeMirror2/mode/<name>/<name>.js, you need to first load it yourself. | ||
* | ||
* @return {$.Promise} A promise object that will be resolved with a Language object | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ define(function (require, exports, module) { | |
} | ||
|
||
describe("Editor", function () { | ||
var defaultContent = 'Brackets is going to be awesome!\n'; | ||
var defaultContent = "Brackets is going to be awesome!\n"; | ||
var myDocument, myEditor; | ||
|
||
function createTestEditor(content, languageId) { | ||
|
@@ -110,36 +110,14 @@ define(function (require, exports, module) { | |
myEditor._codeMirror.setValue("new content"); | ||
expect(changeFired).toBe(true); | ||
}); | ||
|
||
}); | ||
|
||
describe("File extension to mode mapping", function () { | ||
|
||
it("should switch to the HTML mode for files ending in .html", function () { | ||
// verify editor content | ||
var mode = LanguageManager.getLanguageForPath("file:///only/testing/the/path.html").getMode(); | ||
expect(mode).toSpecifyModeNamed("text/x-brackets-html"); | ||
}); | ||
|
||
it("should switch modes even if the url has a query string", function () { | ||
// verify editor content | ||
var mode = LanguageManager.getLanguageForPath("http://only.org/testing/the/path.css?v=2").getMode(); | ||
expect(mode).toSpecifyModeNamed(langNames.css.mode); | ||
}); | ||
|
||
it("should accept just a file name too", function () { | ||
// verify editor content | ||
var mode = LanguageManager.getLanguageForPath("path.js").getMode(); | ||
expect(mode).toSpecifyModeNamed(langNames.javascript.mode); | ||
}); | ||
|
||
it("should default to plain text for unknown file extensions", function () { | ||
// verify editor content | ||
var mode = LanguageManager.getLanguageForPath("test.foo").getMode(); | ||
it("should set mode based on Document language", function () { | ||
createTestEditor(defaultContent, "html"); | ||
|
||
// "unknown" mode uses it's MIME type instead | ||
expect(mode).toBe("text/plain"); | ||
var htmlLanguage = LanguageManager.getLanguage("html"); | ||
expect(myEditor.getModeForDocument()).toBe(htmlLanguage.getMode()); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests above were just testing LanguageManager functionality. I simplified & moved those into LanguageManager-test, and in their place added a single test here to make sure the Document's language actually carries through to the Editor's mode (which the old tests never checked). |
||
}); | ||
|
||
describe("Focus", function () { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
for
and the next one should useArray.forEach