Skip to content

Commit 38912c0

Browse files
committed
Reduce standalone editor API breakage
1 parent 8c668e8 commit 38912c0

6 files changed

Lines changed: 25 additions & 30 deletions

File tree

build/monaco/monaco.d.ts.recipe

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ declare module monaco.languages {
7272

7373
#includeAll(vs/editor/browser/standalone/standaloneLanguages;modes.=>;editorCommon.=>editor.;IMarkerData=>editor.IMarkerData):
7474
#includeAll(vs/editor/common/modes/languageConfiguration):
75-
/**
76-
* An identifier for a registered language.
77-
*/
78-
export class LanguageIdentifier {
79-
public readonly language: string;
80-
public readonly id: number;
81-
82-
constructor(language: string, id: number);
83-
}
8475
#includeAll(vs/editor/common/modes;editorCommon.IRange=>IRange;editorCommon.IPosition=>IPosition;editorCommon.=>editor.):
8576
#include(vs/editor/common/services/modeService): ILanguageExtensionPoint
8677
#includeAll(vs/editor/common/modes/monarch/monarchTypes):

src/vs/editor/browser/standalone/standaloneLanguages.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,5 @@ export function createMonacoLanguagesAPI(): typeof monaco.languages {
645645
CompletionItemKind: CompletionItemKind,
646646
SymbolKind: modes.SymbolKind,
647647
IndentAction: IndentAction,
648-
649-
// classes
650-
LanguageIdentifier: modes.LanguageIdentifier
651648
};
652649
}

src/vs/editor/common/editorCommon.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,9 +1818,15 @@ export interface IReadOnlyModel extends ITextModel {
18181818

18191819
/**
18201820
* Get the language associated with this model.
1821+
* @internal
18211822
*/
18221823
getLanguageIdentifier(): LanguageIdentifier;
18231824

1825+
/**
1826+
* Get the language associated with this model.
1827+
*/
1828+
getModeId(): string;
1829+
18241830
/**
18251831
* Get the word under or besides `position`.
18261832
* @param position The position to look for a word.
@@ -1863,9 +1869,15 @@ export interface ITokenizedModel extends ITextModel {
18631869

18641870
/**
18651871
* Get the language associated with this model.
1872+
* @internal
18661873
*/
18671874
getLanguageIdentifier(): LanguageIdentifier;
18681875

1876+
/**
1877+
* Get the language associated with this model.
1878+
*/
1879+
getModeId(): string;
1880+
18691881
/**
18701882
* Set the current language mode associated with the model.
18711883
* @internal
@@ -2222,11 +2234,11 @@ export interface IModelLanguageChangedEvent {
22222234
/**
22232235
* Previous language
22242236
*/
2225-
readonly oldLanguageIdentifier: LanguageIdentifier;
2237+
readonly oldLanguage: string;
22262238
/**
22272239
* New language
22282240
*/
2229-
readonly newLanguageIdentifier: LanguageIdentifier;
2241+
readonly newLanguage: string;
22302242
}
22312243

22322244
/**

src/vs/editor/common/model/textModelWithTokens.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,19 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
190190
return this._languageIdentifier;
191191
}
192192

193+
public getModeId(): string {
194+
return this._languageIdentifier.language;
195+
}
196+
193197
public setMode(languageIdentifier: LanguageIdentifier): void {
194198
if (this._languageIdentifier.id === languageIdentifier.id) {
195199
// There's nothing to do
196200
return;
197201
}
198202

199203
let e: editorCommon.IModelLanguageChangedEvent = {
200-
oldLanguageIdentifier: this._languageIdentifier,
201-
newLanguageIdentifier: languageIdentifier
204+
oldLanguage: this._languageIdentifier.language,
205+
newLanguage: languageIdentifier.language
202206
};
203207

204208
this._languageIdentifier = languageIdentifier;

src/vs/editor/common/services/modelServiceImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ export class ModelServiceImpl implements IModelService {
479479
if (e.getType() === editorCommon.EventType.ModelLanguageChanged) {
480480
this._onModelModeChanged.fire({
481481
model: modelData.model,
482-
oldModeId: (<editorCommon.IModelLanguageChangedEvent>e.getData()).oldLanguageIdentifier.language
482+
oldModeId: (<editorCommon.IModelLanguageChangedEvent>e.getData()).oldLanguage
483483
});
484484
}
485485
}

src/vs/monaco.d.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ declare module monaco.editor {
20772077
/**
20782078
* Get the language associated with this model.
20792079
*/
2080-
getLanguageIdentifier(): languages.LanguageIdentifier;
2080+
getModeId(): string;
20812081
/**
20822082
* Get the word under or besides `position`.
20832083
* @param position The position to look for a word.
@@ -2101,7 +2101,7 @@ declare module monaco.editor {
21012101
/**
21022102
* Get the language associated with this model.
21032103
*/
2104-
getLanguageIdentifier(): languages.LanguageIdentifier;
2104+
getModeId(): string;
21052105
/**
21062106
* Get the word under or besides `position`.
21072107
* @param position The position to look for a word.
@@ -2286,11 +2286,11 @@ declare module monaco.editor {
22862286
/**
22872287
* Previous language
22882288
*/
2289-
readonly oldLanguageIdentifier: languages.LanguageIdentifier;
2289+
readonly oldLanguage: string;
22902290
/**
22912291
* New language
22922292
*/
2293-
readonly newLanguageIdentifier: languages.LanguageIdentifier;
2293+
readonly newLanguage: string;
22942294
}
22952295

22962296
/**
@@ -4278,15 +4278,6 @@ declare module monaco.languages {
42784278
*/
42794279
removeText?: number;
42804280
}
4281-
/**
4282-
* An identifier for a registered language.
4283-
*/
4284-
export class LanguageIdentifier {
4285-
public readonly language: string;
4286-
public readonly id: number;
4287-
4288-
constructor(language: string, id: number);
4289-
}
42904281

42914282
/**
42924283
* The state of the tokenizer between two lines.

0 commit comments

Comments
 (0)