Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Validation on Generated files
Validation on Generated files [message #1753516] Tue, 07 February 2017 06:58 Go to next message
Eclipse UserFriend
My DSL generates files of another DSL. At the moment these generated files of the otherDSL are not automatically validated after the generation.
(No warnings or errors in the problems view or package explorer). The file does have warnings and errors

I have the feeling i am misisng a simple flag i need to set to make this possible.
Re: Validation on Generated files [message #1753518 is a reply to message #1753516] Tue, 07 February 2017 06:59 Go to previous messageGo to next message
Eclipse UserFriend
this is not possible,

an builder in eclipse does not see changes it did itself.

workaround: introduce another builder that touches the files built by the xtext builder so that the xtext builder will be called a second type.
Re: Validation on Generated files [message #1753519 is a reply to message #1753518] Tue, 07 February 2017 07:02 Go to previous messageGo to next message
Eclipse UserFriend
package org.xtext.example.mydsl.ui;

import java.util.Map;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;

public class DummyBuilder extends IncrementalProjectBuilder {

    @Override
    protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
        IResourceDelta delta = getDelta(getProject());
        if (delta != null) {
            delta.accept(new IResourceDeltaVisitor() {
                
                @Override
                public boolean visit(IResourceDelta delta) throws CoreException {
                    if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {
                        if (delta.getResource() instanceof IFile) {
                            System.out.println(delta);
                            // TODO file extensiion check
                            if (delta.getResource().getFullPath().toString().contains("/src-gen")) {
                                delta.getResource().touch(null);
                            }
                        }
                    }
                    return true;
                }
            });
        }
        return null;
    }

}
mydsl.ui/plugin.xml
 <extension
       id="DummyBuilder" name="DummyBuilder"
       point="org.eclipse.core.resources.builders">
       


in .project of model project
    <builder >
        <run
           class="org.xtext.example.mydsl.ui.DummyBuilder">
        </run>
    </builder>
 </extension>

        <buildCommand>
            <name>org.xtext.example.mydsl.ui.DummyBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
Re: Validation on Generated files [message #1753527 is a reply to message #1753519] Tue, 07 February 2017 08:47 Go to previous message
Eclipse UserFriend
thanks for the response and the example code!
Previous Topic:Type Resolution within XBlockExpression
Next Topic:Troubles With Parsing Numbers
Goto Forum:
  


Current Time: Wed Jul 23 09:48:06 EDT 2025

Powered by FUDForum. Page generated in 0.05417 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top