Search in sources :

Example 1 with OutputImpl

use of org.eclipse.xpand2.output.OutputImpl in project xtext-eclipse by eclipse.

the class IdeaPluginGenerator method generate.

@Override
public void generate(final Grammar grammar, final Xtend2ExecutionContext ctx) {
    this._xtextIDEAGeneratorExtensions.installOutlets(ctx, this.ideaProjectPath, this.encoding, this.getNaming().getLineDelimiter());
    String outlet_src_gen = this._xtextIDEAGeneratorExtensions.getSrcGenOutlet(ctx).getName();
    String _xifexpression = null;
    if (this.srcGenOnly) {
        _xifexpression = outlet_src_gen;
    } else {
        _xifexpression = this._xtextIDEAGeneratorExtensions.getSrcOutlet(ctx).getName();
    }
    String outlet_src = _xifexpression;
    final BindFactory bindFactory = new BindFactory();
    bindFactory.addTypeToType("org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider", this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar));
    bindFactory.addTypeToType("org.eclipse.xtext.parser.antlr.Lexer", this._ideaPluginClassNames.getPsiInternalLexerName(grammar));
    String _psiInternalLexerName = this._ideaPluginClassNames.getPsiInternalLexerName(grammar);
    String _plus = (((("binder.bind(org.eclipse.xtext.parser.antlr.Lexer.class)" + ".annotatedWith(com.google.inject.name.Names.named(") + "org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME") + ")).to(") + _psiInternalLexerName);
    String _plus_1 = (_plus + ".class)");
    bindFactory.addConfiguredBinding("RuntimeLexer", _plus_1);
    bindFactory.addTypeToType("com.intellij.lang.PsiParser", this._ideaPluginClassNames.getPsiParserName(grammar));
    bindFactory.addTypeToType("org.eclipse.xtext.idea.parser.TokenTypeProvider", this._ideaPluginClassNames.getTokenTypeProviderName(grammar));
    bindFactory.addTypeToType("com.intellij.lang.ParserDefinition", this._ideaPluginClassNames.getParserDefinitionName(grammar));
    bindFactory.addTypeToTypeSingleton("org.eclipse.xtext.idea.lang.IElementTypeProvider", this._ideaPluginClassNames.getElementTypeProviderName(grammar));
    bindFactory.addTypeToType("org.eclipse.xtext.idea.facet.AbstractFacetConfiguration", this._ideaPluginClassNames.getFacetConfiguration(grammar));
    String _facetTypeName = this._ideaPluginClassNames.getFacetTypeName(grammar);
    String _plus_2 = (_facetTypeName + ".TYPEID");
    bindFactory.addTypeToInstance("com.intellij.facet.FacetTypeId", _plus_2);
    boolean _doesUseXbase = XbaseGeneratorFragment.doesUseXbase(grammar);
    if (_doesUseXbase) {
        bindFactory.addTypeToType("org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider", "org.eclipse.xtext.idea.common.types.StubBasedTypeScopeProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.xbase.typesystem.internal.IFeatureScopeTracker.Provider", "org.eclipse.xtext.xbase.typesystem.internal.OptimizingFeatureScopeTrackerProvider");
        bindFactory.addConfiguredBinding("LanguageSpecificPsiModelAssociations", (("binder.bind(org.eclipse.xtext.psi.IPsiModelAssociations.class)." + "annotatedWith(org.eclipse.xtext.service.LanguageSpecific.class).") + "to(org.eclipse.xtext.idea.common.types.DerivedMemberAwarePsiModelAssociations.class)"));
        bindFactory.addTypeToType("org.eclipse.xtext.idea.highlighting.IHighlightingConfiguration", "org.eclipse.xtext.xbase.idea.highlighting.XbaseHighlightingConfiguration");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.formatting.BlockFactory", "org.eclipse.xtext.xbase.idea.formatting.XbaseBlockFactory");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.formatting.ChildAttributesProvider", "org.eclipse.xtext.xbase.idea.formatting.XbaseChildAttributesProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.ide.editor.bracketmatching.IBracePairProvider", "org.eclipse.xtext.xbase.idea.bracketmatching.XbaseBracePairProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.findusages.IReferenceSearcher", "org.eclipse.xtext.xbase.idea.findusages.JvmElementAwareReferenceSearcher");
        bindFactory.addTypeToType("org.eclipse.xtext.xbase.compiler.IGeneratorConfigProvider", "org.eclipse.xtext.xbase.idea.facet.XbaseGeneratorConfigProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.findusages.WordsScannerProvider", "org.eclipse.xtext.xbase.idea.findusages.XbaseWordsScanner.XbaseWordsScannerProvider");
    }
    final Set<Binding> bindings = bindFactory.getBindings();
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getStandaloneSetupIdea(grammar)), this.compileStandaloneSetup(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.getIdeaSetup(grammar)), this.compileIdeaSetup(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getIdeaModuleName(grammar)), this.compileIdeaModule(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.getCompletionContributor(grammar)), this.compileCompletionContributor(grammar));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("META-INF/services/");
    String _name = ISetup.class.getName();
    _builder.append(_name);
    ctx.writeFile(outlet_src_gen, _builder.toString(), this.compileServicesISetup(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAbstractCompletionContributor(grammar)), this.compileAbstractCompletionContributor(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getLanguageName(grammar)), this.compileLanguage(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.getFileTypeName(grammar)), this.compileFileType(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAbstractFileTypeName(grammar)), this.compileAbstractFileType(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFileTypeFactoryName(grammar)), this.compileFileTypeFactory(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFileImplName(grammar)), this.compileFileImpl(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getTokenTypeProviderName(grammar)), this.compileTokenTypeProvider(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getElementTypeProviderName(grammar)), this.compileElementTypeProvider(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getParserDefinitionName(grammar)), this.compileParserDefinition(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getSyntaxHighlighterFactoryName(grammar)), this.compileSyntaxHighlighterFactory(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getSemanticHighlightVisitorName(grammar)), this.compileSemanticHighlightVisitor(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAbstractIdeaModuleName(grammar)), this.compileGuiceModuleIdeaGenerated(grammar, bindings));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getExtensionFactoryName(grammar)), this.compileExtensionFactory(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getCodeBlockModificationListenerName(grammar)), this.compileCodeBlockModificationListener(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getPsiParserName(grammar)), this.compilePsiParser(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar)), this.compileAntlrTokenFileProvider(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getPomDeclarationSearcherName(grammar)), this.compilePomDeclarationSearcher(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFacetTypeName(grammar)), this.compileFacetType(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFacetConfiguration(grammar)), this.compileFacetConfiguration(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.baseColorSettingsPage(grammar)), this.compileBaseColorSettingsPage(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.colorSettingsPage(grammar)), this.compileColorSettingsPage(grammar));
    OutputImpl output = new OutputImpl();
    this.addOutlet(output, IdeaPluginGenerator.PLUGIN, false, this.ideaProjectPath);
    this.addOutlet(output, IdeaPluginGenerator.META_INF_PLUGIN, false, (this.ideaProjectPath + "/META-INF"));
    this.addOutlet(output, IdeaPluginGenerator.META_INF_PLUGIN_GEN, true, (this.ideaProjectPath + "/META-INF"));
    if (this.deployable) {
        this.writeFile(output, IdeaPluginGenerator.META_INF_PLUGIN, "plugin.xml", this.compilePluginXml(grammar));
        this.writeFile(output, IdeaPluginGenerator.META_INF_PLUGIN_GEN, "plugin_gen.xml", this.compilePluginGenXml(grammar));
    }
}
Also used : Binding(org.eclipse.xtext.generator.Binding) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BindFactory(org.eclipse.xtext.generator.BindFactory) OutputImpl(org.eclipse.xpand2.output.OutputImpl)

Example 2 with OutputImpl

use of org.eclipse.xpand2.output.OutputImpl in project applause by applause.

the class ApplauseDslProjectCreator method enhanceProject.

protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException {
    OutputImpl output = new OutputImpl();
    output.addOutlet(new Outlet(false, getEncoding(), null, true, project.getLocation().makeAbsolute().toOSString()));
    XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, null);
    execCtx.getResourceManager().setFileEncoding("ISO-8859-1");
    execCtx.registerMetaModel(new JavaBeansMetaModel());
    XpandFacade facade = XpandFacade.create(execCtx);
    facade.evaluate("org::applause::lang::ui::wizard::ApplauseDslNewProject::main", getProjectInfo());
    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
Also used : Outlet(org.eclipse.xpand2.output.Outlet) XpandExecutionContextImpl(org.eclipse.xpand2.XpandExecutionContextImpl) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel) OutputImpl(org.eclipse.xpand2.output.OutputImpl) XpandFacade(org.eclipse.xpand2.XpandFacade)

Example 3 with OutputImpl

use of org.eclipse.xpand2.output.OutputImpl in project applause by applause.

the class AbstractBuildStrategy method build.

public void build(IProgressMonitor monitor) throws CoreException {
    if (canBuildProject()) {
        final IFolder folder = getPlatformProject().getFolder(getGeneratedSourcesFolderName());
        // FIXME: maybe we should just create the folder if it's missing?!
        if (!folder.exists())
            return;
        List<EObject> objects = new ArrayList<EObject>();
        for (Delta d : context.getDeltas()) {
            if (d.getNew() != null) {
                for (IEObjectDescription desc : d.getNew().getExportedObjects()) {
                    EObject obj = context.getResourceSet().getEObject(desc.getEObjectURI(), true);
                    EcoreUtil2.resolveAll(context.getResourceSet());
                    objects.add(obj);
                }
            }
        }
        Iterable<Application> applicationObjects = Iterables.filter(objects, Application.class);
        if (!Iterables.isEmpty(applicationObjects)) {
            deletePreviouslyGeneratedFiles(monitor, folder);
        }
        for (Application app : applicationObjects) {
            OutputImpl output = new OutputImpl();
            Outlet outlet = createOutlet(folder);
            configureOutlet(outlet);
            output.addOutlet(outlet);
            // IFolder rootFolder = (IFolder) getPlatformProject().getAdapter(IFolder.class);
            // // IPath location = getPlatformProject().getFullPath();
            // // IFolder rootFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(location);
            // Outlet projectRootOutlet = createOutlet(rootFolder);
            // projectRootOutlet.setName("ROOT");
            // output.addOutlet(projectRootOutlet);
            generate(app, output);
            copyResources(app, getModelProject().getFolder("/Images"));
            getPlatformProject().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
            return;
        }
    }
}
Also used : Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Outlet(org.eclipse.xpand2.output.Outlet) Application(org.applause.lang.applauseDsl.Application) OutputImpl(org.eclipse.xpand2.output.OutputImpl) IFolder(org.eclipse.core.resources.IFolder) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

OutputImpl (org.eclipse.xpand2.output.OutputImpl)3 Outlet (org.eclipse.xpand2.output.Outlet)2 ArrayList (java.util.ArrayList)1 Application (org.applause.lang.applauseDsl.Application)1 IFolder (org.eclipse.core.resources.IFolder)1 EObject (org.eclipse.emf.ecore.EObject)1 XpandExecutionContextImpl (org.eclipse.xpand2.XpandExecutionContextImpl)1 XpandFacade (org.eclipse.xpand2.XpandFacade)1 JavaBeansMetaModel (org.eclipse.xtend.type.impl.java.JavaBeansMetaModel)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 BindFactory (org.eclipse.xtext.generator.BindFactory)1 Binding (org.eclipse.xtext.generator.Binding)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1