should work
This commit is contained in:
parent
51ed506ced
commit
845948c240
|
|
@ -68,9 +68,11 @@
|
||||||
"highlighting"
|
"highlighting"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/haxo-games/x86-x64-syntax-highlighting#readme",
|
"homepage": "https://github.com/haxo-games/x86-x64-syntax-highlighting#readme",
|
||||||
"devDependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"cheerio": "^1.0.0",
|
"cheerio": "^1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
"vscode": "^1.1.34"
|
"vscode": "^1.1.34"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,11 @@ async function fetchInstructionInfo(instruction) {
|
||||||
return hoverContent;
|
return hoverContent;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.status === 404) {
|
if (error.response && error.response.status === 404) {
|
||||||
// Handle 404 error specifically
|
console.warn(`Instruction info not found for: ${instruction}`);
|
||||||
return undefined; // or return null based on your preference
|
} else {
|
||||||
}
|
|
||||||
console.error(`Failed to fetch instruction info: ${error.message}`);
|
console.error(`Failed to fetch instruction info: ${error.message}`);
|
||||||
return undefined; // Handle other errors if necessary
|
}
|
||||||
|
return null; // Return null if fetching fails
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,17 +89,65 @@ function findDefinition(document, word) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for label
|
// Look for label
|
||||||
const labelRegex = new RegExp(`^(${word}|FLAT:${word}):`, 'i');
|
const labelRegex = new RegExp(`^${word}:`, 'i');
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
if (labelRegex.test(lines[i])) {
|
if (labelRegex.test(lines[i])) {
|
||||||
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for lcomm directive
|
// Look for extern declarations
|
||||||
const lcommRegex = new RegExp(`\\.lcomm\\s+${word}`, 'i');
|
const externRegex = new RegExp(`^extern\\s+${word}\\s*`, 'i');
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
if (lcommRegex.test(lines[i])) {
|
if (externRegex.test(lines[i])) {
|
||||||
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for global declarations
|
||||||
|
const globalRegex = new RegExp(`^global\\s+${word}\\s*`, 'i');
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
if (globalRegex.test(lines[i])) {
|
||||||
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for struct definitions
|
||||||
|
const structRegex = new RegExp(`^\\s*struc\\s+${word}\\s*`, 'i');
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
if (structRegex.test(lines[i])) {
|
||||||
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for section declarations
|
||||||
|
const sectionRegex = new RegExp(`^section\\s+${word}\\s*`, 'i');
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
if (sectionRegex.test(lines[i])) {
|
||||||
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for macro definitions
|
||||||
|
const macroRegex = new RegExp(`^\\s*%define\\s+${word}\\s*`, 'i');
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
if (macroRegex.test(lines[i])) {
|
||||||
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for equates
|
||||||
|
const equateRegex = new RegExp(`\\bequ\\s+${word}\\s*`, 'i');
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
if (equateRegex.test(lines[i])) {
|
||||||
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for data declarations (db, dw, dd)
|
||||||
|
const dataRegex = new RegExp(`\\b${word}\\s+`, 'i');
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
if (dataRegex.test(lines[i])) {
|
||||||
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
return new vscode.Location(document.uri, new vscode.Position(i, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "keyword.control.directive.extern.x86asm",
|
"name": "keyword.control.directive.extern.x86asm",
|
||||||
"match": "\\.extern\\b"
|
"match": "\\bextern\\b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "keyword.control.directive.global.x86asm",
|
"name": "keyword.control.directive.global.x86asm",
|
||||||
"match": "\\.global\\b"
|
"match": "\\bglobal\\b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "keyword.control.directive.weak.x86asm",
|
"name": "keyword.control.directive.weak.x86asm",
|
||||||
|
|
@ -111,6 +111,14 @@
|
||||||
{
|
{
|
||||||
"name": "keyword.control.directive.internal.x86asm",
|
"name": "keyword.control.directive.internal.x86asm",
|
||||||
"match": "\\.internal\\b"
|
"match": "\\.internal\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.control.directive.default.x86asm",
|
||||||
|
"match": "\\bdefault\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.control.directive.rel.x86asm",
|
||||||
|
"match": "\\brel\\b"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue