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

Continued Language API work #2979

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 3 additions & 3 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ define(function (require, exports, module) {
// We'd like undefined/null/"" to mean plain text mode. CodeMirror defaults to plaintext for any
// unrecognized mode, but it complains on the console in that fallback case: so, convert
// here so we're always explicit, avoiding console noise.
return this.document.getLanguage().mode || "text/plain";
return this.document.getLanguage().getMode() || "text/plain";
};


Expand Down Expand Up @@ -1208,7 +1208,7 @@ define(function (require, exports, module) {
*
* @return {?(Object|string)} Name of syntax-highlighting mode, or object containing a "name" property
* naming the mode along with configuration options required by the mode.
* See {@link Languages#getLanguageForFileExtension()} and {@link Language#mode}.
* See {@link LanguageManager#getLanguageForFileExtension()} and {@link Language#getMode()}.
*/
Editor.prototype.getModeForSelection = function () {
// Check for mixed mode info
Expand Down Expand Up @@ -1241,7 +1241,7 @@ define(function (require, exports, module) {
/**
* Gets the syntax-highlighting mode for the document.
*
* @return {Object|String} Object or Name of syntax-highlighting mode; see {@link Languages#getLanguageForFileExtension()} and {@link Language#mode}.
* @return {Object|String} Object or Name of syntax-highlighting mode; see {@link LanguageManager#getLanguageForFileExtension()} and {@link Language#getMode()}.
*/
Editor.prototype.getModeForDocument = function () {
return this._codeMirror.getOption("mode");
Expand Down
13 changes: 7 additions & 6 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,9 @@ define(function (require, exports, module) {

var language = editor.getLanguageForSelection();

if (language.blockComment) {
blockCommentPrefixSuffix(editor, language.blockComment.prefix, language.blockComment.suffix, language.lineComment ? language.lineComment.prefix : null);
if (language.hasBlockCommentSyntax()) {
// getLineCommentPrefix returns null if no line comment syntax is defined
blockCommentPrefixSuffix(editor, language.getBlockCommentPrefix(), language.getBlockCommentSuffix(), language.getLineCommentPrefix());
}
}

Expand All @@ -485,10 +486,10 @@ define(function (require, exports, module) {

var language = editor.getLanguageForSelection();

if (language.lineComment) {
lineCommentPrefix(editor, language.lineComment.prefix);
} else if (language.blockComment) {
lineCommentPrefixSuffix(editor, language.blockComment.prefix, language.blockComment.suffix);
if (language.hasLineCommentSyntax()) {
lineCommentPrefix(editor, language.getLineCommentPrefix());
} else if (language.hasBlockCommentSyntax()) {
lineCommentPrefixSuffix(editor, language.getBlockCommentPrefix(), language.getBlockCommentSuffix());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/JavaScriptCodeHints/ScopeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ define(function (require, exports, module) {
file = split.file;

if (file.indexOf(".") > 1) { // ignore /.dotfiles
var mode = LanguageManager.getLanguageForFileExtension(entry.fullPath).mode;
var mode = LanguageManager.getLanguageForFileExtension(entry.fullPath).getMode();
if (mode === HintUtils.MODE_NAME) {
DocumentManager.getDocumentForPath(path).done(function (document) {
refreshOuterScope(dir, file, document.getText());
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/LESSSupport/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define(function (require, exports, module) {

var LanguageManager = brackets.getModule("language/LanguageManager");

var language = LanguageManager.defineLanguage("less", {
LanguageManager.defineLanguage("less", {
name: "LESS",
mode: "less",
fileExtensions: ["less"],
Expand Down
Loading