blob: 6ab16550bbb4a59be068a89e4cdbe89f2a0a02bd [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package org.eclipse.dltk.ruby.internal.parser;
import org.eclipse.dltk.compiler.SourceElementRequestVisitor;
import org.eclipse.dltk.compiler.task.ITaskReporter;
import org.eclipse.dltk.compiler.task.TodoTaskPreferences;
import org.eclipse.dltk.compiler.task.TodoTaskSimpleParser;
import org.eclipse.dltk.core.AbstractSourceElementParser;
import org.eclipse.dltk.core.ISourceModuleInfoCache.ISourceModuleInfo;
import org.eclipse.dltk.ruby.core.RubyNature;
import org.eclipse.dltk.ruby.core.RubyPlugin;
import org.eclipse.dltk.ruby.internal.parser.visitors.RubySourceElementRequestor;
public class RubySourceElementParser extends AbstractSourceElementParser {
/*
* @see org.eclipse.dltk.core.AbstractSourceElementParser#createVisitor()
*/
protected SourceElementRequestVisitor createVisitor() {
return new RubySourceElementRequestor(getRequestor());
}
/*
* @see org.eclipse.dltk.core.AbstractSourceElementParser#getNatureId()
*/
protected String getNatureId() {
return RubyNature.NATURE_ID;
}
public void parseSourceModule(char[] contents, ISourceModuleInfo astCache,
char[] filename) {
super.parseSourceModule(contents, astCache, filename);
if (getProblemReporter() != null) {
final ITaskReporter taskReporter = (ITaskReporter) getProblemReporter()
.getAdapter(ITaskReporter.class);
if (taskReporter != null) {
taskReporter.clearTasks();
parseTasks(taskReporter, contents);
}
}
}
protected void parseTasks(ITaskReporter taskReporter, char[] content) {
final TodoTaskPreferences preferences = new TodoTaskPreferences(
RubyPlugin.getDefault().getPluginPreferences());
if (preferences.isEnabled()) {
final TodoTaskSimpleParser taskParser = new TodoTaskSimpleParser(
taskReporter, preferences);
if (taskParser.isValid()) {
taskParser.parse(content);
}
}
}
}