提交 074bb34a 编写于 作者: A Alex Dima

Remove IMode.outlineSupport

上级 d37a76dc
......@@ -211,11 +211,6 @@ export interface IMode {
*/
declarationSupport?: IDeclarationSupport;
/**
* Optional adapter to support showing an outline.
*/
outlineSupport?:IOutlineSupport;
/**
* Optional adapter to support formatting.
*/
......@@ -550,7 +545,6 @@ export interface IOutlineEntry {
export interface IOutlineSupport {
getOutline(resource:URI):TPromise<IOutlineEntry[]>;
outlineGroupLabel?: { [name: string]: string; };
}
/**
......@@ -808,7 +802,7 @@ export const SignatureHelpProviderRegistry = new LanguageFeatureRegistry<Signatu
export const HoverProviderRegistry = new LanguageFeatureRegistry<HoverProvider>(null);
export const OutlineRegistry = new LanguageFeatureRegistry<IOutlineSupport>('outlineSupport');
export const OutlineRegistry = new LanguageFeatureRegistry<IOutlineSupport>(null);
export const OccurrencesRegistry = new LanguageFeatureRegistry<IOccurrencesSupport>('occurrencesSupport');
......
......@@ -12,9 +12,10 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import {TPromise} from 'vs/base/common/winjs.base';
import {Range} from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import {IOutlineEntry} from 'vs/editor/common/modes';
import {IOutlineEntry, OutlineRegistry} from 'vs/editor/common/modes';
import {ICodeEditor, IViewZone, IViewZoneChangeAccessor} from 'vs/editor/browser/editorBrowser';
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
import {getOutlineEntries, IOutline} from 'vs/editor/contrib/quickOpen/common/quickOpen';
class OutlineViewZone implements IViewZone {
......@@ -117,7 +118,7 @@ export class OutlineMarkerContribution implements editorCommon.IEditorContributi
private _globalToDispose:IDisposable[];
private _localToDispose:IDisposable[];
private _currentOutlinePromise:TPromise<IOutlineEntry[]>;
private _currentOutlinePromise:TPromise<IOutline>;
private _markers:OutlineMarker[];
......@@ -176,8 +177,7 @@ export class OutlineMarkerContribution implements editorCommon.IEditorContributi
return;
}
var mode = model.getMode();
if (!mode.outlineSupport) {
if (!OutlineRegistry.has(model)) {
return;
}
......@@ -186,10 +186,10 @@ export class OutlineMarkerContribution implements editorCommon.IEditorContributi
this._currentOutlinePromise.cancel();
}
this._currentOutlinePromise = mode.outlineSupport.getOutline(model.getAssociatedResource());
this._currentOutlinePromise = getOutlineEntries(model);
this._currentOutlinePromise.then((result) => {
this.renderOutlines(result);
this.renderOutlines(result.entries);
}, (error) => {
onUnexpectedError(error);
});
......
......@@ -17,8 +17,9 @@ import {IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel} from 'vs/base
import {IAutoFocus, Mode} from 'vs/base/parts/quickopen/common/quickOpen';
import {Behaviour} from 'vs/editor/common/editorActionEnablement';
import {ICommonCodeEditor, IEditorActionDescriptorData, IRange} from 'vs/editor/common/editorCommon';
import {IOutlineEntry} from 'vs/editor/common/modes';
import {IOutlineEntry, OutlineRegistry} from 'vs/editor/common/modes';
import {BaseEditorQuickOpenAction, IDecorator} from './editorQuickOpen';
import {getOutlineEntries, IOutline} from 'vs/editor/contrib/quickOpen/common/quickOpen';
let SCOPE_PREFIX = ':';
......@@ -130,28 +131,23 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
}
public isSupported(): boolean {
let mode = this.editor.getModel().getMode();
return !!mode && !!mode.outlineSupport && super.isSupported();
return (OutlineRegistry.has(this.editor.getModel()) && super.isSupported());
}
public run(): TPromise<boolean> {
let model = this.editor.getModel();
let mode = model.getMode();
let outlineSupport = mode.outlineSupport;
// Only works for models with outline support
if (!outlineSupport) {
if (!OutlineRegistry.has(model)) {
return null;
}
// Resolve outline
let promise = outlineSupport.getOutline(model.getAssociatedResource());
return promise.then((result: IOutlineEntry[]) => {
if (Array.isArray(result) && result.length > 0) {
let promise = getOutlineEntries(model);
return promise.then((result: IOutline) => {
if (result.entries.length > 0) {
// Cache result
this.cachedResult = result;
this.cachedResult = result.entries;
return super.run();
}
......
......@@ -16,24 +16,14 @@ import {IModelService} from 'vs/editor/common/services/modelService';
export interface IOutline {
entries: IOutlineEntry[];
outlineGroupLabel: { [n: string]: string; };
}
export function getOutlineEntries(model: IModel): TPromise<IOutline> {
let groupLabels: { [n: string]: string } = Object.create(null);
let entries: IOutlineEntry[] = [];
let promises = OutlineRegistry.all(model).map(support => {
if (support.outlineGroupLabel) {
let keys = Object.keys(support.outlineGroupLabel);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i];
groupLabels[key] = support.outlineGroupLabel[key];
}
}
return support.getOutline(model.getAssociatedResource()).then(result => {
if (Array.isArray(result)) {
entries.push(...result);
......@@ -50,7 +40,6 @@ export function getOutlineEntries(model: IModel): TPromise<IOutline> {
return {
entries: flatEntries,
outlineGroupLabel: groupLabels
};
});
}
......
......@@ -284,7 +284,6 @@ export class CSSMode extends AbstractMode {
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
public configSupport:Modes.IConfigurationSupport;
public occurrencesSupport:Modes.IOccurrencesSupport;
public outlineSupport: Modes.IOutlineSupport;
public declarationSupport: Modes.IDeclarationSupport;
public quickFixSupport: Modes.IQuickFixSupport;
......@@ -334,7 +333,7 @@ export class CSSMode extends AbstractMode {
//this.occurrencesSupport = this;
Modes.HoverProviderRegistry.register(this.getId(), this);
// Modes.ReferenceSearchRegistry.register(this.getId(), this);
this.outlineSupport = this;
Modes.OutlineRegistry.register(this.getId(), this);
// this.declarationSupport = new DeclarationSupport(this.getId(), {
// tokens: [cssTokenTypes.TOKEN_VALUE + '.css'],
// findDeclaration: (resource, position) => this.findDeclaration(resource, position)});
......
......@@ -9,7 +9,6 @@ import Modes = require('vs/editor/common/modes');
import URI from 'vs/base/common/uri';
import WinJS = require('vs/base/common/winjs.base');
import Platform = require('vs/platform/platform');
import nls = require('vs/nls');
import jsonWorker = require('vs/languages/json/common/jsonWorker');
import tokenization = require('vs/languages/json/common/features/tokenization');
import {AbstractMode, createWordRegExp, ModeWorkerManager} from 'vs/editor/common/modes/abstractMode';
......@@ -27,11 +26,8 @@ export class JSONMode extends AbstractMode implements Modes.HoverProvider, Modes
public richEditSupport: Modes.IRichEditSupport;
public configSupport:Modes.IConfigurationSupport;
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
public outlineSupport: Modes.IOutlineSupport;
public formattingSupport: Modes.IFormattingSupport;
public outlineGroupLabel : { [name: string]: string; };
private _modeWorkerManager: ModeWorkerManager<jsonWorker.JSONWorker>;
private _threadService:IThreadService;
......@@ -74,14 +70,7 @@ export class JSONMode extends AbstractMode implements Modes.HoverProvider, Modes
this.configSupport = this;
// Initialize Outline support
this.outlineSupport = this;
this.outlineGroupLabel = Object.create(null);
this.outlineGroupLabel['object'] = nls.localize('object', "objects");
this.outlineGroupLabel['array'] = nls.localize('array', "arrays");
this.outlineGroupLabel['string'] = nls.localize('string', "strings");
this.outlineGroupLabel['number'] = nls.localize('number', "numbers");
this.outlineGroupLabel['boolean'] = nls.localize('boolean', "booleans");
this.outlineGroupLabel['null'] = nls.localize('undefined', "undefined");
Modes.OutlineRegistry.register(this.getId(), this);
this.formattingSupport = this;
......
......@@ -183,7 +183,6 @@ export class LESSMode extends AbstractMode implements Modes.HoverProvider, Modes
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
public configSupport:Modes.IConfigurationSupport;
public declarationSupport: Modes.IDeclarationSupport;
public outlineSupport: Modes.IOutlineSupport;
public tokenizationSupport: Modes.ITokenizationSupport;
public richEditSupport: Modes.IRichEditSupport;
......@@ -214,7 +213,7 @@ export class LESSMode extends AbstractMode implements Modes.HoverProvider, Modes
this.declarationSupport = new DeclarationSupport(this.getId(), {
tokens: ['variable.less', lessTokenTypes.TOKEN_SELECTOR + '.class.less', lessTokenTypes.TOKEN_SELECTOR + '.id.less', 'selector.less'],
findDeclaration: (resource, position) => this.findDeclaration(resource, position)});
this.outlineSupport = this;
Modes.OutlineRegistry.register(this.getId(), this);
Modes.SuggestRegistry.register(this.getId(), {
triggerCharacters: [],
......
......@@ -284,7 +284,6 @@ export class SASSMode extends AbstractMode implements Modes.HoverProvider, Modes
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
public configSupport:Modes.IConfigurationSupport;
public outlineSupport: Modes.IOutlineSupport;
public declarationSupport: Modes.IDeclarationSupport;
public tokenizationSupport: Modes.ITokenizationSupport;
public richEditSupport: Modes.IRichEditSupport;
......@@ -315,7 +314,7 @@ export class SASSMode extends AbstractMode implements Modes.HoverProvider, Modes
this.declarationSupport = new DeclarationSupport(this.getId(), {
tokens: ['variable.decl.sass', 'variable.ref.sass', 'support.function.name.sass', sassTokenTypes.TOKEN_PROPERTY + '.sass', sassTokenTypes.TOKEN_SELECTOR + '.sass'],
findDeclaration: (resource, position) => this.findDeclaration(resource, position)});
this.outlineSupport = this;
Modes.OutlineRegistry.register(this.getId(), this);
Modes.SuggestRegistry.register(this.getId(), {
triggerCharacters: [],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册