Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validation on Generated files
Validation on Generated files [message #1753516] Tue, 07 February 2017 11:58 Go to next message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
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 11:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation on Generated files [message #1753519 is a reply to message #1753518] Tue, 07 February 2017 12:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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>


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation on Generated files [message #1753527 is a reply to message #1753519] Tue, 07 February 2017 13:47 Go to previous message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
thanks for the response and the example code!
Previous Topic:Type Resolution within XBlockExpression
Next Topic:Troubles With Parsing Numbers
Goto Forum:
  


Current Time: Tue Apr 23 13:50:54 GMT 2024

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

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

Back to the top