-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new code lens and grammar for SF APIs
- Loading branch information
Showing
6 changed files
with
131 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/vscode-extension/src/codeLensProviders/executeApiLensProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import VlocodeService from "../lib/vlocodeService"; | ||
import { container, injectable } from "@vlocode/core"; | ||
|
||
@injectable() | ||
export class ExecuteApiLensProvider implements vscode.CodeLensProvider { | ||
|
||
private regex = /^(GET|POST|PUT|DELETE|PATCH) (.*)$/i | ||
|
||
public static register(service: VlocodeService) { | ||
const lens = container.get(ExecuteApiLensProvider); | ||
vscode.languages.registerCodeLensProvider({ pattern: '**/*.{api,http,sfhttp,sfapi}' }, lens); | ||
vscode.languages.registerCodeLensProvider({ language: 'sfhttp' }, lens); | ||
} | ||
|
||
public provideCodeLenses(document: vscode.TextDocument): vscode.CodeLens[] { | ||
for (let i = 0; i < document.lineCount; i++) { | ||
const line = document.lineAt(i); | ||
const match = line.text.match(this.regex); | ||
if (match) { | ||
return [ | ||
new vscode.CodeLens(line.range, { | ||
title: `Execute as Salesforce API Request (${match[1].toLowerCase()})`, | ||
tooltip: "Execute the API request described in this file on the selected Salesforce org", | ||
command: "vlocode.api.execute", | ||
arguments: [ document ] | ||
}) | ||
]; | ||
} else if (line.text) { | ||
break; | ||
} | ||
} | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 10 additions & 11 deletions
21
packages/vscode-extension/src/symbolProviders/apexLogSymbolProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "Salesforce http API", | ||
"scopeName": "source.sfhttp", | ||
"patterns": [{ "include": "#method-and-headers" }], | ||
"repository": { | ||
"method-and-headers": { | ||
"patterns": [{ "include": "#method-and-url" }, { "include": "#header" }], | ||
"end": "\\r?\\n\\r?\\n" | ||
}, | ||
"method-and-url": { | ||
"captures": { | ||
"1": { "name": "http.sf.method" }, | ||
"2": { "name": "http.sf.url" } | ||
}, | ||
"match": "(?i)^(GET|POST|PUT|DELETE|PATCH) (.*)$\\n?", | ||
"name": "meta.http.sf.method-url" | ||
}, | ||
"header": { | ||
"captures": { | ||
"1": { "name": "http.sf.header.name" }, | ||
"2": { "name": "http.sf.header.value" } | ||
}, | ||
"match": "(?i)^([a-z]+)[ ]*:[ ]*([a-z]+)$\\n?", | ||
"name": "meta.http.sf.header" | ||
}, | ||
"comment": { | ||
"captures": { | ||
"1": { | ||
"name": "http.sf.method.comment" | ||
} | ||
}, | ||
"match": "(//).*$\\n?", | ||
"name": "comment.line.double-slash" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.