Skip to content
Open
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
7 changes: 4 additions & 3 deletions gulpfile.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ function _computeCacheManifest(baseDir, filePaths) {

totalSize = Math.round(totalSize/1024); // KB
console.log("Total size of cache in KB: ", totalSize);
if(totalSize > 75000){
throw new Error("The total size of the src or dist folder core assets exceeds 75MB." +
if(totalSize > 78000){
throw new Error("The total size of the src or dist folder core assets exceeds 78MB." +
"\nPlease review and trim storage. This significantly impacts the distribution size." +
"\nEither trim down the size or increase the limit after careful review.");
}
Expand Down Expand Up @@ -909,7 +909,8 @@ function _renameExtensionConcatAsExtensionJSInDist(extensionName) {
}

const minifyableExtensions = ["CloseOthers", "CodeFolding", "DebugCommands", "Git",
"HealthData", "JavaScriptCodeHints", "JavaScriptRefactoring", "QuickView", "TypeScriptSupport"];
"HealthData", "JavaScriptCodeHints", "JavaScriptRefactoring", "PHPSupport", "QuickView",
"TypeScriptSupport"];
// extensions that nned not be minified either coz they are single file extensions or some other reason.
const nonMinifyExtensions = ["CSSAtRuleCodeHints", "CSSCodeHints",
"CSSPseudoSelectorHints", "DarkTheme", "DocCommentHints", "HandlebarsSupport", "HTMLCodeHints",
Expand Down
22 changes: 17 additions & 5 deletions src-node/lsp-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,27 @@ exports.startServer = async function startServer(params) {
return { success: true, message: "already running", serverId };
}

// Prefer a server bundled in node_modules/.bin, otherwise fall back to PATH.
// Command resolution, in order:
// 1. An absolute path to a .js entry (e.g. a user-installed server like intelephense living
// outside src-node) runs on our own node runtime - process.execPath is phnode itself, the
// same spawn-self pattern _npmInstallInFolder and the ESLint service use. This sidesteps
// node_modules/.bin shims entirely (they are sh scripts / .cmd on Windows).
// 2. A server bundled in src-node/node_modules/.bin.
// 3. Fall back to PATH.
let commandPath = command;
const localBinPath = path.join(NODE_MODULES_BIN, command);
if (fs.existsSync(localBinPath)) {
commandPath = localBinPath;
let spawnArgs = args;
if (path.isAbsolute(command) && command.endsWith('.js')) {
spawnArgs = [command, ...args];
commandPath = process.execPath;
} else {
const localBinPath = path.join(NODE_MODULES_BIN, command);
if (fs.existsSync(localBinPath)) {
commandPath = localBinPath;
}
}

return new Promise((resolve, reject) => {
const serverProcess = spawn(commandPath, args, { stdio: ['pipe', 'pipe', 'pipe'] });
const serverProcess = spawn(commandPath, spawnArgs, { stdio: ['pipe', 'pipe', 'pipe'] });
const parser = createParser(serverId);

const serverState = {
Expand Down
3 changes: 2 additions & 1 deletion src/extensions/default/DefaultExtensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
],
"desktopOnly": [
"Git",
"TypeScriptSupport"
"TypeScriptSupport",
"PHPSupport"
],
"warnExtensionStoreExtensions": {
"description": "list extension ids here that you want to show this warning in extension store: 'You may not need this extension. Phoenix comes built in with this feature.'",
Expand Down
13 changes: 13 additions & 0 deletions src/extensions/default/HTMLCodeHints/html-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,25 @@
* Run JSLint on the current document. Reports results to the main UI. Displays
* a gold star when no errors are found.
*/
// html-validate cannot tokenize php blocks ("failed to tokenize <?php ..." parser errors on
// every php file). Blank them out with same-length whitespace - newlines preserved - so the
// surrounding HTML is linted normally and every reported position stays valid. Handles
// <?php ... ?>, <?= ... ?> and an unterminated <? ... at EOF (pure-php files lint clean).
function _blankPhpRegions(text) {

Check warning on line 87 in src/extensions/default/HTMLCodeHints/html-lint.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move function '_blankPhpRegions' to the outer scope.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AZ8mdI35vs9BZkREENI1&open=AZ8mdI35vs9BZkREENI1&pullRequest=3011
return text.replace(/<\?(?:php|=)?[\s\S]*?(?:\?>|$)/g, function (block) {
return block.replace(/[^\n]/g, " ");
});
}

async function lintOneFile(text, fullPath) {
return new Promise((resolve, reject)=>{
if(configErrorMessage){
resolve({ errors: _getLinterConfigFileErrorMsg() });
return;
}
if(/\.(php\d?|phtml?|phps|ctp)$/i.test(fullPath)) {
text = _blankPhpRegions(text);
}
IndexingWorker.execPeer("htmlLint", {
text,
filePath: fullPath,
Expand Down
8 changes: 8 additions & 0 deletions src/extensions/default/HTMLCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ define(function (require, exports, module) {
if (enabled) {
this.editor = editor;

// php files are mixed-mode: their HTML regions report "html" at the cursor and are
// served through the html registration. So a cursor whose language is actually "php"
// is inside real PHP code (<?php ... ?>), where markup abbreviations are never right -
// typing `addition(` there must not summon an Emmet hint.
if (editor.getLanguageForSelection().getId() === "php") {
return false;
}

// check the context before showing emmet hints, because we don't want to show
// emmet hints when its a Attribute name or value
// cause for those cases AttrHints should handle it
Expand Down
29 changes: 29 additions & 0 deletions src/extensions/default/HTMLCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,35 @@ define(function (require, exports, module) {

describe("Emmet hint provider", function () {

it("should not offer emmet inside php code regions, only in html regions of php files", function () {
// php is a mixed mode: <?php ... ?> regions are real PHP (emmet is never right
// there - e.g. typing `addition(`), while the surrounding markup is HTML where
// emmet must keep working.
const phpContent = "<?php\n" +
"$x = 1;\n" +
"function addition(\n" +
"?>\n" +
"<div>\n" +
"div\n" +
"</div>\n";
const phpDocument = SpecRunnerUtils.createMockDocument(phpContent, "php");
$("body").append("<div id='php-editor'/>");
const phpEditor = new Editor(phpDocument, true, $("#php-editor").get(0));

// cursor inside the php code region, right after `addition(`
phpEditor.setCursorPos({ line: 2, ch: 18 });
expect(phpEditor.getLanguageForSelection().getId()).toBe("php");
expect(HTMLCodeHints.emmetHintProvider.hasHints(phpEditor, null)).toBe(false);

// cursor in the html region after "div" - emmet abbreviation expansion still works
phpEditor.setCursorPos({ line: 5, ch: 3 });
expect(phpEditor.getLanguageForSelection().getId()).not.toBe("php");
expect(HTMLCodeHints.emmetHintProvider.hasHints(phpEditor, null)).toBe(true);

phpEditor.destroy();
$("#php-editor").remove();
});

it("should display emmet hint and expand to boilerplate code on ! press", function () {

let emmetBoilerPlate = [
Expand Down
10 changes: 7 additions & 3 deletions src/extensions/default/JavaScriptCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,13 @@
? LanguageManager.getLanguageForPath(editor.document.file.fullPath).getId()
: null;

// When the TypeScript language server serves this language, defer to it entirely: don't
// create a Tern session, so ScopeManager never indexes the project alongside the server.
if (_lspServesLanguage(languageId)) {
// When a language server serves this language, defer to it entirely: don't create a
// Tern session, so ScopeManager never indexes the project alongside the server.
// EXCEPT inline-script host documents (html, php): a server claiming those (e.g.
// Intelephense for php) serves only the host language, not the embedded <script> JS -
// Tern must keep its session there or embedded-JS intelligence dies. Feature routing
// by cursor language already keeps the two from overlapping.
if (_lspServesLanguage(languageId) && _inlineScriptLanguages.indexOf(languageId) === -1) {

Check warning on line 714 in src/extensions/default/JavaScriptCodeHints/main.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use `.includes()`, rather than `.indexOf()`, when checking for existence.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AZ8mdI7gvs9BZkREENJM&open=AZ8mdI7gvs9BZkREENJM&pullRequest=3011
session = null;
return;
}
Expand Down
Loading
Loading