Revert "Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d (#5949)" (#5983)

This reverts commit d15a3fcc98.
This commit is contained in:
Karl Burtram
2019-06-11 12:35:58 -07:00
committed by GitHub
parent 95a50b7892
commit 5a7562a37b
926 changed files with 11394 additions and 19540 deletions

View File

@@ -6,19 +6,18 @@
import { ITextModel } from 'vs/editor/common/model';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { CodeLensModel } from 'vs/editor/contrib/codelens/codelens';
import { ICodeLensData } from 'vs/editor/contrib/codelens/codelens';
import { LRUCache, values } from 'vs/base/common/map';
import { CodeLensProvider, CodeLensList, CodeLens } from 'vs/editor/common/modes';
import { ICodeLensSymbol, CodeLensProvider } from 'vs/editor/common/modes';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { Range } from 'vs/editor/common/core/range';
import { runWhenIdle } from 'vs/base/common/async';
export const ICodeLensCache = createDecorator<ICodeLensCache>('ICodeLensCache');
export interface ICodeLensCache {
_serviceBrand: any;
put(model: ITextModel, data: CodeLensModel): void;
get(model: ITextModel): CodeLensModel | undefined;
put(model: ITextModel, data: ICodeLensData[]): void;
get(model: ITextModel): ICodeLensData[] | undefined;
delete(model: ITextModel): void;
}
@@ -31,7 +30,7 @@ class CacheItem {
constructor(
readonly lineCount: number,
readonly data: CodeLensModel
readonly data: ICodeLensData[]
) { }
}
@@ -40,7 +39,7 @@ export class CodeLensCache implements ICodeLensCache {
_serviceBrand: any;
private readonly _fakeProvider = new class implements CodeLensProvider {
provideCodeLenses(): CodeLensList {
provideCodeLenses(): ICodeLensSymbol[] {
throw new Error('not supported');
}
};
@@ -49,12 +48,9 @@ export class CodeLensCache implements ICodeLensCache {
constructor(@IStorageService storageService: IStorageService) {
// remove old data
const oldkey = 'codelens/cache';
runWhenIdle(() => storageService.remove(oldkey, StorageScope.WORKSPACE));
const key = 'codelens/cache';
// restore lens data on start
const key = 'codelens/cache2';
const raw = storageService.get(key, StorageScope.WORKSPACE, '{}');
this._deserialize(raw);
@@ -65,12 +61,13 @@ export class CodeLensCache implements ICodeLensCache {
});
}
put(model: ITextModel, data: CodeLensModel): void {
const lensModel = new CodeLensModel();
lensModel.add({ lenses: data.lenses.map(v => v.symbol), dispose() { } }, this._fakeProvider);
const item = new CacheItem(model.getLineCount(), lensModel);
put(model: ITextModel, data: ICodeLensData[]): void {
const item = new CacheItem(model.getLineCount(), data.map(item => {
return {
symbol: item.symbol,
provider: this._fakeProvider
};
}));
this._cache.set(model.uri.toString(), item);
}
@@ -89,7 +86,7 @@ export class CodeLensCache implements ICodeLensCache {
const data: Record<string, ISerializedCacheData> = Object.create(null);
this._cache.forEach((value, key) => {
const lines = new Set<number>();
for (const d of value.data.lenses) {
for (const d of value.data) {
lines.add(d.symbol.range.startLineNumber);
}
data[key] = {
@@ -105,14 +102,14 @@ export class CodeLensCache implements ICodeLensCache {
const data: Record<string, ISerializedCacheData> = JSON.parse(raw);
for (const key in data) {
const element = data[key];
const lenses: CodeLens[] = [];
const symbols: ICodeLensData[] = [];
for (const line of element.lines) {
lenses.push({ range: new Range(line, 1, line, 11) });
symbols.push({
provider: this._fakeProvider,
symbol: { range: new Range(line, 1, line, 11) }
});
}
const model = new CodeLensModel();
model.add({ lenses, dispose() { } }, this._fakeProvider);
this._cache.set(key, new CacheItem(element.lineCount, model));
this._cache.set(key, new CacheItem(element.lineCount, symbols));
}
} catch {
// ignore...