mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-29 18:09:01 +01:00
Use inplaceReplaceSupport only in the modes that customize it
This commit is contained in:
@@ -10,7 +10,6 @@ import {TextualSuggestSupport} from 'vs/editor/common/modes/supports/suggestSupp
|
||||
import {AbstractModeWorker} from 'vs/editor/common/modes/abstractModeWorker';
|
||||
import Modes = require('vs/editor/common/modes');
|
||||
import EditorCommon = require('vs/editor/common/editorCommon');
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {IDisposable} from 'vs/base/common/lifecycle';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -35,7 +34,6 @@ export abstract class AbstractMode<W extends AbstractModeWorker> implements Mode
|
||||
|
||||
// adapters start
|
||||
public autoValidateDelay:number;
|
||||
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
|
||||
public configSupport:Modes.IConfigurationSupport;
|
||||
// adapters end
|
||||
|
||||
@@ -55,7 +53,6 @@ export abstract class AbstractMode<W extends AbstractModeWorker> implements Mode
|
||||
|
||||
this.autoValidateDelay = 500;
|
||||
|
||||
this.inplaceReplaceSupport = this;
|
||||
this.configSupport = this;
|
||||
|
||||
this._workerPiecePromise = null;
|
||||
@@ -142,11 +139,6 @@ export abstract class AbstractMode<W extends AbstractModeWorker> implements Mode
|
||||
};
|
||||
}
|
||||
|
||||
static $navigateValueSet = OneWorkerAttr(AbstractMode, AbstractMode.prototype.navigateValueSet);
|
||||
public navigateValueSet(resource:URI, position:EditorCommon.IRange, up:boolean):TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
return this._worker((w) => w.inplaceReplaceSupport.navigateValueSet(resource, position, up));
|
||||
}
|
||||
|
||||
public configure(options:any): TPromise<boolean> {
|
||||
this._options = options;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import {ValidationHelper} from 'vs/editor/common/worker/validationHelper';
|
||||
import EditorCommon = require('vs/editor/common/editorCommon');
|
||||
import Modes = require('vs/editor/common/modes');
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {WorkerInplaceReplaceSupport} from 'vs/editor/common/modes/supports/inplaceReplaceSupport';
|
||||
|
||||
export class AbstractModeWorker {
|
||||
|
||||
@@ -20,8 +19,6 @@ export class AbstractModeWorker {
|
||||
public resourceService:IResourceService;
|
||||
public markerService: IMarkerService;
|
||||
|
||||
public inplaceReplaceSupport: Modes.IInplaceReplaceSupport;
|
||||
|
||||
private _mode:Modes.IMode;
|
||||
|
||||
_validationHelper: ValidationHelper;
|
||||
@@ -40,12 +37,6 @@ export class AbstractModeWorker {
|
||||
(resource) => this._shouldIncludeModelInValidation(resource),
|
||||
500
|
||||
);
|
||||
|
||||
this.inplaceReplaceSupport = this._createInPlaceReplaceSupport();
|
||||
}
|
||||
|
||||
protected _createInPlaceReplaceSupport(): Modes.IInplaceReplaceSupport {
|
||||
return new WorkerInplaceReplaceSupport(this.resourceService);
|
||||
}
|
||||
|
||||
_getMode():Modes.IMode {
|
||||
|
||||
@@ -4,11 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IInplaceReplaceSupport, IInplaceReplaceSupportResult} from 'vs/editor/common/modes';
|
||||
import {IInplaceReplaceSupportResult} from 'vs/editor/common/modes';
|
||||
import {IRange} from 'vs/editor/common/editorCommon';
|
||||
import {IResourceService} from 'vs/editor/common/services/resourceService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
export class BasicInplaceReplace {
|
||||
|
||||
@@ -101,53 +98,3 @@ export class BasicInplaceReplace {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IInplaceReplaceSupportCustomization {
|
||||
navigateValueSetFallback?: (resource: URI, range: IRange, up: boolean) => TPromise<IInplaceReplaceSupportResult>;
|
||||
}
|
||||
|
||||
export class WorkerInplaceReplaceSupport implements IInplaceReplaceSupport {
|
||||
|
||||
private resourceService: IResourceService;
|
||||
private _customization:IInplaceReplaceSupportCustomization;
|
||||
|
||||
constructor(resourceService: IResourceService, customization: IInplaceReplaceSupportCustomization = null) {
|
||||
this._customization = customization;
|
||||
this.resourceService = resourceService;
|
||||
}
|
||||
|
||||
public navigateValueSet(resource:URI, range:IRange, up:boolean):TPromise<IInplaceReplaceSupportResult> {
|
||||
let result = this.doNavigateValueSet(resource, range, up);
|
||||
if (result && result.value && result.range) {
|
||||
return TPromise.as(result);
|
||||
}
|
||||
if (this._customization && typeof this._customization.navigateValueSetFallback === 'function') {
|
||||
return this._customization.navigateValueSetFallback(resource, range, up);
|
||||
}
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
private doNavigateValueSet(resource:URI, range:IRange, up:boolean): IInplaceReplaceSupportResult {
|
||||
let model = this.resourceService.get(resource);
|
||||
if (range.startColumn === range.endColumn) {
|
||||
range.endColumn += 1;
|
||||
}
|
||||
|
||||
let selectionText = model.getValueInRange(range);
|
||||
|
||||
let wordPos = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn });
|
||||
let word: string = null;
|
||||
let wordRange: IRange = null;
|
||||
if (wordPos && wordPos.startColumn !== -1) {
|
||||
word = wordPos.word;
|
||||
wordRange = {
|
||||
startLineNumber: range.startLineNumber,
|
||||
endLineNumber: range.endLineNumber,
|
||||
startColumn: wordPos.startColumn,
|
||||
endColumn: wordPos.endColumn
|
||||
};
|
||||
}
|
||||
|
||||
return BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,6 +284,7 @@ export class CSSMode extends AbstractMode<cssWorker.CSSWorker> {
|
||||
public tokenizationSupport: Modes.ITokenizationSupport;
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
|
||||
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
|
||||
public referenceSupport: Modes.IReferenceSupport;
|
||||
public logicalSelectionSupport: Modes.ILogicalSelectionSupport;
|
||||
public extraInfoSupport:Modes.IExtraInfoSupport;
|
||||
@@ -335,6 +336,7 @@ export class CSSMode extends AbstractMode<cssWorker.CSSWorker> {
|
||||
}
|
||||
});
|
||||
|
||||
this.inplaceReplaceSupport = this;
|
||||
this.occurrencesSupport = this;
|
||||
this.extraInfoSupport = this;
|
||||
this.referenceSupport = new ReferenceSupport(this.getId(), {
|
||||
@@ -359,6 +361,11 @@ export class CSSMode extends AbstractMode<cssWorker.CSSWorker> {
|
||||
return createAsyncDescriptor2('vs/languages/css/common/cssWorker', 'CSSWorker');
|
||||
}
|
||||
|
||||
static $navigateValueSet = OneWorkerAttr(CSSMode, CSSMode.prototype.navigateValueSet);
|
||||
public navigateValueSet(resource:URI, position:EditorCommon.IRange, up:boolean):WinJS.TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
return this._worker((w) => w.navigateValueSet(resource, position, up));
|
||||
}
|
||||
|
||||
static $findOccurrences = OneWorkerAttr(CSSMode, CSSMode.prototype.findOccurrences);
|
||||
public findOccurrences(resource:URI, position:EditorCommon.IPosition, strict:boolean = false): WinJS.TPromise<Modes.IOccurence[]> {
|
||||
return this._worker((w) => w.findOccurrences(resource, position, strict));
|
||||
|
||||
@@ -25,7 +25,6 @@ import lintRules = require('vs/languages/css/common/services/lintRules');
|
||||
import {IMarker, IMarkerData} from 'vs/platform/markers/common/markers';
|
||||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {IResourceService} from 'vs/editor/common/services/resourceService';
|
||||
import {WorkerInplaceReplaceSupport} from 'vs/editor/common/modes/supports/inplaceReplaceSupport';
|
||||
import {filterSuggestions} from 'vs/editor/common/modes/supports/suggestSupport';
|
||||
|
||||
export class CSSWorker extends AbstractModeWorker {
|
||||
@@ -44,67 +43,63 @@ export class CSSWorker extends AbstractModeWorker {
|
||||
this.validationEnabled = true;
|
||||
}
|
||||
|
||||
protected _createInPlaceReplaceSupport(): Modes.IInplaceReplaceSupport {
|
||||
return new WorkerInplaceReplaceSupport(this.resourceService, {
|
||||
navigateValueSetFallback: (resource:URI, range:EditorCommon.IRange, up:boolean):winjs.TPromise<Modes.IInplaceReplaceSupportResult> => {
|
||||
return this.languageService.join().then(() => {
|
||||
public navigateValueSet(resource:URI, range:EditorCommon.IRange, up:boolean):winjs.TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
return this.languageService.join().then(() => {
|
||||
|
||||
let model = this.resourceService.get(resource);
|
||||
let offset = model.getOffsetFromPosition({ lineNumber: range.startLineNumber, column: range.startColumn });
|
||||
let styleSheet = this.languageService.getStylesheet(resource);
|
||||
let model = this.resourceService.get(resource);
|
||||
let offset = model.getOffsetFromPosition({ lineNumber: range.startLineNumber, column: range.startColumn });
|
||||
let styleSheet = this.languageService.getStylesheet(resource);
|
||||
|
||||
let node = nodes.getNodeAtOffset(styleSheet, offset);
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
let declaration = nodes.getParentDeclaration(node);
|
||||
if (!declaration) {
|
||||
return;
|
||||
}
|
||||
let node = nodes.getNodeAtOffset(styleSheet, offset);
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
let declaration = nodes.getParentDeclaration(node);
|
||||
if (!declaration) {
|
||||
return;
|
||||
}
|
||||
|
||||
let entry: languageFacts.IEntry = languageFacts.getProperties()[declaration.getFullPropertyName()];
|
||||
if (!entry || !entry.values) {
|
||||
return;
|
||||
}
|
||||
let entry: languageFacts.IEntry = languageFacts.getProperties()[declaration.getFullPropertyName()];
|
||||
if (!entry || !entry.values) {
|
||||
return;
|
||||
}
|
||||
|
||||
let values = entry.values.filter(value => languageFacts.isCommonValue(value)).map(v => v.name);
|
||||
let values = entry.values.filter(value => languageFacts.isCommonValue(value)).map(v => v.name);
|
||||
|
||||
let isColor = (entry.restrictions.indexOf('color') >= 0);
|
||||
if (isColor) {
|
||||
values = values.concat(Object.getOwnPropertyNames(languageFacts.colors), Object.getOwnPropertyNames(languageFacts.colorKeywords));
|
||||
}
|
||||
let isColor = (entry.restrictions.indexOf('color') >= 0);
|
||||
if (isColor) {
|
||||
values = values.concat(Object.getOwnPropertyNames(languageFacts.colors), Object.getOwnPropertyNames(languageFacts.colorKeywords));
|
||||
}
|
||||
|
||||
let text = node.getText();
|
||||
for (let i = 0, len = values.length; i < len; i++) {
|
||||
if (strings.equalsIgnoreCase(values[i], text)) {
|
||||
let nextIdx = i;
|
||||
if(up) {
|
||||
nextIdx = (i + 1) % len;
|
||||
} else {
|
||||
nextIdx = i - 1;
|
||||
if(nextIdx < 0) {
|
||||
nextIdx = len - 1;
|
||||
}
|
||||
}
|
||||
let result:Modes.IInplaceReplaceSupportResult = {
|
||||
value: values[nextIdx],
|
||||
range: this._range(node, model)
|
||||
};
|
||||
return result;
|
||||
let text = node.getText();
|
||||
for (let i = 0, len = values.length; i < len; i++) {
|
||||
if (strings.equalsIgnoreCase(values[i], text)) {
|
||||
let nextIdx = i;
|
||||
if(up) {
|
||||
nextIdx = (i + 1) % len;
|
||||
} else {
|
||||
nextIdx = i - 1;
|
||||
if(nextIdx < 0) {
|
||||
nextIdx = len - 1;
|
||||
}
|
||||
}
|
||||
// if none matches, take the first one
|
||||
if (values.length > 0) {
|
||||
let result:Modes.IInplaceReplaceSupportResult = {
|
||||
value: values[0],
|
||||
range: this._range(node, model)
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
let result:Modes.IInplaceReplaceSupportResult = {
|
||||
value: values[nextIdx],
|
||||
range: this._range(node, model)
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// if none matches, take the first one
|
||||
if (values.length > 0) {
|
||||
let result:Modes.IInplaceReplaceSupportResult = {
|
||||
value: values[0],
|
||||
range: this._range(node, model)
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ suite('Validation - CSS', () => {
|
||||
var pos = env.model.getPositionFromOffset(value.indexOf(selection));
|
||||
var range = { startLineNumber: pos.lineNumber, startColumn: pos.column, endLineNumber: pos.lineNumber, endColumn: pos.column + selectionLength };
|
||||
|
||||
return env.worker.inplaceReplaceSupport.navigateValueSet(url, range, up);
|
||||
return env.worker.navigateValueSet(url, range, up);
|
||||
};
|
||||
|
||||
var testOccurrences = function (value: string, tokenBefore: string): WinJS.TPromise<{ occurrences: Modes.IOccurence[]; model: mm.MirrorModel; }> {
|
||||
|
||||
@@ -26,6 +26,7 @@ export class JSONMode extends AbstractMode<jsonWorker.JSONWorker> implements Mod
|
||||
public tokenizationSupport: Modes.ITokenizationSupport;
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
|
||||
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
|
||||
public extraInfoSupport: Modes.IExtraInfoSupport;
|
||||
public outlineSupport: Modes.IOutlineSupport;
|
||||
public formattingSupport: Modes.IFormattingSupport;
|
||||
@@ -74,6 +75,7 @@ export class JSONMode extends AbstractMode<jsonWorker.JSONWorker> implements Mod
|
||||
});
|
||||
|
||||
this.extraInfoSupport = this;
|
||||
this.inplaceReplaceSupport = this;
|
||||
|
||||
// Initialize Outline support
|
||||
this.outlineSupport = this;
|
||||
@@ -130,6 +132,11 @@ export class JSONMode extends AbstractMode<jsonWorker.JSONWorker> implements Mod
|
||||
return this._worker((w) => w.setSchemaContributions(data));
|
||||
}
|
||||
|
||||
static $navigateValueSet = OneWorkerAttr(JSONMode, JSONMode.prototype.navigateValueSet);
|
||||
public navigateValueSet(resource:URI, position:EditorCommon.IRange, up:boolean):WinJS.TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
return this._worker((w) => w.navigateValueSet(resource, position, up));
|
||||
}
|
||||
|
||||
static $suggest = OneWorkerAttr(JSONMode, JSONMode.prototype.suggest);
|
||||
public suggest(resource:URI, position:EditorCommon.IPosition):WinJS.TPromise<Modes.ISuggestResult[]> {
|
||||
return this._worker((w) => w.suggest(resource, position));
|
||||
|
||||
@@ -30,7 +30,6 @@ import {ISchemaContributions} from 'vs/platform/jsonschemas/common/jsonContribut
|
||||
import {IResourceService} from 'vs/editor/common/services/resourceService';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {JSONLocation} from './parser/jsonLocation';
|
||||
import {WorkerInplaceReplaceSupport} from 'vs/editor/common/modes/supports/inplaceReplaceSupport';
|
||||
import {filterSuggestions} from 'vs/editor/common/modes/supports/suggestSupport';
|
||||
|
||||
export interface IOptionsSchema {
|
||||
@@ -101,64 +100,60 @@ export class JSONWorker extends AbstractModeWorker implements Modes.IExtraInfoSu
|
||||
this.jsonIntellisense = new JSONIntellisense.JSONIntellisense(this.schemaService, this.requestService, this.contributions);
|
||||
}
|
||||
|
||||
protected _createInPlaceReplaceSupport(): Modes.IInplaceReplaceSupport {
|
||||
return new WorkerInplaceReplaceSupport(this.resourceService, {
|
||||
navigateValueSetFallback: (resource:URI, range:EditorCommon.IRange, up:boolean):WinJS.TPromise<Modes.IInplaceReplaceSupportResult> => {
|
||||
var modelMirror = this.resourceService.get(resource);
|
||||
var offset = modelMirror.getOffsetFromPosition({ lineNumber: range.startLineNumber, column: range.startColumn });
|
||||
public navigateValueSet(resource:URI, range:EditorCommon.IRange, up:boolean):WinJS.TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
var modelMirror = this.resourceService.get(resource);
|
||||
var offset = modelMirror.getOffsetFromPosition({ lineNumber: range.startLineNumber, column: range.startColumn });
|
||||
|
||||
var parser = new Parser.JSONParser();
|
||||
var config = new Parser.JSONDocumentConfig();
|
||||
config.ignoreDanglingComma = true;
|
||||
var doc = parser.parse(modelMirror.getValue(), config);
|
||||
var node = doc.getNodeFromOffsetEndInclusive(offset);
|
||||
var parser = new Parser.JSONParser();
|
||||
var config = new Parser.JSONDocumentConfig();
|
||||
config.ignoreDanglingComma = true;
|
||||
var doc = parser.parse(modelMirror.getValue(), config);
|
||||
var node = doc.getNodeFromOffsetEndInclusive(offset);
|
||||
|
||||
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
|
||||
return this.schemaService.getSchemaForResource(resource.toString(), doc).then((schema) => {
|
||||
if (schema) {
|
||||
var proposals : Modes.ISuggestion[] = [];
|
||||
var proposed: any = {};
|
||||
var collector = {
|
||||
add: (suggestion: Modes.ISuggestion) => {
|
||||
if (!proposed[suggestion.label]) {
|
||||
proposed[suggestion.label] = true;
|
||||
proposals.push(suggestion);
|
||||
}
|
||||
},
|
||||
setAsIncomplete: () => { /* ignore */ },
|
||||
error: (message: string) => {
|
||||
errors.onUnexpectedError(message);
|
||||
}
|
||||
};
|
||||
if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
|
||||
return this.schemaService.getSchemaForResource(resource.toString(), doc).then((schema) => {
|
||||
if (schema) {
|
||||
var proposals : Modes.ISuggestion[] = [];
|
||||
var proposed: any = {};
|
||||
var collector = {
|
||||
add: (suggestion: Modes.ISuggestion) => {
|
||||
if (!proposed[suggestion.label]) {
|
||||
proposed[suggestion.label] = true;
|
||||
proposals.push(suggestion);
|
||||
}
|
||||
},
|
||||
setAsIncomplete: () => { /* ignore */ },
|
||||
error: (message: string) => {
|
||||
errors.onUnexpectedError(message);
|
||||
}
|
||||
};
|
||||
|
||||
this.jsonIntellisense.getValueSuggestions(resource, schema, doc, node.parent, node.start, collector);
|
||||
this.jsonIntellisense.getValueSuggestions(resource, schema, doc, node.parent, node.start, collector);
|
||||
|
||||
var range = modelMirror.getRangeFromOffsetAndLength(node.start, node.end - node.start);
|
||||
var text = modelMirror.getValueInRange(range);
|
||||
for (var i = 0, len = proposals.length; i < len; i++) {
|
||||
if (Strings.equalsIgnoreCase(proposals[i].label, text)) {
|
||||
var nextIdx = i;
|
||||
if (up) {
|
||||
nextIdx = (i + 1) % len;
|
||||
} else {
|
||||
nextIdx = i - 1;
|
||||
if (nextIdx < 0) {
|
||||
nextIdx = len - 1;
|
||||
}
|
||||
}
|
||||
return {
|
||||
value: proposals[nextIdx].label,
|
||||
range: range
|
||||
};
|
||||
var range = modelMirror.getRangeFromOffsetAndLength(node.start, node.end - node.start);
|
||||
var text = modelMirror.getValueInRange(range);
|
||||
for (var i = 0, len = proposals.length; i < len; i++) {
|
||||
if (Strings.equalsIgnoreCase(proposals[i].label, text)) {
|
||||
var nextIdx = i;
|
||||
if (up) {
|
||||
nextIdx = (i + 1) % len;
|
||||
} else {
|
||||
nextIdx = i - 1;
|
||||
if (nextIdx < 0) {
|
||||
nextIdx = len - 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return {
|
||||
value: proposals[nextIdx].label,
|
||||
range: range
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ suite('JSON - Worker', () => {
|
||||
var pos = env.model.getPositionFromOffset(value.indexOf(selection));
|
||||
var range = { startLineNumber: pos.lineNumber, startColumn: pos.column, endLineNumber: pos.lineNumber, endColumn: pos.column + selectionLength };
|
||||
|
||||
return env.worker.inplaceReplaceSupport.navigateValueSet(url, range, up);
|
||||
return env.worker.navigateValueSet(url, range, up);
|
||||
};
|
||||
|
||||
function getOutline(content: string):WinJS.TPromise<Modes.IOutlineEntry[]> {
|
||||
|
||||
@@ -179,6 +179,7 @@ export var language: Types.ILanguage = <Types.ILanguage> {
|
||||
|
||||
export class LESSMode extends Monarch.MonarchMode<lessWorker.LessWorker> implements Modes.IExtraInfoSupport, Modes.IOutlineSupport {
|
||||
|
||||
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
|
||||
public referenceSupport: Modes.IReferenceSupport;
|
||||
public logicalSelectionSupport: Modes.ILogicalSelectionSupport;
|
||||
public extraInfoSupport: Modes.IExtraInfoSupport;
|
||||
@@ -201,6 +202,7 @@ export class LESSMode extends Monarch.MonarchMode<lessWorker.LessWorker> impleme
|
||||
this.modeService = modeService;
|
||||
|
||||
this.extraInfoSupport = this;
|
||||
this.inplaceReplaceSupport = this;
|
||||
this.referenceSupport = new ReferenceSupport(this.getId(), {
|
||||
tokens: [lessTokenTypes.TOKEN_PROPERTY + '.less', lessTokenTypes.TOKEN_VALUE + '.less', 'variable.less', lessTokenTypes.TOKEN_SELECTOR + '.class.less', lessTokenTypes.TOKEN_SELECTOR + '.id.less', 'selector.less'],
|
||||
findReferences: (resource, position, /*unused*/includeDeclaration) => this.findReferences(resource, position)});
|
||||
@@ -229,6 +231,11 @@ export class LESSMode extends Monarch.MonarchMode<lessWorker.LessWorker> impleme
|
||||
});
|
||||
}
|
||||
|
||||
static $navigateValueSet = OneWorkerAttr(LESSMode, LESSMode.prototype.navigateValueSet);
|
||||
public navigateValueSet(resource:URI, position:EditorCommon.IRange, up:boolean):winjs.TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
return this._worker((w) => w.navigateValueSet(resource, position, up));
|
||||
}
|
||||
|
||||
static $findReferences = OneWorkerAttr(LESSMode, LESSMode.prototype.findReferences);
|
||||
public findReferences(resource:URI, position:EditorCommon.IPosition):winjs.TPromise<Modes.IReference[]> {
|
||||
return this._worker((w) => w.findReferences(resource, position));
|
||||
|
||||
@@ -281,6 +281,7 @@ export var language = <Types.ILanguage>{
|
||||
|
||||
export class SASSMode extends Monarch.MonarchMode<sassWorker.SassWorker> implements Modes.IExtraInfoSupport, Modes.IOutlineSupport {
|
||||
|
||||
public inplaceReplaceSupport:Modes.IInplaceReplaceSupport;
|
||||
public referenceSupport: Modes.IReferenceSupport;
|
||||
public logicalSelectionSupport: Modes.ILogicalSelectionSupport;
|
||||
public extraInfoSupport: Modes.IExtraInfoSupport;
|
||||
@@ -303,6 +304,7 @@ export class SASSMode extends Monarch.MonarchMode<sassWorker.SassWorker> impleme
|
||||
this.modeService = modeService;
|
||||
|
||||
this.extraInfoSupport = this;
|
||||
this.inplaceReplaceSupport = this;
|
||||
this.referenceSupport = new ReferenceSupport(this.getId(), {
|
||||
tokens: [sassTokenTypes.TOKEN_PROPERTY + '.sass', sassTokenTypes.TOKEN_VALUE + '.sass', 'variable.decl.sass', 'variable.ref.sass', 'support.function.name.sass', sassTokenTypes.TOKEN_PROPERTY + '.sass', sassTokenTypes.TOKEN_SELECTOR + '.sass'],
|
||||
findReferences: (resource, position, /*unused*/includeDeclaration) => this.findReferences(resource, position)});
|
||||
@@ -331,6 +333,11 @@ export class SASSMode extends Monarch.MonarchMode<sassWorker.SassWorker> impleme
|
||||
});
|
||||
}
|
||||
|
||||
static $navigateValueSet = OneWorkerAttr(SASSMode, SASSMode.prototype.navigateValueSet);
|
||||
public navigateValueSet(resource:URI, position:EditorCommon.IRange, up:boolean):winjs.TPromise<Modes.IInplaceReplaceSupportResult> {
|
||||
return this._worker((w) => w.navigateValueSet(resource, position, up));
|
||||
}
|
||||
|
||||
static $findReferences = OneWorkerAttr(SASSMode, SASSMode.prototype.findReferences);
|
||||
public findReferences(resource:URI, position:EditorCommon.IPosition):winjs.TPromise<Modes.IReference[]> {
|
||||
return this._worker((w) => w.findReferences(resource, position));
|
||||
|
||||
@@ -46,7 +46,7 @@ suite('SASS - Worker', () => {
|
||||
var pos = env.model.getPositionFromOffset(value.indexOf(selection));
|
||||
var range = { startLineNumber: pos.lineNumber, startColumn: pos.column, endLineNumber: pos.lineNumber, endColumn: pos.column + selectionLength };
|
||||
|
||||
return env.worker.inplaceReplaceSupport.navigateValueSet(url, range, up);
|
||||
return env.worker.navigateValueSet(url, range, up);
|
||||
};
|
||||
|
||||
var testOccurrences = function(value:string, tokenBefore:string):WinJS.TPromise<{ occurrences: Modes.IOccurence[]; model: mm.MirrorModel }> {
|
||||
|
||||
Reference in New Issue
Block a user