Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7126c9
commit 579c37e
Showing
6 changed files
with
121 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ azureresources | |
walkthrough | ||
walkthroughs | ||
DEBUGTELEMETRY | ||
appservice | ||
containerapp | ||
staticwebapp |
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
40 changes: 40 additions & 0 deletions
40
ext/vscode/src/language/AzureYamlDocumentDropEditProvider.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,40 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { AzExtFsExtra, IActionContext, callWithTelemetryAndErrorHandling } from '@microsoft/vscode-azext-utils'; | ||
import * as path from 'path'; | ||
import * as vscode from 'vscode'; | ||
import { getProjectRelativePath } from './azureYamlUtils'; | ||
import { TelemetryId } from '../telemetry/telemetryId'; | ||
|
||
export class AzureYamlDocumentDropEditProvider implements vscode.DocumentDropEditProvider { | ||
public provideDocumentDropEdits(document: vscode.TextDocument, position: vscode.Position, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.DocumentDropEdit | undefined> { | ||
return callWithTelemetryAndErrorHandling(TelemetryId.AzureYamlProvideDocumentDropEdits, async (context: IActionContext) => { | ||
const maybeFolder = dataTransfer.get('text/uri-list')?.value; | ||
const maybeFolderUri = vscode.Uri.parse(maybeFolder); | ||
|
||
if (await AzExtFsExtra.pathExists(maybeFolderUri) && await AzExtFsExtra.isDirectory(maybeFolderUri)) { | ||
const basename = path.basename(maybeFolderUri.fsPath); | ||
const newRelativePath = getProjectRelativePath(document.uri, maybeFolderUri); | ||
|
||
const initialWhitespace = position.character === 0 ? '\n\t' : '\n'; | ||
|
||
const snippet = new vscode.SnippetString(initialWhitespace) | ||
.appendPlaceholder(basename).appendText(':\n') | ||
.appendText(`\t\tproject: ${newRelativePath}\n`) | ||
.appendText('\t\tlanguage: ') | ||
.appendChoice(['dotnet', 'csharp', 'fsharp', 'py', 'python', 'js', 'ts', 'java']) | ||
.appendText('\n') | ||
.appendText('\t\thost: ') | ||
.appendChoice(['appservice', 'containerapp', 'function', 'staticwebapp', 'aks']) | ||
.appendText('\n'); | ||
|
||
context.telemetry.properties.editProvided = 'true'; | ||
return new vscode.DocumentDropEdit(snippet); | ||
} | ||
|
||
context.telemetry.properties.editProvided = 'false'; | ||
return undefined; | ||
}); | ||
} | ||
} |
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
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