forked from redhat-developer/vscode-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added file association option to binding wizard
- Loading branch information
1 parent
27687c6
commit 5f56d3a
Showing
4 changed files
with
153 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as path from "path"; | ||
import { TextDocument, Uri, workspace, WorkspaceFolder } from "vscode"; | ||
|
||
/** | ||
* Return the current workspace uri from root | ||
* | ||
* @param document the opened TextDocument | ||
* @returns the path from root of the current workspace | ||
*/ | ||
export function getWorkspaceUri(document: TextDocument): Uri | undefined { | ||
const currentWorkspace: WorkspaceFolder = (document && document.uri) ? workspace.getWorkspaceFolder(document.uri) : undefined; | ||
return ((currentWorkspace && currentWorkspace.uri) || (workspace.workspaceFolders && workspace.workspaceFolders[0].uri)); | ||
} | ||
|
||
/** | ||
* Return the uri of the current file | ||
* | ||
* @param document the opened TextDocument | ||
* @returns the uri of the current file | ||
*/ | ||
export function getFilePath(document: TextDocument): string { | ||
return (document && document.uri) ? document.uri.fsPath : undefined; | ||
} | ||
|
||
/** | ||
* Uses path to return a basename from a uri | ||
* | ||
* @param filePath the uri of the file | ||
* @return the filename | ||
*/ | ||
export function getFileName(filePath: string): string { | ||
return path.basename(filePath); | ||
} | ||
|
||
/** | ||
* Return the relative file path between a start and destination uri | ||
* | ||
* @param startPath the absolute path of the beginning directory | ||
* @param destinationPath the absolute path of destination file | ||
* @returns the path to the destination relative to the start | ||
*/ | ||
export function getRelativePath(startPath: string, destinationPath: string): string { | ||
return path.relative(path.normalize(startPath), path.normalize(destinationPath)).replace(/\\/g, '/'); | ||
} | ||
|
||
/** | ||
* Uses path to return the directory name from a uri | ||
* | ||
* @param filePath the uri of the file | ||
* @return the directory path | ||
*/ | ||
export function getDirectoryPath(filePath: string): string { | ||
return path.dirname(filePath); | ||
|
||
} |