Skip to content

Commit

Permalink
Merge pull request #103 from zardoy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Feb 17, 2023
2 parents 3a25f12 + cf8e348 commit 20e2856
Show file tree
Hide file tree
Showing 28 changed files with 551 additions and 153 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}
# optional
EXTENSION_ICON: ${{ secrets.EXTENSION_ICON }}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"tsEssentialPlugins.autoImport.changeToNamespaceImport": {
"typescript": {
"namespace": "ts",
"addImport": false
}
},
"tsEssentialPlugins.suggestions.ignoreAutoImports": [
"typescript-full"
],
"betterSnippets.customSnippets": [
{
"name": "SyntaxKind",
Expand Down
17 changes: 15 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# TypeScript Essential Plugins

Feature-complete TypeScript plugin that improves every single builtin feature such as completions, definitions, references and so on, and also adds even new TypeScript killer features, so you can work with large codebases faster!
We make completions more informative. Definitions, references (and sometimes even completions) less noisy. And finally our main goal is to provide most customizable TypeScript experience for IDE features.

TOC:

- [Top Features](#top-features)
- [Minor Useful Features](#minor-useful-features)
- [Auto Imports](#auto-imports)
- [Rename Features](#rename-features)
- [Special Commands List](#special-commands-list)
- [Contributed Code Actions](#contributed-code-actions)
- [Even Even More](#even-even-more)

## Top Features

> Here React experience hits different!
> Note: With this plugin React experience hits different! (see below)
### Special Commands & Actions

Expand Down Expand Up @@ -364,4 +377,4 @@ const a = {

## Even Even More

Please look at extension settings, as this extension has much more features than described here!
Also please take a look at extension settings, as this extension has much more features than described here!
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"esbuild": "^0.16.16",
"fs-extra": "^10.1.0",
"got": "^12.5.3",
"got-cjs": "npm:got@^11.x",
"type-fest": "^2.13.1",
"typed-jsonfile": "^0.2.1",
"typescript": "^4.9.3",
Expand Down
123 changes: 115 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/apiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { sendCommand } from './sendCommand'
export default () => {
/** @unique */
const cacheableCommands: Set<(typeof passthroughExposedApiCommands)[number]> = new Set(['getNodePath', 'getSpanOfEnclosingComment', 'getNodeAtPosition'])
const operationsCache = new Map<string, { key: string; data }>()
const operationsCache = new Map<string, { key: string; data; time?: number }>()
const sharedRequest = async (type: TriggerCharacterCommand, { offset, relativeOffset = 0, document, position }: RequestOptions) => {
if (position && offset) throw new Error('Only position or offset parameter can be provided')
if (document && !offset && !position) throw new Error('When custom document is provided, offset or position must be provided')
Expand All @@ -18,10 +18,11 @@ export default () => {
const requestOffset = offset ?? document.offsetAt(position!)
const requestPos = position ?? document.positionAt(offset!)
const getData = async () => sendCommand(type, { document: document!, position: requestPos })
const CACHE_UNDEFINED_TIMEOUT = 1000
if (cacheableCommands.has(type as any)) {
const cacheEntry = operationsCache.get(type)
const operationKey = `${document.uri.toString()}:${document.version}:${requestOffset}`
if (cacheEntry?.key === operationKey) {
if (cacheEntry?.key === operationKey && cacheEntry?.time && Date.now() - cacheEntry.time < CACHE_UNDEFINED_TIMEOUT) {
return cacheEntry.data
}

Expand All @@ -31,9 +32,9 @@ export default () => {
// at the same time:
// extension 2 completion provider requests API data at the same document and position
// and so on
operationsCache.set(type, { key: operationKey, data })
operationsCache.set(type, { key: operationKey, data, time: data === undefined ? Date.now() : undefined })
if (type === 'getNodePath') {
operationsCache.set('getNodeAtPosition', { key: operationKey, data: data.then((path: any) => path[path.length - 1]) })
operationsCache.set('getNodeAtPosition', { key: operationKey, data: data.then((path: any) => path?.[path.length - 1]) })
}

return data
Expand Down
Loading

0 comments on commit 20e2856

Please sign in to comment.