|
From: <caw...@us...> - 2007-09-13 20:06:46
|
Revision: 3173
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3173&view=rev
Author: cawilliams
Date: 2007-09-13 13:06:43 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
get rid of SingleFileCompiler / MultipleFileCompiler stuff and use the Compilationparticipant extension point
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/plugin.xml
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
Modified: trunk/org.rubypeople.rdt.core/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.core/plugin.xml 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/plugin.xml 2007-09-13 20:06:43 UTC (rev 3173)
@@ -126,4 +126,19 @@
<error prefKey="org.rubypeople.rdt.core.compiler.problem.emptyStatement" label="Empty Statements"
categoryId="org.rubypeople.rdt.errors.unneccesaryCode"/>
</extension>
+ <extension
+ point="org.rubypeople.rdt.core.compilationParticipant">
+ <compilationParticipant
+ class="org.rubypeople.rdt.internal.core.builder.RubyCodeAnalyzer"
+ createsProblems="true"
+ id="org.rubypeople.rdt.core.compilationParticipant.CodeAnalyzer">
+ <managedMarker markerType="org.rubypeople.rdt.core.problem"/>
+ </compilationParticipant>
+ <compilationParticipant
+ class="org.rubypeople.rdt.internal.core.builder.TaskCompiler"
+ createsProblems="true"
+ id="org.rubypeople.rdt.core.compilationParticipant.TaskParser">
+ <managedMarker markerType="org.rubypeople.rdt.core.task"/>
+ </compilationParticipant>
+ </extension>
</plugin>
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,7 +1,6 @@
package org.rubypeople.rdt.internal.core.builder;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -14,82 +13,57 @@
import org.rubypeople.rdt.core.compiler.CategorizedProblem;
import org.rubypeople.rdt.core.compiler.CompilationParticipant;
import org.rubypeople.rdt.internal.core.RubyModelManager;
-import org.rubypeople.rdt.internal.core.util.ListUtil;
public abstract class AbstractRdtCompiler {
protected final IProject project;
protected final IMarkerManager markerManager;
- protected final List<SingleFileCompiler> singleFileCompilers;
- protected final List<MultipleFileCompiler> multiFileCompilers;
+ protected CompilationParticipant[] fParticipants;
- public AbstractRdtCompiler(IProject project,
- IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers, List<MultipleFileCompiler> multiFileCompilers) {
+ public AbstractRdtCompiler(IProject project, IMarkerManager markerManager) {
this.project = project;
this.markerManager = markerManager;
- this.singleFileCompilers = singleCompilers;
- this.multiFileCompilers = multiFileCompilers;
}
-
- public AbstractRdtCompiler(IProject project,
- IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers) {
- this(project, markerManager, singleCompilers, new ArrayList<MultipleFileCompiler>());
- }
protected abstract void removeMarkers(IMarkerManager markerManager);
- protected abstract List<IFile> getFilesToCompile();
- protected abstract void analyzeFiles() throws CoreException;
+ protected abstract List<IFile> getFilesToCompile() throws CoreException;
+ protected abstract List getFilesToClear() throws CoreException;
- protected static List<SingleFileCompiler> singleFileCompilers(MarkerManager markerManager) {
- return ListUtil.create(new RubyCodeAnalyzer(markerManager),
- new TaskCompiler(markerManager));
- }
-
- public void compile(IProgressMonitor monitor) throws CoreException {
- analyzeFiles();
+ public void compile(IProgressMonitor monitor) throws CoreException {
+ IRubyProject rubyProject = getRubyProject();
+ fParticipants = RubyModelManager.getRubyModelManager().compilationParticipants.getCompilationParticipants(rubyProject);
+ for (int i = 0; i < fParticipants.length; i++) {
+ fParticipants[i].aboutToBuild(rubyProject);
+ }
List<IFile> files = getFilesToCompile();
int filesToClear = getFilesToClear().size();
- int taskCount = (filesToClear) + (files.size() * (singleFileCompilers.size() + multiFileCompilers.size()));
+ int taskCount = (filesToClear) + (files.size() * fParticipants.length);
- monitor.beginTask("Building "+project.getName() + "...", taskCount);
- monitor.subTask("Removing Markers...");
+ monitor.beginTask("Building " + project.getName() + "...", taskCount);
+ monitor.subTask("Removing Markers...");
removeMarkers(markerManager);
monitor.worked(filesToClear);
+ monitor.subTask("Analyzing Files...");
compileFiles(files, monitor);
monitor.done();
- }
-
- protected abstract List getFilesToClear();
+ }
private void compileFiles(List<IFile> list, IProgressMonitor monitor) throws CoreException {
- for (MultipleFileCompiler compiler : multiFileCompilers) {
- if (monitor.isCanceled())
- return;
- compiler.compileFile(list, monitor);
- }
- for (IFile file : list) {
- if (monitor.isCanceled())
- return;
-
- monitor.subTask(file.getFullPath().toString());
- compileFile(file, monitor);
- }
- BuildContext[] contexts = getBuildContexts(list);
- CompilationParticipant[] participants = RubyModelManager.getRubyModelManager().compilationParticipants.getCompilationParticipants(getRubyProject());
- if (participants != null) {
- for (int i = 0; i < participants.length; i++) {
+ BuildContext[] contexts = getBuildContexts(list);
+ if (fParticipants != null) {
+ for (int i = 0; i < fParticipants.length; i++) {
if (monitor.isCanceled())
return;
- participants[i].buildStarting(contexts, true);
+ fParticipants[i].buildStarting(contexts, true);
}
}
for (int i = 0; i < contexts.length; i++) {
CategorizedProblem[] problems = contexts[i].getProblems();
if (problems == null || problems.length == 0) continue;
- for (int j = 0; j < problems.length; j++) {
+ for (int j = 0; j < problems.length; j++) {
markerManager.addProblem(contexts[i].getFile(), problems[j]);
}
}
@@ -106,12 +80,4 @@
private IRubyProject getRubyProject() {
return RubyCore.create(project);
}
-
- private void compileFile(IFile file, IProgressMonitor monitor) throws CoreException {
- for (Iterator<SingleFileCompiler> cIter = singleFileCompilers.iterator(); cIter.hasNext();) {
- SingleFileCompiler fileCompiler = cIter.next();
- fileCompiler.compileFile(file);
- monitor.worked(1);
- }
- }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -13,30 +13,28 @@
public CleanRdtCompiler(IProject project) {
this(project, new MarkerManager());
}
-
- public CleanRdtCompiler(IProject project,
- IMarkerManager markerManager, List singleCompilers) {
- super(project, markerManager, singleCompilers);
- }
-
+
private CleanRdtCompiler(IProject project,
MarkerManager markerManager) {
- this(project, markerManager, singleFileCompilers(markerManager));
+ super(project, markerManager);
}
protected void removeMarkers(IMarkerManager markerManager) {
markerManager.removeProblemsAndTasksFor(project);
}
- protected List<IFile> getFilesToClear() {
- return projectFiles;
+ protected List<IFile> getFilesToClear() throws CoreException {
+ return getFilesToCompile();
}
- protected List<IFile> getFilesToCompile() {
+ protected List<IFile> getFilesToCompile() throws CoreException {
+ if (projectFiles == null) {
+ analyzeFiles();
+ }
return projectFiles;
}
- protected void analyzeFiles() throws CoreException {
+ private void analyzeFiles() throws CoreException {
ProjectFileFinder finder = new ProjectFileFinder(project);
projectFiles = finder.findFiles();
}
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,53 +0,0 @@
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.parser.RdtPosition;
-import org.rubypeople.rdt.internal.core.parser.Warning;
-import org.rubypeople.rdt.internal.core.pmd.CPD;
-import org.rubypeople.rdt.internal.core.pmd.Match;
-import org.rubypeople.rdt.internal.core.pmd.TokenEntry;
-
-// XXX Either use this in some way, or remove it!
-public class CodeDuplicationDetector implements MultipleFileCompiler {
-
- private IMarkerManager markerManager;
-
- public CodeDuplicationDetector(IMarkerManager manager) {
- this.markerManager = manager;
- }
-
- public void compileFile(List<IFile> files, IProgressMonitor monitor) throws CoreException {
- monitor.subTask("Finding duplicate code...");
- try {
- Iterator<Match> matches = CPD.findMatches(files);
- while (matches.hasNext()) {
- Match match = matches.next();
- addMarker(match);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- monitor.worked(files.size());
- }
-
- private void addMarker(Match match) {
- StringBuffer message = new StringBuffer("Found a ");
- message.append(match.getLineCount()).append(" line (").append(match.getTokenCount()).append(" tokens) duplication");
- for (Iterator occurrences = match.iterator(); occurrences.hasNext();) {
- TokenEntry mark = (TokenEntry) occurrences.next();
- // FIXME Make TokenEntry hold an IFile pointer to source file?
- IFile file = RubyCore.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(mark.getTokenSrcID()));
- Warning warning = new Warning(new RdtPosition(mark.getBeginLine(), mark.getStartOffset(), mark.getStartOffset() + match.getSourceCodeSlice().length()), message.toString());
- markerManager.addProblem(file, warning);
- }
- }
-
-}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -19,8 +19,8 @@
private final IResourceDelta rootDelta;
public IncrementalRdtCompiler(IProject project, IResourceDelta delta,
- IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers) {
- super(project, markerManager, singleCompilers);
+ IMarkerManager markerManager) {
+ super(project, markerManager);
this.rootDelta = delta;
}
@@ -28,11 +28,6 @@
this(project, delta, new MarkerManager());
}
- private IncrementalRdtCompiler(IProject project, IResourceDelta delta,
- MarkerManager manager) {
- this(project, delta, manager, singleFileCompilers(manager));
- }
-
protected void removeMarkers(IMarkerManager markerManager) {
for (Iterator iter = filesToClear.iterator(); iter.hasNext();) {
IFile file = (IFile) iter.next();
@@ -40,11 +35,14 @@
}
}
- protected List getFilesToCompile() {
+ protected List getFilesToCompile() throws CoreException {
+ if (filesToCompile == null) {
+ analyzeFiles();
+ }
return filesToCompile;
}
- protected void analyzeFiles() throws CoreException {
+ private void analyzeFiles() throws CoreException {
filesToClear = new ArrayList();
filesToCompile = new ArrayList();
@@ -69,7 +67,10 @@
}
@Override
- protected List getFilesToClear() {
+ protected List getFilesToClear() throws CoreException {
+ if (filesToClear == null) {
+ analyzeFiles();
+ }
return filesToClear;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -36,7 +36,7 @@
}
public void addProblem(IFile file, IProblem problem) {
- MarkerUtility.createProblemMarker(file, problem);
+ MarkerUtility.createProblemMarker(file, problem);
}
}
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,16 +0,0 @@
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @deprecated Please use CompilationParticipant infrastructure
- * @author Chris Williams
- *
- */
-public interface MultipleFileCompiler {
- public void compileFile(List<IFile> file, IProgressMonitor monitor) throws CoreException;
-}
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,84 +0,0 @@
-/*
- * Author: David Corbin
- *
- * Copyright (c) 2005 RubyPeople.
- *
- * This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
- */
-
-
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.jruby.ast.Node;
-import org.jruby.ast.visitor.NodeVisitor;
-import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.parser.warnings.DelegatingVisitor;
-import org.rubypeople.rdt.core.parser.warnings.RubyLintVisitor;
-import org.rubypeople.rdt.internal.core.parser.Error;
-import org.rubypeople.rdt.internal.core.parser.ImmediateWarnings;
-import org.rubypeople.rdt.internal.core.parser.RubyParser;
-
-public final class RubyCodeAnalyzer implements SingleFileCompiler {
- private final IMarkerManager markerManager;
- private RubyParser parser;
-
- public RubyCodeAnalyzer(IMarkerManager markerManager) {
- this(markerManager, new RubyParser(new ImmediateWarnings(markerManager)));
- }
-
- public RubyCodeAnalyzer(IMarkerManager markerManager, RubyParser parser) {
- this.markerManager = markerManager;
- this.parser = parser;
- }
-
- public void compileFile(IFile file) throws CoreException {
- Reader reader = null;
- try {
- reader = new InputStreamReader(file.getContents(), file.getCharset());
- } catch (UnsupportedEncodingException e1) {
- RubyCore.log(e1);
- return;
- }
- String contents = readContents(reader);
- markerManager.removeProblemsAndTasksFor(file);
- try {
- Node rootNode = parser.parse(file, new StringReader(contents));
- if (rootNode == null) return;
- List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents); // FIXME How do we hook the warnings/errors up now?!
- NodeVisitor visitor = new DelegatingVisitor(visitors);
- rootNode.accept(visitor);
- } catch (SyntaxException e) {
- markerManager.addProblem(file, new Error(e.getPosition(), e.getMessage()));
- } finally {
- IoUtils.closeQuietly(reader);
- }
- }
-
- private String readContents(Reader reader) {
- try {
- int c = 0;
- StringBuffer str = new StringBuffer();
- while ((c = reader.read()) != -1) {
- str.append((char) c);
- }
- return str.toString();
- } catch (IOException e) {
- e.printStackTrace();
- return "";
- }
- }
-
-}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -0,0 +1,59 @@
+package org.rubypeople.rdt.internal.core.builder;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.jruby.ast.Node;
+import org.jruby.lexer.yacc.SyntaxException;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.compiler.BuildContext;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.CompilationParticipant;
+import org.rubypeople.rdt.core.compiler.IProblem;
+import org.rubypeople.rdt.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.core.parser.warnings.RubyLintVisitor;
+import org.rubypeople.rdt.internal.core.parser.Error;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+
+public class RubyCodeAnalyzer extends CompilationParticipant {
+
+ private RubyParser parser;
+
+ public RubyCodeAnalyzer() {
+ this.parser = new RubyParser();
+ }
+
+ @Override
+ public boolean isActive(IRubyProject project) {
+ return true;
+ }
+
+ @Override
+ public void buildStarting(BuildContext[] files, boolean isBatch) {
+ for (int i = 0; i < files.length; i++) {
+ BuildContext context = files[i];
+
+ IFile file = context.getFile();
+ String contents = new String(context.getContents());
+ Reader reader = new StringReader(contents);
+ try {
+ Node rootNode = parser.parse(file, reader);
+ if (rootNode == null)
+ return;
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents);
+ DelegatingVisitor visitor = new DelegatingVisitor(visitors);
+ rootNode.accept(visitor);
+
+ List<CategorizedProblem> problems = visitor.getProblems();
+ context.recordNewProblems(problems.toArray(new CategorizedProblem[problems.size()]));
+ } catch (SyntaxException e) {
+ context.recordNewProblems(new CategorizedProblem[] {new Error(e.getPosition(), e.getMessage(), IProblem.Syntax) });
+ } finally {
+ IoUtils.closeQuietly(reader);
+ }
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,25 +0,0 @@
-/*
-?* Author: David Corbin
-?*
-?* Copyright (c) 2005 RubyPeople.
-?*
-?* This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
-?*/
-
-
-package org.rubypeople.rdt.internal.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @deprecated Please use CompilationParticipant infrastructure
- * @author Chris Williams
- *
- */
-public interface SingleFileCompiler {
- public void compileFile(IFile file) throws CoreException;
-}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,51 +0,0 @@
-/*
-?* Author: David Corbin
-?*
-?* Copyright (c) 2005 RubyPeople.
-?*
-?* This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
-?*/
-
-
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.parser.TaskParser;
-
-public final class TaskCompiler implements SingleFileCompiler {
- private final TaskParser taskParser;
- private final IMarkerManager markerManager;
-
- public TaskCompiler(IMarkerManager markerManager) {
- this(markerManager, new TaskParser(RubyCore.getOptions()));
- }
-
- public TaskCompiler(IMarkerManager markerManager, TaskParser taskParser) {
- this.taskParser = taskParser;
- this.markerManager = markerManager;
- }
-
- public void compileFile(IFile file) throws CoreException {
- InputStream contents = null;
- try {
- contents = file.getContents();
- taskParser.clear();
- taskParser.parse(new InputStreamReader(contents));
- markerManager.createTasks(file, taskParser.getTasks());
- taskParser.clear();
- } catch (IOException e) {
- RubyCore.log(e);
- } finally {
- IoUtils.closeQuietly(contents);
- }
- }
-}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -0,0 +1,38 @@
+package org.rubypeople.rdt.internal.core.builder;
+
+import java.util.List;
+
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.compiler.BuildContext;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.CompilationParticipant;
+import org.rubypeople.rdt.internal.core.parser.TaskParser;
+import org.rubypeople.rdt.internal.core.parser.TaskTag;
+
+public class TaskCompiler extends CompilationParticipant {
+
+ private TaskParser taskParser;
+
+ @Override
+ public int aboutToBuild(IRubyProject project) {
+ taskParser = new TaskParser(project.getOptions(true));
+ return super.aboutToBuild(project);
+ }
+
+ @Override
+ public boolean isActive(IRubyProject project) {
+ return true;
+ }
+
+ @Override
+ public void buildStarting(BuildContext[] files, boolean isBatch) {
+ for (int i = 0; i < files.length; i++) {
+ BuildContext context = files[i];
+ taskParser.parse(new String(context.getContents()));
+ List<TaskTag> tasks = taskParser.getTasks();
+ context.recordNewProblems(tasks.toArray(new CategorizedProblem[tasks.size()]));
+ taskParser.clear();
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -69,6 +69,14 @@
}
public static void createProblemMarker(IResource underlyingResource, IProblem problem) {
+ if (problem.isTask()) {
+ try {
+ createTask(underlyingResource, (TaskTag) problem);
+ } catch (CoreException e) {
+ RubyCore.log(e);
+ }
+ return;
+ }
try {
IMarker marker = markerExists(underlyingResource, problem.getMessage(), problem.getSourceLineNumber(), IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER);
if (marker != null) return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|