My favorites | Sign in
Project Home Downloads Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Copyright (c) 2012 Google Inc.
*
* All rights reserved. This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.xtext.filename.ui;

import static com.google.eclipse.xtext.filename.resource.MyDslContentHandler.MY_DSL_FILE_CONTENT_TYPE;
import static org.eclipse.emf.ecore.resource.ContentHandler.Registry.HIGH_PRIORITY;

import org.eclipse.emf.ecore.resource.ContentHandler;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.resource.IResourceServiceProvider;

import com.google.eclipse.xtext.filename.resource.MyDslContentHandler;
import com.google.inject.Provider;

/**
* Utility methods for configuration of Xtext's behavior.
*
* @author alruiz@google.com (Alex Ruiz)
*/
final class XtextSetup {

/**
* Configures Xtext to associate the file name "MyDsl" to a Xtext editor. By default, Xtext
* associates file extensions to a Xtext editor.
* @param injectorProvider provides the {@code Injector} used by the "MyDsl" editor.
*/
static void configureXtextToWorkWithFileNames(InjectorProvider injectorProvider) {
register(new MyDslContentHandler());
register(new ResourceFactoryDescriptor(injectorProvider));
register(new ResourceServiceProvider(injectorProvider));
}

private static void register(ContentHandler h) {
ContentHandler.Registry registry = ContentHandler.Registry.INSTANCE;
registry.put(HIGH_PRIORITY, h);
}

private static void register(Resource.Factory.Descriptor d) {
Resource.Factory.Registry registry = Resource.Factory.Registry.INSTANCE;
registry.getContentTypeToFactoryMap().put(MY_DSL_FILE_CONTENT_TYPE, d);
}

private static void register(Provider<IResourceServiceProvider> p) {
IResourceServiceProvider.Registry registry = IResourceServiceProvider.Registry.INSTANCE;
registry.getContentTypeToFactoryMap().put(MY_DSL_FILE_CONTENT_TYPE, p);
}

private XtextSetup() {}
}

Change log

ba3910eee250 by Alex Ruiz <alr...@google.com> on Jan 10, 2012   Diff
Formatting.
Go to: 
Project members, sign in to write a code review

Older revisions

46a03995f280 by Alex Ruiz <alr...@google.com> on Jan 7, 2012   Diff
Initial upload.
All revisions of this file

File info

Size: 2090 bytes, 55 lines
Powered by Google Project Hosting