66
77import 'vs/css!./media/standalone-tokens' ;
88import * as editorCommon from 'vs/editor/common/editorCommon' ;
9- /* tslint:disable:duplicate-imports */
10- import { IModel } from 'vs/editor/common/editorCommon' ;
11- /* tslint:disable:duplicate-imports */
129import { ContentWidgetPositionPreference , OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser' ;
1310import { StandaloneEditor , IStandaloneCodeEditor , StandaloneDiffEditor , IStandaloneDiffEditor , IEditorConstructionOptions , IDiffEditorConstructionOptions } from 'vs/editor/browser/standalone/standaloneCodeEditor' ;
1411import { ScrollbarVisibility } from 'vs/base/common/scrollable' ;
@@ -33,9 +30,9 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
3330import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService' ;
3431import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService' ;
3532import { ITextModelResolverService } from 'vs/editor/common/services/resolverService' ;
36- import { IState , ITokenizationSupport , TokenizationRegistry } from 'vs/editor/common/modes' ;
3733import { NULL_STATE , nullTokenize } from 'vs/editor/common/modes/nullMode' ;
3834import { IStandaloneColorService } from 'vs/editor/common/services/standaloneColorService' ;
35+ import { Token } from 'vs/editor/common/core/token' ;
3936
4037/**
4138 * @internal
@@ -136,15 +133,15 @@ export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: ID
136133 return new DiffNavigator ( diffEditor , opts ) ;
137134}
138135
139- function doCreateModel ( value : string , mode : TPromise < modes . IMode > , uri ?: URI ) : IModel {
136+ function doCreateModel ( value : string , mode : TPromise < modes . IMode > , uri ?: URI ) : editorCommon . IModel {
140137 return StaticServices . modelService . get ( ) . createModel ( value , mode , uri ) ;
141138}
142139
143140/**
144141 * Create a new editor model.
145142 * You can specify the language that should be set for this model or let the language be inferred from the `uri`.
146143 */
147- export function createModel ( value : string , language ?: string , uri ?: URI ) : IModel {
144+ export function createModel ( value : string , language ?: string , uri ?: URI ) : editorCommon . IModel {
148145 value = value || '' ;
149146
150147 if ( ! language ) {
@@ -164,14 +161,14 @@ export function createModel(value: string, language?: string, uri?: URI): IModel
164161/**
165162 * Change the language for a model.
166163 */
167- export function setModelLanguage ( model : IModel , language : string ) : void {
164+ export function setModelLanguage ( model : editorCommon . IModel , language : string ) : void {
168165 StaticServices . modelService . get ( ) . setMode ( model , StaticServices . modeService . get ( ) . getOrCreateMode ( language ) ) ;
169166}
170167
171168/**
172169 * Set the markers for a model.
173170 */
174- export function setModelMarkers ( model : IModel , owner : string , markers : IMarkerData [ ] ) : void {
171+ export function setModelMarkers ( model : editorCommon . IModel , owner : string , markers : IMarkerData [ ] ) : void {
175172 if ( model ) {
176173 StaticServices . markerService . get ( ) . changeOne ( owner , model . uri , markers ) ;
177174 }
@@ -180,38 +177,38 @@ export function setModelMarkers(model: IModel, owner: string, markers: IMarkerDa
180177/**
181178 * Get the model that has `uri` if it exists.
182179 */
183- export function getModel ( uri : URI ) : IModel {
180+ export function getModel ( uri : URI ) : editorCommon . IModel {
184181 return StaticServices . modelService . get ( ) . getModel ( uri ) ;
185182}
186183
187184/**
188185 * Get all the created models.
189186 */
190- export function getModels ( ) : IModel [ ] {
187+ export function getModels ( ) : editorCommon . IModel [ ] {
191188 return StaticServices . modelService . get ( ) . getModels ( ) ;
192189}
193190
194191/**
195192 * Emitted when a model is created.
196193 * @event
197194 */
198- export function onDidCreateModel ( listener : ( model : IModel ) => void ) : IDisposable {
195+ export function onDidCreateModel ( listener : ( model : editorCommon . IModel ) => void ) : IDisposable {
199196 return StaticServices . modelService . get ( ) . onModelAdded ( listener ) ;
200197}
201198
202199/**
203200 * Emitted right before a model is disposed.
204201 * @event
205202 */
206- export function onWillDisposeModel ( listener : ( model : IModel ) => void ) : IDisposable {
203+ export function onWillDisposeModel ( listener : ( model : editorCommon . IModel ) => void ) : IDisposable {
207204 return StaticServices . modelService . get ( ) . onModelRemoved ( listener ) ;
208205}
209206
210207/**
211208 * Emitted when a different language is set to a model.
212209 * @event
213210 */
214- export function onDidChangeModelLanguage ( listener : ( e : { readonly model : IModel ; readonly oldLanguage : string ; } ) => void ) : IDisposable {
211+ export function onDidChangeModelLanguage ( listener : ( e : { readonly model : editorCommon . IModel ; readonly oldLanguage : string ; } ) => void ) : IDisposable {
215212 return StaticServices . modelService . get ( ) . onModelModeChanged ( ( e ) => {
216213 listener ( {
217214 model : e . model ,
@@ -255,31 +252,21 @@ export function colorize(text: string, languageId: string, options: IColorizerOp
255252/**
256253 * Colorize a line in a model.
257254 */
258- export function colorizeModelLine ( model : IModel , lineNumber : number , tabSize : number = 4 ) : string {
255+ export function colorizeModelLine ( model : editorCommon . IModel , lineNumber : number , tabSize : number = 4 ) : string {
259256 return Colorizer . colorizeModelLine ( model , lineNumber , tabSize ) ;
260257}
261258
262- export class Token {
263- public readonly offset : number ;
264- public readonly type : string ;
265-
266- constructor ( offset : number , type : string ) {
267- this . offset = offset ;
268- this . type = type ;
269- }
270- }
271-
272259/**
273260 * @internal
274261 */
275- function getSafeTokenizationSupport ( languageId : string ) : ITokenizationSupport {
276- let tokenizationSupport = TokenizationRegistry . get ( languageId ) ;
262+ function getSafeTokenizationSupport ( languageId : string ) : modes . ITokenizationSupport {
263+ let tokenizationSupport = modes . TokenizationRegistry . get ( languageId ) ;
277264 if ( tokenizationSupport ) {
278265 return tokenizationSupport ;
279266 }
280267 return {
281268 getInitialState : ( ) => NULL_STATE ,
282- tokenize : ( line : string , state : IState , deltaOffset : number ) => nullTokenize ( languageId , line , state , deltaOffset ) ,
269+ tokenize : ( line : string , state : modes . IState , deltaOffset : number ) => nullTokenize ( languageId , line , state , deltaOffset ) ,
283270 tokenize3 : undefined ,
284271 } ;
285272}
@@ -300,7 +287,7 @@ export function tokenize(text: string, languageId: string): Token[][] {
300287 let line = lines [ i ] ;
301288 let tokenizationResult = tokenizationSupport . tokenize ( line , state , 0 ) ;
302289
303- result [ i ] = tokenizationResult . tokens . map ( ( t ) => new Token ( t . startIndex , t . type ) ) ;
290+ result [ i ] = tokenizationResult . tokens ;
304291 state = tokenizationResult . endState ;
305292 }
306293 return result ;
@@ -358,7 +345,6 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
358345 BareFontInfo : < any > editorCommon . BareFontInfo ,
359346 FontInfo : < any > editorCommon . FontInfo ,
360347 TextModelResolvedOptions : < any > editorCommon . TextModelResolvedOptions ,
361- Token : Token ,
362348
363349 // vars
364350 EditorType : editorCommon . EditorType ,
0 commit comments