001    package org.meta_environment.eclipse.builder;
002    
003    import org.eclipse.core.resources.IFile;
004    import org.eclipse.core.runtime.CoreException;
005    import org.eclipse.core.runtime.IProgressMonitor;
006    import org.eclipse.imp.language.ILanguageService;
007    import org.eclipse.imp.utils.StreamUtils;
008    
009    import toolbus.adapter.eclipse.EclipseTool;
010    
011    public class BuilderTool extends EclipseTool implements ILanguageService {
012            private static final String TOOL_NAME = "builder";
013    
014            public BuilderTool() {
015                    super(TOOL_NAME);
016            }
017    
018            public void compile(IFile file, IProgressMonitor monitor) {
019                    try {
020                            String contents = StreamUtils.readStreamContents(file.getContents());
021                            sendEvent(factory.make("compile(<str>,<str>)", file.getFullPath().toOSString(), contents));
022                    } catch (CoreException e) {
023                            e.printStackTrace();
024                    }
025            }
026    
027            public void collectDependencies(IFile file) {
028                    try {
029                            String contents = StreamUtils.readStreamContents(file.getContents());
030                            sendEvent(factory.make("dependencies(<str>,<str>)", file.getFullPath().toOSString(), contents));
031                    } catch (CoreException e) {
032                            e.printStackTrace();
033                    }
034            }
035    }