chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:38:42 +08:00
commit 2d485ba600
8326 changed files with 2641263 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
"preLaunchTask": "npm"
}
]
}
+11
View File
@@ -0,0 +1,11 @@
{
"version": "2.0.0",
"command": "npm",
"type": "shell",
"presentation": {
"reveal": "silent"
},
"args": ["run", "compile"],
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
+7
View File
@@ -0,0 +1,7 @@
test/**
build/**
out/test/**
src/**
tsconfig.json
cgmanifest.json
.vscode
+75
View File
@@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
import * as vscodeGrammarUpdater from 'vscode-grammar-updater';
function adaptInjectionScope(grammar) {
// we're using the HTML grammar from https://github.com/textmate/html.tmbundle which has moved away from source.js.embedded.html
// also we need to add source.css scope for PHP code in <style> tags, which are handled differently in atom
const oldInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js.embedded.html - (meta.embedded.block.php | meta.embedded.line.php))";
const newInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.css - (meta.embedded.block.php | meta.embedded.line.php))";
const injections = grammar.injections;
const injection = injections[oldInjectionKey];
if (!injection) {
throw new Error("Can not find PHP injection to patch");
}
delete injections[oldInjectionKey];
injections[newInjectionKey] = injection;
}
function includeDerivativeHtml(grammar) {
grammar.patterns.forEach(pattern => {
if (pattern.include === 'text.html.basic') {
pattern.include = 'text.html.derivative';
}
});
}
// Workaround for https://github.com/microsoft/vscode/issues/40279
// and https://github.com/microsoft/vscode-textmate/issues/59
function fixBadRegex(grammar) {
function fail(msg) {
throw new Error(`fixBadRegex callback couldn't patch ${msg}. It may be obsolete`);
}
const scopeResolution = grammar.repository['scope-resolution'];
if (scopeResolution) {
const match = scopeResolution.patterns[0].match;
if (match === '(?i)([a-z_\\x{7f}-\\x{10ffff}\\\\][a-z0-9_\\x{7f}-\\x{10ffff}\\\\]*)(?=\\s*::)') {
scopeResolution.patterns[0].match = '([A-Za-z_\\x{7f}-\\x{10ffff}\\\\][A-Za-z0-9_\\x{7f}-\\x{10ffff}\\\\]*)(?=\\s*::)';
} else {
fail('scope-resolution.match');
}
} else {
fail('scope-resolution');
}
const functionCall = grammar.repository['function-call'];
if (functionCall) {
const begin0 = functionCall.patterns[0].begin;
if (begin0 === '(?xi)\n(\n \\\\?(?<![a-z0-9_\\x{7f}-\\x{10ffff}]) # Optional root namespace\n [a-z_\\x{7f}-\\x{10ffff}][a-z0-9_\\x{7f}-\\x{10ffff}]* # First namespace\n (?:\\\\[a-z_\\x{7f}-\\x{10ffff}][a-z0-9_\\x{7f}-\\x{10ffff}]*)+ # Additional namespaces\n)\\s*(\\()') {
functionCall.patterns[0].begin = '(?x)\n(\n \\\\?(?<![a-zA-Z0-9_\\x{7f}-\\x{10ffff}]) # Optional root namespace\n [a-zA-Z_\\x{7f}-\\x{10ffff}][a-zA-Z0-9_\\x{7f}-\\x{10ffff}]* # First namespace\n (?:\\\\[a-zA-Z_\\x{7f}-\\x{10ffff}][a-zA-Z0-9_\\x{7f}-\\x{10ffff}]*)+ # Additional namespaces\n)\\s*(\\()';
} else {
fail('function-call.begin0');
}
const begin1 = functionCall.patterns[1].begin;
if (begin1 === '(?i)(\\\\)?(?<![a-z0-9_\\x{7f}-\\x{10ffff}])([a-z_\\x{7f}-\\x{10ffff}][a-z0-9_\\x{7f}-\\x{10ffff}]*)\\s*(\\()') {
functionCall.patterns[1].begin = '(\\\\)?(?<![a-zA-Z0-9_\\x{7f}-\\x{10ffff}])([a-zA-Z_\\x{7f}-\\x{10ffff}][a-zA-Z0-9_\\x{7f}-\\x{10ffff}]*)\\s*(\\()';
} else {
fail('function-call.begin1');
}
} else {
fail('function-call');
}
}
vscodeGrammarUpdater.update('KapitanOczywisty/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex);
vscodeGrammarUpdater.update('KapitanOczywisty/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', grammar => {
adaptInjectionScope(grammar);
includeDerivativeHtml(grammar);
});
+17
View File
@@ -0,0 +1,17 @@
{
"registrations": [
{
"component": {
"type": "git",
"git": {
"name": "language-php",
"repositoryUrl": "https://github.com/KapitanOczywisty/language-php",
"commitHash": "5e8f000cb5a20f44f7a7a89d07ad0774031c53f3"
}
},
"license": "MIT",
"version": "0.49.0"
}
],
"version": 1
}
+171
View File
@@ -0,0 +1,171 @@
{
"comments": {
"lineComment": "//", // "#"
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{
"open": "{",
"close": "}",
"notIn": [
"string"
]
},
{
"open": "[",
"close": "]",
"notIn": [
"string"
]
},
{
"open": "(",
"close": ")",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string",
"comment"
]
},
{
"open": "/**",
"close": " */",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"'",
"'"
],
[
"\"",
"\""
],
[
"`",
"`"
]
],
"indentationRules": {
"increaseIndentPattern": "({(?!.*}).*|\\(|\\[|((else(\\s)?)?if|else|for(each)?|while|switch|case).*:)\\s*((/[/*].*|)?$|\\?>)",
"decreaseIndentPattern": "^(.*\\*\\/)?\\s*((\\})|(\\)+[;,])|(\\]\\)*[;,])|\\b(else:)|\\b((end(if|for(each)?|while|switch));))"
},
"folding": {
"markers": {
"start": "^\\s*(#|\/\/)region\\b",
"end": "^\\s*(#|\/\/)endregion\\b"
}
},
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\-\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
"onEnterRules": [
{
// e.g. /** | */
"beforeText": "^\\s*\\/\\*\\*(?!\\/)([^\\*]|\\*(?!\\/))*$",
"afterText": "^\\s*\\*\\/$",
"action": {
"indent": "indentOutdent",
"appendText": " * "
}
},
{
// e.g. /** ...|
"beforeText": "^\\s*\\/\\*\\*(?!\\/)([^\\*]|\\*(?!\\/))*$",
"action": {
"indent": "none",
"appendText": " * "
}
},
{
// e.g. * ...|
"beforeText": "^(\\t|(\\ \\ ))*\\ \\*(\\ ([^\\*]|\\*(?!\\/))*)?$",
"action": {
"indent": "none",
"appendText": "* ",
},
},
{
// e.g. */|
"beforeText": "^(\\t|(\\ \\ ))*\\ \\*\\/\\s*$",
"action": {
"indent": "none",
"removeText": 1
},
},
{
// e.g. *-----*/|
"beforeText": "^(\\t|(\\ \\ ))*\\ \\*[^/]*\\*\\/\\s*$",
"action": {
"indent": "none",
"removeText": 1
}
},
{
// Decrease indentation after single line if/else if/else, for, foreach, or while
"previousLineText": "^\\s*(((else ?)?if|for(each)?|while)\\s*\\(.*\\)\\s*|else\\s*)$",
// But make sure line doesn't have braces or is not another if statement
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
"action": {
"indent": "outdent"
}
},
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}
+69
View File
@@ -0,0 +1,69 @@
{
"name": "php",
"displayName": "%displayName%",
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "0.10.x"
},
"categories": ["Programming Languages"],
"contributes": {
"languages": [
{
"id": "php",
"extensions": [
".php",
".php4",
".php5",
".phtml",
".ctp"
],
"aliases": [
"PHP",
"php"
],
"firstLine": "^#!\\s*/.*\\bphp\\b",
"mimetypes": [
"application/x-php"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "php",
"scopeName": "source.php",
"path": "./syntaxes/php.tmLanguage.json"
},
{
"language": "php",
"scopeName": "text.html.php",
"path": "./syntaxes/html.tmLanguage.json",
"embeddedLanguages": {
"text.html": "html",
"source.php": "php",
"source.sql": "sql",
"text.xml": "xml",
"source.js": "javascript",
"source.json": "json",
"source.css": "css"
}
}
],
"snippets": [
{
"language": "php",
"path": "./snippets/php.code-snippets"
}
]
},
"scripts": {
"update-grammar": "node ./build/update-grammar.mjs"
},
"repository": {
"type": "git",
"url": "https://github.com/microsoft/vscode.git"
}
}
+4
View File
@@ -0,0 +1,4 @@
{
"displayName": "PHP Language Basics",
"description": "Provides syntax highlighting and bracket matching for PHP files."
}
+371
View File
@@ -0,0 +1,371 @@
{
"$… = ( … ) ? … : …": {
"prefix": "if?",
"body": "$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b} ;",
"description": "Ternary conditional assignment"
},
"$… = array (…)": {
"prefix": "array",
"body": "$${1:arrayName} = array($0);",
"description": "Array initializer"
},
"$… = […]": {
"prefix": "shorray",
"body": "$${1:arrayName} = [$0];",
"description": "Array initializer"
},
"… => …": {
"prefix": "keyval,kvp",
"body": "'$1' => $2$0",
"description": "Key-Value pair"
},
"$a <=> $b": {
"prefix": "spaceship",
"body": "(${1:\\$a} <=> ${2:\\$b} === ${3|0,1,-1|})",
"description": "Spaceship equality check"
},
"attribute": {
"prefix": "attr",
"body": [
"#[\\\\Attribute]",
"class ${1:My}Attribute${2: extends ${3:MyOther}Attribute} {",
"\t$0",
"}"
],
"description": "Attribute"
},
"attribute target": {
"prefix": "attr_target",
"body": "\\Attribute::${1|TARGET_ALL,TARGET_CLASS,TARGET_FUNCTION,TARGET_METHOD,TARGET_PROPERTY,TARGET_CLASS_CONSTANT,TARGET_PARAMETER,IS_REPEATABLE|}$0"
},
"attribute with target": {
"prefix": "attr_with_target",
"body": [
"#[\\\\Attribute(\\Attribute::${1|TARGET_ALL,TARGET_CLASS,TARGET_FUNCTION,TARGET_METHOD,TARGET_PROPERTY,TARGET_CLASS_CONSTANT,TARGET_PARAMETER,IS_REPEATABLE|}$2)]",
"class ${3:My}Attribute${4: extends ${5:MyOther}Attribute} {",
"\t$0",
"}"
],
"description": "Attribute - Chain targets with attr_target snippet"
},
"case …": {
"prefix": "case",
"body": [
"case '${1:value}':",
"\t${0:# code...}",
"\tbreak;"
],
"description": "Case Block"
},
"class …": {
"prefix": "class",
"body": [
"${1:${2|final ,readonly |}}class ${3:${TM_FILENAME_BASE}}${4: extends ${5:AnotherClass}} ${6:implements ${7:Interface}}",
"{",
"\t$0",
"}",
""
],
"description": "Class definition"
},
"class __construct": {
"prefix": "construct",
"body": [
"${1|public,private,protected|} function __construct(${2:${3:Type} $${4:var}${5: = ${6:null}}}$7) {",
"\t\\$this->${4:var} = $${4:var};$0",
"}"
]
},
"class function …": {
"prefix": "class_fun",
"body": [
"${1|public ,private ,protected |}${2: static }function ${3:FunctionName}(${4:${5:${6:Type} }$${7:var}${8: = ${9:null}}}$10) : ${11:Returntype}",
"{",
"\t${0:# code...}",
"}"
],
"description": "Function for classes, traits and enums"
},
"const": {
"prefix": "const",
"body": "${1|public ,private ,protected |}const ${2:NAME} = $3;",
"description": "Constant for classes, traits, enums"
},
"enum": {
"prefix": "enum",
"body": [
"enum $1 {",
"\tcase $2;$0",
"}"
]
},
"define(…, …)": {
"prefix": "def",
"body": [
"define('$1', ${2:'$3'});",
"$0"
],
"description": "Definition"
},
"do … while …": {
"prefix": "do",
"body": [
"do {",
"\t${0:# code...}",
"} while (${1:$${2:a} <= ${3:10}});"
],
"description": "Do-While loop"
},
"else …": {
"prefix": "else",
"body": [
"else {",
"\t${0:# code...}",
"}"
],
"description": "Else block"
},
"elseif …": {
"prefix": "elseif",
"body": [
"elseif (${1:condition}) {",
"\t${0:# code...}",
"}"
],
"description": "Elseif block"
},
"for …": {
"prefix": "for",
"body": [
"for ($${1:i}=${2:0}; $${1:i} < $3; $${1:i}++) { ",
"\t${0:# code...}",
"}"
],
"description": "For-loop"
},
"foreach …": {
"prefix": "foreach",
"body": [
"foreach ($${1:variable} as $${2:key}${3: => $${4:value}}) {",
"\t${0:# code...}",
"}"
],
"description": "Foreach loop"
},
"function": {
"prefix": "fun",
"body": [
"function ${1:FunctionName}($2)${3: : ${4:Returntype}} {",
"\t$0",
"}"
],
"description": "Function - use param snippet for parameters"
},
"anonymous function": {
"prefix": "fun_anonymous",
"body": [
"function ($1)${2: use ($${3:var})} {",
"\t$0",
"}"
],
"description": "Anonymous Function"
},
"if …": {
"prefix": "if",
"body": [
"if (${1:condition}) {",
"\t${0:# code...}",
"}"
],
"description": "If block"
},
"if … else …": {
"prefix": "ifelse",
"body": [
"if (${1:condition}) {",
"\t${2:# code...}",
"} else {",
"\t${3:# code...}",
"}",
"$0"
],
"description": "If Else block"
},
"match": {
"prefix": "match",
"body": [
"match (${1:expression}) {",
"\t$2 => $3,",
"\t$4 => $5,$0",
"}"
],
"description": "Match expression; like switch with identity checks. Use keyval snippet to chain expressions"
},
"param": {
"prefix": "param",
"body": "${1:Type} $${2:var}${3: = ${4:null}}$5",
"description": "Parameter definition"
},
"property": {
"prefix": "property",
"body": "${1|public ,private ,protected |}${2|static ,readonly |}${3:Type} $${4:var}${5: = ${6:null}};$0",
"description": "Property"
},
"PHPDoc class …": {
"prefix": "doc_class",
"body": [
"/**",
" * ${8:undocumented class}",
" */",
"${1:${2|final ,readonly |}}class ${3:${TM_FILENAME_BASE}}${4: extends ${5:AnotherClass}} ${6:implements ${7:Interface}}",
"{",
"\t$0",
"}",
""
],
"description": "Documented Class Declaration"
},
"PHPDoc function …": {
"prefix": "doc_fun",
"body": [
"/**",
" * ${1:undocumented function summary}",
" *",
" * ${2:Undocumented function long description}",
" *",
"${3: * @param ${4:Type} $${5:var} ${6:Description}}",
"${7: * @return ${8:type}}",
"${9: * @throws ${10:conditon}}",
" **/",
"${11:public }function ${12:FunctionName}(${13:${14:${4:Type} }$${5:var}${15: = ${16:null}}}17)",
"{",
"\t${0:# code...}",
"}"
],
"description": "Documented function"
},
"PHPDoc param …": {
"prefix": "doc_param",
"body": [
"* @param ${1:Type} ${2:var} ${3:Description}$0"
],
"description": "Paramater documentation"
},
"PHPDoc trait": {
"prefix": "doc_trait",
"body": [
"/**",
" * $1",
" */",
"trait ${2:TraitName}",
"{",
"\t$0",
"}",
""
],
"description": "Trait"
},
"PHPDoc var": {
"prefix": "doc_var",
"body": [
"/** @var ${1:Type} $${2:var} ${3:description} */",
"${4:protected} $${2:var}${5: = ${6:null}};$0"
],
"description": "Documented Class Variable"
},
"Region End": {
"prefix": "#endregion",
"body": [
"#endregion"
],
"description": "Folding Region End"
},
"Region Start": {
"prefix": "#region",
"body": [
"#region"
],
"description": "Folding Region Start"
},
"switch …": {
"prefix": "switch",
"body": [
"switch (\\$${1:variable}) {",
"\tcase '${2:value}':",
"\t\t${3:# code...}",
"\t\tbreak;",
"\t$0",
"\tdefault:",
"\t\t${4:# code...}",
"\t\tbreak;",
"}"
],
"description": "Switch block"
},
"$this->…": {
"prefix": "this",
"body": "\\$this->$0;",
"description": "$this->..."
},
"Throw Exception": {
"prefix": "throw",
"body": [
"throw new $1Exception(${2:\"${3:Error Processing Request}\"}${4:, ${5:1}});",
"$0"
],
"description": "Throw exception"
},
"trait …": {
"prefix": "trait",
"body": [
"trait ${1:TraitName}",
"{",
"\t$0",
"}",
""
],
"description": "Trait"
},
"Try Catch Block": {
"prefix": "try",
"body": [
"try {",
"\t${1://code...}",
"} catch (${2:\\Throwable} ${3:\\$th}) {",
"\t${4://throw \\$th;}",
"}"
],
"description": "Try catch block"
},
"use function": {
"prefix": "use_fun",
"body": "use function $1;"
},
"use const": {
"prefix": "use_const",
"body": "use const $1;"
},
"use grouping": {
"prefix": "use_group",
"body": [
"use${1| const , function |}$2\\{",
"\t$0,",
"}"
],
"description": "Use grouping imports"
},
"use as ": {
"prefix": "use_as",
"body": "use${1| const , function |}$2 as $3;",
"description": "Use as alias"
},
"while …": {
"prefix": "while",
"body": [
"while (${1:$${2:a} <= ${3:10}}) {",
"\t${0:# code...}",
"}"
],
"description": "While-loop"
}
}
@@ -0,0 +1,98 @@
{
"information_for_contributors": [
"This file has been converted from https://github.com/KapitanOczywisty/language-php/blob/master/grammars/html.cson",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/KapitanOczywisty/language-php/commit/ff64523c94c014d68f5dec189b05557649c5872a",
"name": "PHP",
"scopeName": "text.html.php",
"injections": {
"L:meta.embedded.php.blade": {
"patterns": [
{
"include": "text.html.basic"
},
{
"include": "text.html.php.blade#blade"
}
]
},
"text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.css - (meta.embedded.block.php | meta.embedded.line.php))": {
"patterns": [
{
"include": "#php-tag"
}
]
}
},
"patterns": [
{
"begin": "\\A#!",
"beginCaptures": {
"0": {
"name": "punctuation.definition.comment.php"
}
},
"end": "$",
"name": "comment.line.shebang.php"
},
{
"include": "text.html.derivative"
}
],
"repository": {
"php-tag": {
"patterns": [
{
"begin": "<\\?(?i:php|=)?(?![^?]*\\?>)",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.begin.php"
}
},
"end": "(\\?)>",
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.end.php"
},
"1": {
"name": "source.php"
}
},
"name": "meta.embedded.block.php",
"contentName": "source.php",
"patterns": [
{
"include": "source.php"
}
]
},
{
"begin": "<\\?(?i:php|=)?",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.begin.php"
}
},
"end": "(\\?)>",
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.end.php"
},
"1": {
"name": "source.php"
}
},
"name": "meta.embedded.line.php",
"contentName": "source.php",
"patterns": [
{
"include": "source.php"
}
]
}
]
}
}
}
File diff suppressed because one or more lines are too long