Skip to content

Commit 63d2662

Browse files
committed
chore: improve readability and add support for php and jsp
1 parent 17cb388 commit 63d2662

File tree

1 file changed

+23
-4
lines changed
  • src/extensionsIntegrated/Emmet

1 file changed

+23
-4
lines changed

src/extensionsIntegrated/Emmet/main.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ define(function (require, exports, module) {
3131
negativeSymbols
3232
} = require('./emmet-snippets');
3333

34+
3435
/**
3536
* The Emmet api's
3637
*/
3738
const EXPAND_ABBR = Phoenix.libs.Emmet.expand;
3839
// const EMMET = Phoenix.libs.Emmet.module;
3940

41+
4042
/**
4143
* A list of all the markup snippets that can be expanded.
4244
* For ex: 'link:css', 'iframe'
4345
* They expand differently as compared to normal tags.
46+
* Refer to `./emmet-snippets.js` file for more info.
4447
*/
4548
const markupSnippetsList = Object.keys(markupSnippets);
4649

@@ -60,6 +63,14 @@ define(function (require, exports, module) {
6063
function EmmetMarkupHints() {
6164
}
6265

66+
67+
/**
68+
* Checks whether hints are available for the current word where cursor is present.
69+
*
70+
* @param {Editor} editor - the editor instance
71+
* @param {String} implicitChar - unused param [didn't remove, as we might need it in future]
72+
* @returns {Boolean} - true if the abbr can be expanded otherwise false.
73+
*/
6374
EmmetMarkupHints.prototype.hasHints = function (editor, implicitChar) {
6475
if (enabled) {
6576
this.editor = editor;
@@ -85,7 +96,9 @@ define(function (require, exports, module) {
8596

8697
/**
8798
* Returns the Emmet hint for the current word before the cursor.
88-
* The hint element will have an appended "E" icon to indicate it's an Emmet abbreviation.
99+
* The hint element will have an appended "Emmet" icon at bottom-rigth to indicate it's an Emmet abbreviation.
100+
*
101+
* @param {String} implicitChar - unused param [didn't remove, as we might need it in future]
89102
*/
90103
EmmetMarkupHints.prototype.getHints = function (implicitChar) {
91104
const wordObj = getWordBeforeCursor(this.editor);
@@ -132,7 +145,12 @@ define(function (require, exports, module) {
132145
}
133146

134147

135-
EmmetMarkupHints.prototype.insertHint = function (completion) {
148+
/**
149+
* Responsible for updating the abbr with the expanded text in the editor.
150+
* This function calls helper functions for this as there are,
151+
* lot of complex cases that should be taken care of.
152+
*/
153+
EmmetMarkupHints.prototype.insertHint = function () {
136154
const wordObj = getWordBeforeCursor(this.editor);
137155
const config = createConfig(this.editor);
138156
const expandedAbbr = isExpandable(this.editor, wordObj.word, config);
@@ -152,7 +170,7 @@ define(function (require, exports, module) {
152170
function createConfig(editor) {
153171
const fileType = editor.document.getLanguage().getId();
154172

155-
if (fileType === "html") {
173+
if (fileType === "html" || fileType === "php" || fileType === "jsp") {
156174
return { syntax: "html", type: "markup" };
157175
}
158176

@@ -163,6 +181,7 @@ define(function (require, exports, module) {
163181
return false;
164182
}
165183

184+
166185
/**
167186
* Determines whether a given character is allowed as part of an Emmet abbreviation
168187
*
@@ -514,7 +533,7 @@ define(function (require, exports, module) {
514533
preferenceChanged();
515534

516535
var emmetMarkupHints = new EmmetMarkupHints();
517-
CodeHintManager.registerHintProvider(emmetMarkupHints, ["html"], 2);
536+
CodeHintManager.registerHintProvider(emmetMarkupHints, ["html", "php", "jsp"], 2);
518537

519538
});
520539
});

0 commit comments

Comments
 (0)