### Eclipse Workspace Patch 1.0 #P org.eclipse.dltk.tcl.core Index: src/org/eclipse/dltk/tcl/core/TclPlugin.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/tcl/plugins/org.eclipse.dltk.tcl.core/src/org/eclipse/dltk/tcl/core/TclPlugin.java,v retrieving revision 1.2 diff -u -r1.2 TclPlugin.java --- src/org/eclipse/dltk/tcl/core/TclPlugin.java 2 May 2007 15:07:46 -0000 1.2 +++ src/org/eclipse/dltk/tcl/core/TclPlugin.java 24 Apr 2008 11:24:47 -0000 @@ -10,6 +10,7 @@ package org.eclipse.dltk.tcl.core; import org.eclipse.core.runtime.Plugin; +import org.eclipse.dltk.compiler.task.TodoTaskPreferences; import org.osgi.framework.BundleContext; /** @@ -34,6 +35,7 @@ */ public void start(BundleContext context) throws Exception { super.start(context); + new TodoTaskPreferences(getPluginPreferences()).initializeDefaultValues(); } /** Index: src/org/eclipse/dltk/tcl/internal/parser/TclSourceElementParser.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/tcl/plugins/org.eclipse.dltk.tcl.core/src/org/eclipse/dltk/tcl/internal/parser/TclSourceElementParser.java,v retrieving revision 1.28 diff -u -r1.28 TclSourceElementParser.java --- src/org/eclipse/dltk/tcl/internal/parser/TclSourceElementParser.java 23 Apr 2008 23:36:38 -0000 1.28 +++ src/org/eclipse/dltk/tcl/internal/parser/TclSourceElementParser.java 24 Apr 2008 11:24:47 -0000 @@ -2,13 +2,16 @@ import org.eclipse.dltk.ast.declarations.ModuleDeclaration; 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.DLTKCore; import org.eclipse.dltk.core.IScriptProject; import org.eclipse.dltk.core.ISourceElementParserExtension; -import org.eclipse.dltk.core.SourceParserUtil; +import org.eclipse.dltk.core.ISourceModule; import org.eclipse.dltk.core.ISourceModuleInfoCache.ISourceModuleInfo; import org.eclipse.dltk.tcl.core.TclNature; +import org.eclipse.dltk.tcl.core.TclPlugin; import org.eclipse.dltk.tcl.core.TclParseUtil.CodeModel; public class TclSourceElementParser extends AbstractSourceElementParser @@ -20,36 +23,44 @@ * @see org.eclipse.dltk.core.AbstractSourceElementParser#createVisitor() */ protected SourceElementRequestVisitor createVisitor() { - return new TclSourceElementRequestVisitor(this.getRequestor(), this - .getProblemReporter()); + return new TclSourceElementRequestVisitor(getRequestor(), + getProblemReporter()); } public void parseSourceModule(char[] contents, ISourceModuleInfo astCache, char[] filename) { + final ModuleDeclaration declaration = parseSource(filename, contents); + TclSourceElementRequestVisitor requestor = (TclSourceElementRequestVisitor) createVisitor(); + if (getProblemReporter() != null && scriptProject != null) { + requestor.setCodeModel(new CodeModel(new String(contents))); + requestor.setScriptProject(this.scriptProject); + } + traverse(declaration, requestor); + parseTasks(contents); + } - ModuleDeclaration moduleDeclaration = SourceParserUtil - .getModuleDeclaration(filename, contents, getNatureId(), - getProblemReporter(), astCache); - // - + public void processModule(ISourceModule module, + ModuleDeclaration declaration, char[] content) { TclSourceElementRequestVisitor requestor = (TclSourceElementRequestVisitor) createVisitor(); - requestor.setScriptProject(null); - if (getProblemReporter() != null) { - if (this.scriptProject != null) { - boolean markersCleaned = getProblemReporter() - .isMarkersCleaned(); - if (markersCleaned) { - CodeModel model = new CodeModel(new String(contents)); - requestor.setCodeModel(model); - requestor.setScriptProject(this.scriptProject); - } - } + if (content != null && getProblemReporter() != null + && scriptProject != null) { + requestor.setCodeModel(new CodeModel(new String(content))); + requestor.setScriptProject(this.scriptProject); + } + traverse(declaration, requestor); + if (content != null) { + parseTasks(content); } - try { - moduleDeclaration.traverse(requestor); - } catch (Exception e) { - if (DLTKCore.DEBUG) { - e.printStackTrace(); + } + + protected void parseTasks(ITaskReporter taskReporter, char[] content) { + final TodoTaskPreferences preferences = new TodoTaskPreferences( + TclPlugin.getDefault().getPluginPreferences()); + if (preferences.isEnabled()) { + final TodoTaskSimpleParser taskParser = new TodoTaskSimpleParser( + taskReporter, preferences); + if (taskParser.isValid()) { + taskParser.parse(content); } } } #P org.eclipse.dltk.ui Index: src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java,v retrieving revision 1.6 diff -u -r1.6 AbstractConfigurationBlock.java --- src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java 12 Mar 2008 11:06:04 -0000 1.6 +++ src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java 24 Apr 2008 11:24:48 -0000 @@ -49,6 +49,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; @@ -327,6 +328,10 @@ private org.eclipse.dltk.internal.ui.dialogs.StatusInfo fStatus; private final PreferencePage fMainPage; + + protected Shell getShell() { + return fMainPage.getShell(); + } public AbstractConfigurationBlock(OverlayPreferenceStore store) { Assert.isNotNull(store); Index: src/org/eclipse/dltk/ui/preferences/PreferencesMessages.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferencesMessages.java,v retrieving revision 1.16 diff -u -r1.16 PreferencesMessages.java --- src/org/eclipse/dltk/ui/preferences/PreferencesMessages.java 12 Mar 2008 11:06:04 -0000 1.16 +++ src/org/eclipse/dltk/ui/preferences/PreferencesMessages.java 24 Apr 2008 11:24:48 -0000 @@ -229,31 +229,31 @@ // public static String CodeFormatterPreferencePage_description; // public static String TodoTaskPreferencePage_title; // public static String TodoTaskPreferencePage_description; -// public static String TodoTaskConfigurationBlock_markers_tasks_high_priority; -// public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority; -// public static String TodoTaskConfigurationBlock_markers_tasks_low_priority; -// public static String TodoTaskConfigurationBlock_markers_tasks_add_button; -// public static String TodoTaskConfigurationBlock_markers_tasks_remove_button; -// public static String TodoTaskConfigurationBlock_markers_tasks_edit_button; -// public static String TodoTaskConfigurationBlock_markers_tasks_name_column; -// public static String TodoTaskConfigurationBlock_markers_tasks_priority_column; + public static String TodoTaskConfigurationBlock_markers_tasks_high_priority; + public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority; + public static String TodoTaskConfigurationBlock_markers_tasks_low_priority; + public static String TodoTaskConfigurationBlock_markers_tasks_add_button; + public static String TodoTaskConfigurationBlock_markers_tasks_remove_button; + public static String TodoTaskConfigurationBlock_markers_tasks_edit_button; + public static String TodoTaskConfigurationBlock_markers_tasks_name_column; + public static String TodoTaskConfigurationBlock_markers_tasks_priority_column; // public static String TodoTaskConfigurationBlock_markers_tasks_setdefault_button; -// public static String TodoTaskConfigurationBlock_casesensitive_label; + public static String TodoTaskConfigurationBlock_casesensitive_label; // public static String TodoTaskConfigurationBlock_needsbuild_title; // public static String TodoTaskConfigurationBlock_tasks_default; // public static String TodoTaskConfigurationBlock_needsfullbuild_message; // public static String TodoTaskConfigurationBlock_needsprojectbuild_message; -// public static String TodoTaskInputDialog_new_title; -// public static String TodoTaskInputDialog_edit_title; -// public static String TodoTaskInputDialog_name_label; -// public static String TodoTaskInputDialog_priority_label; -// public static String TodoTaskInputDialog_priority_high; -// public static String TodoTaskInputDialog_priority_normal; -// public static String TodoTaskInputDialog_priority_low; -// public static String TodoTaskInputDialog_error_enterName; -// public static String TodoTaskInputDialog_error_comma; -// public static String TodoTaskInputDialog_error_entryExists; -// public static String TodoTaskInputDialog_error_noSpace; + public static String TodoTaskInputDialog_new_title; + public static String TodoTaskInputDialog_edit_title; + public static String TodoTaskInputDialog_name_label; + public static String TodoTaskInputDialog_priority_label; + public static String TodoTaskInputDialog_priority_high; + public static String TodoTaskInputDialog_priority_normal; + public static String TodoTaskInputDialog_priority_low; + public static String TodoTaskInputDialog_error_enterName; + public static String TodoTaskInputDialog_error_comma; + public static String TodoTaskInputDialog_error_entryExists; + public static String TodoTaskInputDialog_error_noSpace; public static String PropertyAndPreferencePage_useworkspacesettings_change; public static String PropertyAndPreferencePage_showprojectspecificsettings_label; Index: src/org/eclipse/dltk/ui/preferences/PreferencesMessages.properties =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferencesMessages.properties,v retrieving revision 1.18 diff -u -r1.18 PreferencesMessages.properties --- src/org/eclipse/dltk/ui/preferences/PreferencesMessages.properties 28 Mar 2008 21:16:15 -0000 1.18 +++ src/org/eclipse/dltk/ui/preferences/PreferencesMessages.properties 24 Apr 2008 11:24:48 -0000 @@ -274,3 +274,29 @@ AbstractConfigurationBlock_fileDoesntExist=File doesn't exist AbstractConfigurationBlock_pathIsntAFile=Path isn't a file AbstractConfigurationBlock_valuesItemsAndLabelMustNotBeNull=values == null || items == null || label == null + +TodoTaskConfigurationBlock_markers_tasks_high_priority=High +TodoTaskConfigurationBlock_markers_tasks_normal_priority=Normal +TodoTaskConfigurationBlock_markers_tasks_low_priority=Low + +TodoTaskConfigurationBlock_markers_tasks_add_button=&New... +TodoTaskConfigurationBlock_markers_tasks_remove_button=&Remove +TodoTaskConfigurationBlock_markers_tasks_edit_button=&Edit... +#TodoTaskConfigurationBlock_markers_tasks_setdefault_button=Defa&ult + +TodoTaskConfigurationBlock_markers_tasks_name_column=Tag +TodoTaskConfigurationBlock_markers_tasks_priority_column=Priority + +TodoTaskConfigurationBlock_casesensitive_label=&Case sensitive task tag names + +TodoTaskInputDialog_new_title=New Task Tag +TodoTaskInputDialog_edit_title=Edit Task Tag +TodoTaskInputDialog_name_label=T&ag: +TodoTaskInputDialog_priority_label=&Priority: +TodoTaskInputDialog_priority_high=High +TodoTaskInputDialog_priority_normal=Normal +TodoTaskInputDialog_priority_low=Low +TodoTaskInputDialog_error_enterName=Enter task tag name. +TodoTaskInputDialog_error_comma=Name cannot contain a comma or semicolon. +TodoTaskInputDialog_error_entryExists=An entry with the same name already exists. +TodoTaskInputDialog_error_noSpace=Name cannot begin or end with a whitespace. Index: src/org/eclipse/dltk/ui/preferences/TodoTaskAbstractPreferencePage.java =================================================================== RCS file: src/org/eclipse/dltk/ui/preferences/TodoTaskAbstractPreferencePage.java diff -N src/org/eclipse/dltk/ui/preferences/TodoTaskAbstractPreferencePage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/dltk/ui/preferences/TodoTaskAbstractPreferencePage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.ui.preferences; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.dltk.ui.PreferencesAdapter; + +public abstract class TodoTaskAbstractPreferencePage extends + AbstractConfigurationBlockPreferencePage { + + protected abstract Preferences getPluginPreferences(); + + protected IPreferenceConfigurationBlock createConfigurationBlock( + OverlayPreferenceStore overlayPreferenceStore) { + return new TodoTaskConfigurationBlock(getPluginPreferences(), + overlayPreferenceStore, this); + } + + protected void setPreferenceStore() { + setPreferenceStore(new PreferencesAdapter(getPluginPreferences())); + } + +} Index: src/org/eclipse/dltk/ui/preferences/TodoTaskInputDialog.java =================================================================== RCS file: src/org/eclipse/dltk/ui/preferences/TodoTaskInputDialog.java diff -N src/org/eclipse/dltk/ui/preferences/TodoTaskInputDialog.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/dltk/ui/preferences/TodoTaskInputDialog.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 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 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.dltk.ui.preferences; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.dltk.compiler.task.TodoTask; +import org.eclipse.dltk.compiler.task.TodoTaskPreferences; +import org.eclipse.dltk.internal.ui.dialogs.StatusInfo; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.ComboDialogField; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.LayoutUtil; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.StringDialogField; +import org.eclipse.jface.dialogs.StatusDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * Dialog to enter a new task tag + */ +public class TodoTaskInputDialog extends StatusDialog { + + private class CompilerTodoTaskInputAdapter implements IDialogFieldListener { + public void dialogFieldChanged(DialogField field) { + doValidation(); + } + } + + private StringDialogField fNameDialogField; + private ComboDialogField fPriorityDialogField; + + private List fExistingNames; + + public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) { + super(parent); + + fExistingNames = new ArrayList(existingEntries.size()); + for (int i = 0; i < existingEntries.size(); i++) { + TodoTask curr = (TodoTask) existingEntries.get(i); + if (!curr.equals(task)) { + fExistingNames.add(curr.name); + } + } + + if (task == null) { + setTitle(PreferencesMessages.TodoTaskInputDialog_new_title); + } else { + setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title); + } + + CompilerTodoTaskInputAdapter adapter = new CompilerTodoTaskInputAdapter(); + + fNameDialogField = new StringDialogField(); + fNameDialogField + .setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label); + fNameDialogField.setDialogFieldListener(adapter); + + fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$ + + String[] items = new String[] { + PreferencesMessages.TodoTaskInputDialog_priority_high, + PreferencesMessages.TodoTaskInputDialog_priority_normal, + PreferencesMessages.TodoTaskInputDialog_priority_low }; + + fPriorityDialogField = new ComboDialogField(SWT.READ_ONLY); + fPriorityDialogField + .setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label); + fPriorityDialogField.setItems(items); + if (task != null) { + if (TodoTask.PRIORITY_HIGH.equals(task.priority)) { + fPriorityDialogField.selectItem(0); + } else if (TodoTask.PRIORITY_NORMAL.equals(task.priority)) { + fPriorityDialogField.selectItem(1); + } else { + fPriorityDialogField.selectItem(2); + } + } else { + fPriorityDialogField.selectItem(1); + } + } + + public TodoTask getResult() { + TodoTask task = new TodoTask(); + task.name = fNameDialogField.getText().trim(); + switch (fPriorityDialogField.getSelectionIndex()) { + case 0: + task.priority = TodoTask.PRIORITY_HIGH; + break; + case 1: + task.priority = TodoTask.PRIORITY_NORMAL; + break; + default: + task.priority = TodoTask.PRIORITY_LOW; + break; + } + return task; + } + + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + + Composite inner = new Composite(composite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; + inner.setLayout(layout); + + fNameDialogField.doFillIntoGrid(inner, 2); + fPriorityDialogField.doFillIntoGrid(inner, 2); + + LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null)); + LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), + convertWidthInCharsToPixels(45)); + + fNameDialogField.postSetFocusOnDialogField(parent.getDisplay()); + + applyDialogFont(composite); + + return composite; + } + + private void doValidation() { + StatusInfo status = new StatusInfo(); + String newText = fNameDialogField.getText(); + if (newText.length() == 0) { + status + .setError(PreferencesMessages.TodoTaskInputDialog_error_enterName); + } else { + if (!TodoTaskPreferences.isValidName(newText)) { + status + .setError(PreferencesMessages.TodoTaskInputDialog_error_comma); + } else if (fExistingNames.contains(newText)) { + status + .setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists); + } else if (Character.isWhitespace(newText.charAt(0)) + || Character.isWhitespace(newText + .charAt(newText.length() - 1))) { + status + .setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace); + } + } + updateStatus(status); + } + + /* + * @see org.eclipse.jface.window.Window#configureShell(Shell) + */ + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + } +} Index: src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java =================================================================== RCS file: src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java diff -N src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,254 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 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 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.dltk.ui.preferences; + +import java.util.List; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.dltk.compiler.task.TodoTask; +import org.eclipse.dltk.compiler.task.TodoTaskPreferences; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.IListAdapter; +import org.eclipse.dltk.internal.ui.wizards.dialogfields.ListDialogField; +import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore.OverlayKey; +import org.eclipse.dltk.ui.util.PixelConverter; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +public class TodoTaskConfigurationBlock extends AbstractConfigurationBlock { + + private class TodoTaskLabelProvider extends LabelProvider implements + ITableLabelProvider { + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + return getColumnText(element, 0); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, + * int) + */ + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, + * int) + */ + public String getColumnText(Object element, int columnIndex) { + final TodoTask task = (TodoTask) element; + if (columnIndex == 0) { + return task.name; + } else { + if (TodoTask.PRIORITY_HIGH.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; + } else if (TodoTask.PRIORITY_NORMAL.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; + } else if (TodoTask.PRIORITY_LOW.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; + } + return ""; //$NON-NLS-1$ + } + } + + } + + private static class TodoTaskSorter extends ViewerSorter { + public int compare(Viewer viewer, Object e1, Object e2) { + return getComparator().compare(((TodoTask) e1).name, + ((TodoTask) e2).name); + } + } + + private static final int IDX_ADD = 0; + private static final int IDX_EDIT = 1; + private static final int IDX_REMOVE = 2; + + private ListDialogField fTodoTasksList; + private Button fCaseSensitiveCheckbox; + + private final TodoTaskPreferences preferences; + + public TodoTaskConfigurationBlock(Preferences preferences, + OverlayPreferenceStore store, PreferencePage mainPreferencePage) { + super(store, mainPreferencePage); + this.preferences = new TodoTaskPreferences(preferences); + store.addKeys(createKeys()); + } + + private OverlayKey[] createKeys() { + return new OverlayPreferenceStore.OverlayKey[] { + new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, TodoTaskPreferences.TAGS), + new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + TodoTaskPreferences.ENABLED), + new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + TodoTaskPreferences.CASE_SENSITIVE) }; + } + + public class TaskTagAdapter implements IListAdapter, IDialogFieldListener { + + private boolean canEdit(List selectedElements) { + return selectedElements.size() == 1; + } + + public void customButtonPressed(ListDialogField field, int index) { + doTodoButtonPressed(index); + } + + public void selectionChanged(ListDialogField field) { + List selectedElements = field.getSelectedElements(); + field.enableButton(IDX_EDIT, canEdit(selectedElements)); + } + + public void doubleClicked(ListDialogField field) { + if (canEdit(field.getSelectedElements())) { + doTodoButtonPressed(IDX_EDIT); + } + } + + public void dialogFieldChanged(DialogField field) { + updateModel(field); + } + + } + + protected final void updateModel(DialogField field) { + preferences.setTaskTags(fTodoTasksList.getElements()); + } + + private void doTodoButtonPressed(int index) { + TodoTask edited = null; + if (index != IDX_ADD) { + edited = (TodoTask) fTodoTasksList.getSelectedElements().get(0); + } + if (index == IDX_ADD || index == IDX_EDIT) { + TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), + edited, fTodoTasksList.getElements()); + if (dialog.open() == Window.OK) { + if (edited != null) { + fTodoTasksList.replaceElement(edited, dialog.getResult()); + } else { + fTodoTasksList.addElement(dialog.getResult()); + } + } + } + } + + public Control createControl(Composite parent) { + final TaskTagAdapter adapter = new TaskTagAdapter(); + final String[] buttons = new String[] { + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button, + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button, + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button }; + fTodoTasksList = new ListDialogField(adapter, buttons, + new TodoTaskLabelProvider()); + fTodoTasksList.setDialogFieldListener(adapter); + fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE); + + final String[] columnsHeaders = new String[] { + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column, + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column, }; + fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription( + columnsHeaders, true)); + fTodoTasksList.setViewerSorter(new TodoTaskSorter()); + + final GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; + + final PixelConverter conv = new PixelConverter(parent); + + final Composite markersComposite = new Composite(parent, SWT.NULL); + markersComposite.setLayout(layout); + markersComposite.setFont(parent.getFont()); + + final Button enableCheckbox = addCheckBox(markersComposite, + "Enable task tags", TodoTaskPreferences.ENABLED, 0); + + fCaseSensitiveCheckbox = addCheckBox( + markersComposite, + PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label, + TodoTaskPreferences.CASE_SENSITIVE, 0); + + final GridData data = new GridData(GridData.FILL_BOTH); + data.widthHint = conv.convertWidthInCharsToPixels(50); + fTodoTasksList.getListControl(markersComposite).setLayoutData(data); + + fTodoTasksList.getButtonBox(markersComposite).setLayoutData( + new GridData(GridData.HORIZONTAL_ALIGN_FILL + | GridData.VERTICAL_ALIGN_BEGINNING)); + + enableCheckbox.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + final boolean enabled = ((Button) e.widget).getSelection(); + updateEnableState(enabled); + } + + }); + + return markersComposite; + } + + protected void updateEnableState(boolean enabled) { + fTodoTasksList.setEnabled(enabled); + fCaseSensitiveCheckbox.setEnabled(enabled); + } + + protected void initializeFields() { + super.initializeFields(); + fTodoTasksList.setElements(preferences.getTaskTags()); + if (fTodoTasksList.getSize() > 0) { + fTodoTasksList.selectFirstElement(); + } else { + fTodoTasksList.enableButton(IDX_EDIT, false); + } + updateEnableState(preferences.isEnabled()); + } + +} #P org.eclipse.dltk.ruby.ui Index: src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.java,v retrieving revision 1.3 diff -u -r1.3 RubyPreferencesMessages.java --- src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.java 21 Apr 2008 06:42:28 -0000 1.3 +++ src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.java 24 Apr 2008 11:24:50 -0000 @@ -29,4 +29,7 @@ public static String EditorFoldingPreferencePageDescription; public static String GlobalPreferencePageDescription; + + public static String TodoTaskDescription; + } Index: src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.properties =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.properties,v retrieving revision 1.3 diff -u -r1.3 RubyPreferencesMessages.properties --- src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.properties 21 Apr 2008 06:42:28 -0000 1.3 +++ src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyPreferencesMessages.properties 24 Apr 2008 11:24:50 -0000 @@ -16,3 +16,4 @@ GlobalPreferencePageDescription = General Ruby preferences +TodoTaskDescription = Strings indicating tasks in Ruby comments. Index: plugin.properties =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.ui/plugin.properties,v retrieving revision 1.24 diff -u -r1.24 plugin.properties --- plugin.properties 21 Apr 2008 06:42:28 -0000 1.24 +++ plugin.properties 24 Apr 2008 11:24:50 -0000 @@ -76,6 +76,8 @@ RubyEditorFoldingPreferencePage.name = Folding RubyCodeTemplatesPreferencePage.name = Templates +RubyTaskTagsPreferencePage.name = Task Tags + # Decorators RubyProjectDecorator.name = Ruby Project Decorator Index: plugin.xml =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.ui/plugin.xml,v retrieving revision 1.39 diff -u -r1.39 plugin.xml --- plugin.xml 21 Apr 2008 06:42:28 -0000 1.39 +++ plugin.xml 24 Apr 2008 11:24:50 -0000 @@ -153,6 +153,11 @@ id="org.eclipse.dltk.ruby.preferences.templates" name="%RubyCodeTemplatesPreferencePage.name"> + Index: src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyTodoTaskPreferencePage.java =================================================================== RCS file: src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyTodoTaskPreferencePage.java diff -N src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyTodoTaskPreferencePage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/dltk/ruby/internal/ui/preferences/RubyTodoTaskPreferencePage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.ruby.internal.ui.preferences; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.dltk.ruby.core.RubyPlugin; +import org.eclipse.dltk.ui.preferences.TodoTaskAbstractPreferencePage; + +public class RubyTodoTaskPreferencePage extends TodoTaskAbstractPreferencePage { + + protected String getHelpId() { + return null; + } + + protected void setDescription() { + setDescription(RubyPreferencesMessages.TodoTaskDescription); + } + + protected Preferences getPluginPreferences() { + return RubyPlugin.getDefault().getPluginPreferences(); + } + +} #P org.eclipse.dltk.ruby.core Index: src/org/eclipse/dltk/ruby/internal/parser/JRubySourceParser.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/JRubySourceParser.java,v retrieving revision 1.30 diff -u -r1.30 JRubySourceParser.java --- src/org/eclipse/dltk/ruby/internal/parser/JRubySourceParser.java 28 Mar 2008 03:21:58 -0000 1.30 +++ src/org/eclipse/dltk/ruby/internal/parser/JRubySourceParser.java 24 Apr 2008 11:24:51 -0000 @@ -30,8 +30,10 @@ import org.eclipse.dltk.ast.parser.AbstractSourceParser; import org.eclipse.dltk.ast.references.SimpleReference; import org.eclipse.dltk.ast.statements.Block; +import org.eclipse.dltk.compiler.problem.AbstractProblemReporter; import org.eclipse.dltk.compiler.problem.IProblem; import org.eclipse.dltk.compiler.problem.IProblemReporter; +import org.eclipse.dltk.compiler.problem.ProblemReporterProxy; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.ruby.core.RubyPlugin; import org.eclipse.dltk.ruby.core.utils.RubySyntaxUtils; @@ -272,32 +274,19 @@ return parserResult; } - private class ProxyProblemReporter implements IProblemReporter { - - private final IProblemReporter original; + private class ProxyProblemReporter extends ProblemReporterProxy { public ProxyProblemReporter(IProblemReporter original) { - super(); - this.original = original; + super(original); } public IMarker reportProblem(IProblem problem) throws CoreException { - IMarker m = null; - if (original != null) - m = original.reportProblem(problem); if (problem.isError()) { errorState[0] = true; } - return m; - } - - public void clearMarkers() { - this.original.clearMarkers(); + return super.reportProblem(problem); } - public boolean isMarkersCleaned() { - return original.isMarkersCleaned(); - } } public JRubySourceParser() { @@ -513,7 +502,7 @@ content2 = fixBrokenCommasUnsafe(content2); content2 = fixBrokenHashesUnsafe(content2); - node2 = parser.parse("", new StringReader(content2), new IProblemReporter() { //$NON-NLS-1$ + node2 = parser.parse("", new StringReader(content2), new AbstractProblemReporter() { //$NON-NLS-1$ public IMarker reportProblem(IProblem problem) { if (DLTKCore.DEBUG) { @@ -529,13 +518,6 @@ return null; } - public void clearMarkers() { - } - - public boolean isMarkersCleaned() { - return true; - } - }); if (node2 != null) node = node2; Index: src/org/eclipse/dltk/ruby/internal/parser/RubySourceElementParser.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/RubySourceElementParser.java,v retrieving revision 1.18 diff -u -r1.18 RubySourceElementParser.java --- src/org/eclipse/dltk/ruby/internal/parser/RubySourceElementParser.java 23 Jan 2008 02:17:36 -0000 1.18 +++ src/org/eclipse/dltk/ruby/internal/parser/RubySourceElementParser.java 24 Apr 2008 11:24:51 -0000 @@ -10,8 +10,12 @@ 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.ruby.core.RubyNature; +import org.eclipse.dltk.ruby.core.RubyPlugin; import org.eclipse.dltk.ruby.internal.parser.visitors.RubySourceElementRequestor; public class RubySourceElementParser extends AbstractSourceElementParser { @@ -29,4 +33,17 @@ protected String getNatureId() { return RubyNature.NATURE_ID; } + + 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); + } + } + } + } Index: src/org/eclipse/dltk/ruby/core/RubyPlugin.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/core/RubyPlugin.java,v retrieving revision 1.15 diff -u -r1.15 RubyPlugin.java --- src/org/eclipse/dltk/ruby/core/RubyPlugin.java 12 Mar 2008 11:06:07 -0000 1.15 +++ src/org/eclipse/dltk/ruby/core/RubyPlugin.java 24 Apr 2008 11:24:51 -0000 @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.dltk.compiler.task.TodoTaskPreferences; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.search.IDLTKSearchConstants; @@ -55,7 +56,8 @@ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { - super.start(context); + super.start(context); + new TodoTaskPreferences(getPluginPreferences()).initializeDefaultValues(); } /* #P org.eclipse.dltk.tcl.ui Index: plugin.xml =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml,v retrieving revision 1.30 diff -u -r1.30 plugin.xml --- plugin.xml 7 Mar 2008 03:10:19 -0000 1.30 +++ plugin.xml 24 Apr 2008 11:24:52 -0000 @@ -239,6 +239,11 @@ id="org.eclipse.dltk.tcl.ui.assistance" name="%TclEditorAssistancePreferencePage.name"> + null if this element is not + * opened yet. + */ public IBuffer getBufferNotOpen() throws ModelException { if (hasBuffer()) { - // ensure element is open - IBuffer buffer = getBufferManager().getBuffer(this); - if (buffer == null) { - return null; - } - return buffer; - } else { - return null; + return getBufferManager().getBuffer(this); } + return null; } /** Index: compiler/org/eclipse/dltk/compiler/problem/DLTKProblemReporter.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/DLTKProblemReporter.java,v retrieving revision 1.8 diff -u -r1.8 DLTKProblemReporter.java --- compiler/org/eclipse/dltk/compiler/problem/DLTKProblemReporter.java 25 Mar 2008 22:36:09 -0000 1.8 +++ compiler/org/eclipse/dltk/compiler/problem/DLTKProblemReporter.java 24 Apr 2008 11:24:54 -0000 @@ -12,6 +12,8 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.dltk.compiler.task.DLTKTaskReporter; +import org.eclipse.dltk.compiler.task.ITaskReporter; import org.eclipse.dltk.core.DLTKCore; public class DLTKProblemReporter implements IProblemReporter { @@ -97,4 +99,11 @@ public boolean isMarkersCleaned() { return this.cleaned; } + + public Object getAdapter(Class adapter) { + if (ITaskReporter.class.equals(adapter)) { + return new DLTKTaskReporter(resource); + } + return null; + } } Index: compiler/org/eclipse/dltk/compiler/problem/IProblemReporter.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/IProblemReporter.java,v retrieving revision 1.5 diff -u -r1.5 IProblemReporter.java --- compiler/org/eclipse/dltk/compiler/problem/IProblemReporter.java 13 Feb 2008 14:30:09 -0000 1.5 +++ compiler/org/eclipse/dltk/compiler/problem/IProblemReporter.java 24 Apr 2008 11:24:54 -0000 @@ -11,10 +11,14 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; + +public interface IProblemReporter extends IAdaptable { -public interface IProblemReporter { IMarker reportProblem(IProblem problem) throws CoreException; - // Clear all existing markes from file + + // Clear all existing marks from file void clearMarkers(); + boolean isMarkersCleaned(); } Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/META-INF/MANIFEST.MF,v retrieving revision 1.13 diff -u -r1.13 MANIFEST.MF --- META-INF/MANIFEST.MF 10 Apr 2008 13:21:43 -0000 1.13 +++ META-INF/MANIFEST.MF 24 Apr 2008 11:24:54 -0000 @@ -23,6 +23,7 @@ org.eclipse.dltk.compiler.env, org.eclipse.dltk.compiler.env.lookup, org.eclipse.dltk.compiler.problem, + org.eclipse.dltk.compiler.task, org.eclipse.dltk.compiler.util, org.eclipse.dltk.core, org.eclipse.dltk.core.builder, @@ -41,11 +42,7 @@ org.eclipse.dltk.internal.compiler.impl;x-internal:=true, org.eclipse.dltk.internal.compiler.lookup;x-internal:=true, org.eclipse.dltk.internal.compiler.problem, - org.eclipse.dltk.internal.core; - x-friends:="org.eclipse.dltk.ui, - org.eclipse.dltk.launching, - org.eclipse.dltk.debug, - org.eclipse.dltk.validators.core", + org.eclipse.dltk.internal.core;x-friends:="org.eclipse.dltk.ui,org.eclipse.dltk.launching,org.eclipse.dltk.debug,org.eclipse.dltk.validators.core", org.eclipse.dltk.internal.core.builder;x-internal:=true, org.eclipse.dltk.internal.core.hierarchy, org.eclipse.dltk.internal.core.mixin, Index: model/org/eclipse/dltk/core/SourceParserUtil.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/SourceParserUtil.java,v retrieving revision 1.10 diff -u -r1.10 SourceParserUtil.java --- model/org/eclipse/dltk/core/SourceParserUtil.java 10 Apr 2008 13:21:42 -0000 1.10 +++ model/org/eclipse/dltk/core/SourceParserUtil.java 24 Apr 2008 11:24:54 -0000 @@ -9,121 +9,152 @@ import org.eclipse.dltk.internal.core.ModelManager; public class SourceParserUtil { - private static final Object AST = "ast"; //$NON-NLS-1$ - private static final Object FLAGS = "flags"; //$NON-NLS-1$ + private static final String AST = "ast"; //$NON-NLS-1$ + private static final int DEFAULT_FLAGS = ISourceParserConstants.DEFAULT; /** - * Used to retrive module declaration from source module. + * Used to retrieve module declaration from source module. */ public static ModuleDeclaration getModuleDeclaration(ISourceModule module, IProblemReporter reporter) { - return getModuleDeclaration(module, reporter, ISourceParserConstants.DEFAULT); + return getModuleDeclaration(module, reporter, DEFAULT_FLAGS); } + public static ModuleDeclaration getModuleDeclaration(ISourceModule module, IProblemReporter reporter, int flags) { - ISourceModuleInfoCache sourceModuleInfoCache = ModelManager - .getModelManager().getSourceModuleInfoCache(); - ISourceModuleInfo sourceModuleInfo = sourceModuleInfoCache.get(module); - return getModuleDeclaration(module, reporter, sourceModuleInfo, flags); + ISourceModuleInfoCache cache = ModelManager.getModelManager() + .getSourceModuleInfoCache(); + ISourceModuleInfo cacheEntry = cache.get(module); + ModuleDeclaration declaration = getFromCache(cacheEntry, flags); + if (declaration == null) { + final char[] content = getModuleContent(module); + if (content != null) { + declaration = parseModule(module, content, reporter, flags); + if (declaration != null) { + putToCache(cacheEntry, declaration, flags); + } + } + } + return declaration; + } + + private static ISourceParser getSourceParser(ISourceModule module) { + IDLTKLanguageToolkit toolkit = DLTKLanguageManager + .getLanguageToolkit(module); + return DLTKLanguageManager.getSourceParser(toolkit.getNatureId()); + } + + private static String getCacheKey(int flags) { + if (flags == DEFAULT_FLAGS) { + return AST; + } else { + return AST + flags; + } } /** - * Used to retrive module declaration from source module. + * This is for use in parsers. */ + private static ModuleDeclaration getFromCache(ISourceModuleInfo cacheEntry, + int flags) { + if (cacheEntry != null) { + return (ModuleDeclaration) cacheEntry.get(getCacheKey(flags)); + } + return null; + } - public static ModuleDeclaration getModuleDeclaration(ISourceModule module, - IProblemReporter reporter, ISourceModuleInfo mifo) { - return getModuleDeclaration(module, reporter, mifo, ISourceParserConstants.DEFAULT); + private static void putToCache(ISourceModuleInfo cacheEntry, + ModuleDeclaration declaration, int flags) { + if (cacheEntry != null) { + cacheEntry.put(getCacheKey(flags), declaration); + } } - public static ModuleDeclaration getModuleDeclaration(ISourceModule module, - IProblemReporter reporter, ISourceModuleInfo mifo, int flags) { - IDLTKLanguageToolkit toolkit; - toolkit = DLTKLanguageManager.getLanguageToolkit(module); - ModuleDeclaration moduleDeclaration = null; - Integer flag; - if (mifo != null) { - moduleDeclaration = (ModuleDeclaration) mifo.get(AST); - flag = (Integer) mifo.get(FLAGS); - if( flag != null && flag.intValue() != flags ) { - moduleDeclaration = null; - } + private static char[] getModuleContent(ISourceModule module) { + try { + return module.getSourceAsCharArray(); + } catch (Exception e) { + DLTKCore.error("Error parsing " + module.getPath(), e); + return null; } - if (moduleDeclaration == null) { - if (reporter != null) { - reporter.clearMarkers(); - } - ISourceParser sourceParser = null; - sourceParser = DLTKLanguageManager.getSourceParser(toolkit - .getNatureId()); - if (sourceParser != null) { - if (sourceParser instanceof ISourceParserExtension) { - ((ISourceParserExtension) sourceParser).setFlags(flags); - } - try { - moduleDeclaration = sourceParser.parse(module.getPath() - .toString().toCharArray(), module - .getSourceAsCharArray(), reporter); - } catch (ModelException e) { - if (DLTKCore.DEBUG) { - e.printStackTrace(); - } - } - if (moduleDeclaration != null && mifo != null) { - mifo.put(AST, moduleDeclaration); - mifo.put(FLAGS, new Integer(flags)); - } - } + } + + private static ModuleDeclaration parseModule(ISourceModule module, + char[] content, IProblemReporter reporter, int flags) { + if (reporter != null) { + reporter.clearMarkers(); + } + final ISourceParser parser = getSourceParser(module); + if (parser instanceof ISourceParserExtension) { + ((ISourceParserExtension) parser).setFlags(flags); } - return moduleDeclaration; + final String filename = module.getPath().toString(); + return parser.parse(filename.toCharArray(), content, reporter); } - public static ModuleDeclaration getModuleDeclaration(char[] filename, - char[] content, String nature, IProblemReporter reporter, - ISourceModuleInfo mifo) { - return getModuleDeclaration(filename, content, nature, reporter, mifo, - ISourceParserConstants.DEFAULT); + public static void parseSourceModule( + ISourceElementParser sourceElementParser, ISourceModule sourceModule) { + final ISourceModuleInfo cacheEntry = ModelManager.getModelManager() + .getSourceModuleInfoCache().get(sourceModule); + parseSourceModule(sourceElementParser, sourceModule, cacheEntry); } - public static ModuleDeclaration getModuleDeclaration(char[] filename, - char[] content, String nature, IProblemReporter reporter, - ISourceModuleInfo mifo, int flags) { - ISourceParser sourceParser;// = new SourceParser(this.fReporter); - sourceParser = DLTKLanguageManager.getSourceParser(nature); - if (sourceParser instanceof ISourceParserExtension) { - ((ISourceParserExtension) sourceParser).setFlags(flags); - } - ModuleDeclaration moduleDeclaration = SourceParserUtil - .getModuleFromCache(mifo, flags); - if (moduleDeclaration == null) { - if (reporter != null) { - reporter.clearMarkers(); + public static void parseSourceModule(ISourceElementParser elementParser, + ISourceModule module, ISourceModuleInfo cacheEntry) { + if (cacheEntry != null + && elementParser instanceof ISourceElementASTCachingParser) { + final ISourceElementASTCachingParser cachingParser = (ISourceElementASTCachingParser) elementParser; + final int flags = DEFAULT_FLAGS; + ModuleDeclaration declaration = getFromCache(cacheEntry, flags); + if (declaration == null) { + final char[] content = getModuleContent(module); + if (content == null) { + return; + } + IProblemReporter reporter = cachingParser.getProblemReporter(); + declaration = parseModule(module, content, reporter, flags); + if (declaration != null) { + putToCache(cacheEntry, declaration, flags); + cachingParser.processModule(module, declaration, content); + } + } else { + cachingParser.processModule(module, declaration, null); + } + } else { + final char[] content = getModuleContent(module); + if (content == null) { + return; } - moduleDeclaration = sourceParser.parse(filename, content, reporter); - SourceParserUtil.putModuleToCache(mifo, moduleDeclaration, flags); + elementParser.parseSourceModule(content, cacheEntry, module + .getPath().toString().toCharArray()); } - return moduleDeclaration; } /** - * This is for use in parsers. + * @param filename + * @param content + * @param natureId + * @param object + * @param object2 + * @param runtimeModel + * @return */ - public static ModuleDeclaration getModuleFromCache(ISourceModuleInfo mifo, int flags) { - if (mifo != null) { - Integer flag = (Integer) mifo.get(FLAGS); - if( flag != null && flag.intValue() != flags ) { - return null; + public static ModuleDeclaration getModuleDeclaration(char[] filename, + char[] content, String natureId, IProblemReporter reporter, + ISourceModuleInfo cacheEntry, int flags) { + ModuleDeclaration declaration = getFromCache(cacheEntry, flags); + if (declaration == null) { + ISourceParser parser = DLTKLanguageManager + .getSourceParser(natureId); + if (parser instanceof ISourceParserExtension) { + ((ISourceParserExtension) parser).setFlags(flags); + } + declaration = parser.parse(filename, content, reporter); + if (declaration != null) { + putToCache(cacheEntry, declaration, flags); } - return (ModuleDeclaration) mifo.get(AST); } - return null; + return declaration; } - public static void putModuleToCache(ISourceModuleInfo info, - ModuleDeclaration module, int flags) { - if (info != null) { - info.put(AST, module); - info.put(FLAGS, new Integer(flags)); - } - } } Index: model/org/eclipse/dltk/core/AbstractSourceElementParser.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/AbstractSourceElementParser.java,v retrieving revision 1.4 diff -u -r1.4 AbstractSourceElementParser.java --- model/org/eclipse/dltk/core/AbstractSourceElementParser.java 17 Apr 2008 09:16:02 -0000 1.4 +++ model/org/eclipse/dltk/core/AbstractSourceElementParser.java 24 Apr 2008 11:24:54 -0000 @@ -11,28 +11,57 @@ package org.eclipse.dltk.core; import org.eclipse.dltk.ast.declarations.ModuleDeclaration; +import org.eclipse.dltk.ast.parser.ISourceParser; +import org.eclipse.dltk.ast.parser.ISourceParserConstants; +import org.eclipse.dltk.ast.parser.ISourceParserExtension; import org.eclipse.dltk.compiler.ISourceElementRequestor; import org.eclipse.dltk.compiler.SourceElementRequestVisitor; import org.eclipse.dltk.compiler.problem.IProblemReporter; +import org.eclipse.dltk.compiler.task.ITaskReporter; import org.eclipse.dltk.core.ISourceModuleInfoCache.ISourceModuleInfo; public abstract class AbstractSourceElementParser implements - ISourceElementParser { + ISourceElementParser, ISourceElementASTCachingParser { - private ISourceElementRequestor sourceElementRequestor = null; + private ISourceElementRequestor sourceElementRequestor; private IProblemReporter problemReporter; public void parseSourceModule(char[] contents, ISourceModuleInfo astCache, char[] filename) { + final ModuleDeclaration declaration = parseSource(filename, contents); + final SourceElementRequestVisitor requestor = createVisitor(); + traverse(declaration, requestor); + } - ModuleDeclaration moduleDeclaration = SourceParserUtil - .getModuleDeclaration(filename, contents, getNatureId(), - problemReporter, astCache); + protected ModuleDeclaration parseSource(char[] filename, char[] content) { + if (problemReporter != null) { + problemReporter.clearMarkers(); + } + final ISourceParser sourceParser = createSourceParser(); + if (sourceParser instanceof ISourceParserExtension) { + ((ISourceParserExtension) sourceParser) + .setFlags(ISourceParserConstants.DEFAULT); + } + return sourceParser.parse(filename, content, problemReporter); + } - SourceElementRequestVisitor requestor = createVisitor(); + protected ISourceParser createSourceParser() { + return DLTKLanguageManager.getSourceParser(getNatureId()); + } + + public void processModule(ISourceModule module, + ModuleDeclaration declaration, char[] content) { + final SourceElementRequestVisitor requestor = createVisitor(); + traverse(declaration, requestor); + if (content != null) { + parseTasks(content); + } + } + protected void traverse(final ModuleDeclaration declaration, + final SourceElementRequestVisitor requestor) { try { - moduleDeclaration.traverse(requestor); + declaration.traverse(requestor); } catch (Exception e) { if (DLTKCore.DEBUG) { e.printStackTrace(); @@ -40,6 +69,21 @@ } } + protected void parseTasks(char[] content) { + if (problemReporter != null) { + final ITaskReporter taskReporter = (ITaskReporter) problemReporter + .getAdapter(ITaskReporter.class); + if (taskReporter != null) { + taskReporter.clearTasks(); + parseTasks(taskReporter, content); + } + } + } + + protected void parseTasks(ITaskReporter taskReporter, char[] content) { + // empty - should be overridden in descendants + } + public void setReporter(IProblemReporter reporter) { this.problemReporter = reporter; } @@ -52,7 +96,7 @@ return sourceElementRequestor; } - protected IProblemReporter getProblemReporter() { + public IProblemReporter getProblemReporter() { return problemReporter; } Index: model/org/eclipse/dltk/core/DLTKCore.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/DLTKCore.java,v retrieving revision 1.22 diff -u -r1.22 DLTKCore.java --- model/org/eclipse/dltk/core/DLTKCore.java 2 Apr 2008 09:50:22 -0000 1.22 +++ model/org/eclipse/dltk/core/DLTKCore.java 24 Apr 2008 11:24:54 -0000 @@ -27,8 +27,10 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.dltk.internal.core.BatchOperation; import org.eclipse.dltk.internal.core.BuildpathAccessRule; @@ -1541,5 +1543,13 @@ public static String[] getUserLibraryNames(IDLTKLanguageToolkit toolkit) { return ModelManager.getUserLibraryManager().getUserLibraryNames(toolkit); } + + public static void error(String message) { + plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, null)); + } + + public static void error(String message, Throwable t) { + plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, t)); + } } Index: compiler/org/eclipse/dltk/compiler/task/ITaskReporter.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/task/ITaskReporter.java diff -N compiler/org/eclipse/dltk/compiler/task/ITaskReporter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/task/ITaskReporter.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.task; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; + +/** + * The interface to create tasks for the attached resource. At any given + * moment this object operates on single {@link IResource}. + */ +public interface ITaskReporter extends IAdaptable { + + /** + * Clears all tasks related to the attached resource. + */ + void clearTasks(); + + /** + * Creates new task for the attached resource. + * + * @param message + * @param lineNumber + * @param priority + * @param charStart + * @param charEnd + * @throws CoreException + */ + void reportTask(String message, int lineNumber, int priority, + int charStart, int charEnd) throws CoreException; + +} Index: compiler/org/eclipse/dltk/compiler/task/TodoTaskSimpleParser.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/task/TodoTaskSimpleParser.java diff -N compiler/org/eclipse/dltk/compiler/task/TodoTaskSimpleParser.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/task/TodoTaskSimpleParser.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,156 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.task; + +import java.util.List; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.dltk.core.DLTKCore; + +public class TodoTaskSimpleParser { + + private final ITaskReporter taskReporter; + private final boolean caseSensitive; + private final char[][] tags; + private final int minTagLength; + private final int[] priorities; + + public TodoTaskSimpleParser(ITaskReporter taskReporter, + TodoTaskPreferences preferences) { + this.taskReporter = taskReporter; + this.caseSensitive = preferences.isCaseSensitive(); + final List tags = preferences.getTaskTags(); + if (!tags.isEmpty()) { + final int tagCount = tags.size(); + this.tags = new char[tagCount][]; + this.priorities = new int[tagCount]; + int minTagLength = Integer.MAX_VALUE; + for (int i = 0; i < tagCount; ++i) { + final TodoTask task = (TodoTask) tags.get(i); + String tagName = task.name; + if (!caseSensitive) { + tagName = tagName.toUpperCase(); + } + if (tagName.length() < minTagLength) { + minTagLength = tagName.length(); + } + this.tags[i] = tagName.toCharArray(); + if (TodoTask.PRIORITY_HIGH.equals(task.priority)) { + priorities[i] = IMarker.PRIORITY_HIGH; + } else if (TodoTask.PRIORITY_LOW.equals(task.priority)) { + priorities[i] = IMarker.PRIORITY_LOW; + } else { + priorities[i] = IMarker.PRIORITY_NORMAL; + } + } + this.minTagLength = minTagLength; + } else { + this.tags = null; + this.minTagLength = 0; + this.priorities = null; + } + } + + public boolean isValid() { + return tags != null && tags.length > 0; + } + + private int lineNumber; + private int contentPos; + private int contentEnd; + + public void parse(char[] content) { + lineNumber = 0; + contentPos = 0; + contentEnd = content.length; + while (contentPos < contentEnd) { + int begin = contentPos; + final int end = findEndOfLine(content); + if (begin < end) { + begin = skipSpaces(content, begin, end); + if (begin < end && content[begin] == '#') { + ++begin; + begin = skipSpaces(content, begin, end); + if (begin + minTagLength <= end) { + processLine(content, begin, end); + } + } + } + ++lineNumber; + } + } + + private final int skipSpaces(char[] content, int pos, final int end) { + while (pos < end && Character.isWhitespace(content[pos])) { + ++pos; + } + return pos; + } + + private void processLine(char[] content, int begin, final int end) { + for (int i = 0; i < tags.length; ++i) { + final char[] tag = tags[i]; + if (begin + tag.length < end + && Character.isWhitespace(content[begin + tag.length]) + || begin + tag.length == end) { + if (compareTag(content, begin, tag)) { + final String msg = new String(content, begin, end - begin); + try { + taskReporter.reportTask(msg, lineNumber, priorities[i], + begin, contentPos); + } catch (CoreException e) { + DLTKCore.error("Error in reportTask()", e); + } + } + } + } + } + + private boolean compareTag(char[] content, int pos, final char[] tag) { + if (caseSensitive) { + for (int j = 0; j < tag.length; ++j) { + if (content[pos + j] != tag[j]) { + return false; + } + } + } else { + for (int j = 0; j < tag.length; ++j) { + if (Character.toUpperCase(content[pos + j]) != tag[j]) { + return false; + } + } + } + return true; + } + + private int findEndOfLine(char[] content) { + while (contentPos < contentEnd) { + if (content[contentPos] == '\r') { + final int endLine = contentPos; + ++contentPos; + if (contentPos < contentEnd && content[contentPos] == '\n') { + ++contentPos; + } + return endLine; + } else if (content[contentPos] == '\n') { + final int endLine = contentPos; + ++contentPos; + return endLine; + } else { + ++contentPos; + } + } + return contentPos; + } + +} Index: model/org/eclipse/dltk/core/ISourceElementASTCachingParser.java =================================================================== RCS file: model/org/eclipse/dltk/core/ISourceElementASTCachingParser.java diff -N model/org/eclipse/dltk/core/ISourceElementASTCachingParser.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ model/org/eclipse/dltk/core/ISourceElementASTCachingParser.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.core; + +import org.eclipse.dltk.ast.declarations.ModuleDeclaration; +import org.eclipse.dltk.ast.parser.ISourceParser; +import org.eclipse.dltk.compiler.problem.IProblemReporter; + +/** + * The optional interface to be implemented by {@link ISourceElementParser} if + * operates on the AST model build by {@link ISourceParser} and wishes to share + * AST cache. + */ +public interface ISourceElementASTCachingParser extends ISourceElementParser { + + /** + * @return + */ + IProblemReporter getProblemReporter(); + + /** + * This entry to call when caching is used. + * + * @param module + * the {@link ISourceModule} being parsed + * @param declaration + * the {@link ModuleDeclaration} parsed + * @param content + * source module content if module was just parsed or + * null if {@link ModuleDeclaration} was retrieved + * from cache (if the module content is needed it could be + * retrieved from {@link ISourceModule}). + */ + void processModule(ISourceModule module, ModuleDeclaration declaration, + char[] content); + +} Index: compiler/org/eclipse/dltk/compiler/task/TodoTaskPreferences.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/task/TodoTaskPreferences.java diff -N compiler/org/eclipse/dltk/compiler/task/TodoTaskPreferences.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/task/TodoTaskPreferences.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.task; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.dltk.core.DLTKCore; + +public class TodoTaskPreferences { + + public static final String CASE_SENSITIVE = DLTKCore.PLUGIN_ID + + "tasks.case_sensitive"; //$NON-NLS-1$ + public static final String TAGS = DLTKCore.PLUGIN_ID + "tasks.tags"; //$NON-NLS-1$ + public static final String ENABLED = DLTKCore.PLUGIN_ID + "tasks.enabled"; //$NON-NLS-1$ + + private static final String TAG_SEPARATOR = ","; //$NON-NLS-1$ + private static final String PRIORITY_SEPARATOR = ";"; //$NON-NLS-1$ + + public static boolean isValidName(String newText) { + return newText.indexOf(TAG_SEPARATOR.charAt(0)) < 0 + && newText.indexOf(PRIORITY_SEPARATOR.charAt(0)) < 0; + } + + private final Preferences store; + + public TodoTaskPreferences(Preferences store) { + this.store = store; + } + + protected String[] getTokens(String text, String separator) { + final StringTokenizer tok = new StringTokenizer(text, separator); + final int nTokens = tok.countTokens(); + final String[] res = new String[nTokens]; + for (int i = 0; i < res.length; i++) { + res[i] = tok.nextToken().trim(); + } + return res; + } + + public boolean isEnabled() { + return store.getBoolean(ENABLED); + } + + public boolean isCaseSensitive() { + return store.getBoolean(CASE_SENSITIVE); + } + + public List getTaskTags() { + final String tags = store.getString(TAGS); + final String[] tagPairs = getTokens(tags, TAG_SEPARATOR); + final List elements = new ArrayList(); + for (int i = 0; i < tagPairs.length; ++i) { + final String[] values = getTokens(tagPairs[i], PRIORITY_SEPARATOR); + final TodoTask task = new TodoTask(); + task.name = values[0]; + if (values.length == 2) { + task.priority = values[1]; + } else { + task.priority = TodoTask.PRIORITY_NORMAL; + } + elements.add(task); + } + return elements; + } + + public void setTaskTags(List elements) { + store.setValue(TAGS, encodeTaskTags(elements)); + } + + private String encodeTaskTags(List elements) { + final StringBuffer sb = new StringBuffer(); + for (int i = 0; i < elements.size(); ++i) { + final TodoTask task = (TodoTask) elements.get(i); + if (i > 0) { + sb.append(TAG_SEPARATOR); + } + sb.append(task.name); + sb.append(PRIORITY_SEPARATOR); + sb.append(task.priority); + } + final String string = sb.toString(); + return string; + } + + public static List getDefaultTags() { + final List defaultTags = new ArrayList(); + defaultTags.add(new TodoTask("TODO", TodoTask.PRIORITY_NORMAL)); //$NON-NLS-1$ + defaultTags.add(new TodoTask("FIXME", TodoTask.PRIORITY_HIGH)); //$NON-NLS-1$ + defaultTags.add(new TodoTask("XXX", TodoTask.PRIORITY_NORMAL)); //$NON-NLS-1$ + return defaultTags; + } + + public void initializeDefaultValues() { + store.setDefault(ENABLED, true); + store.setDefault(CASE_SENSITIVE, true); + store.setDefault(TAGS, encodeTaskTags(getDefaultTags())); + } + +} Index: compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java diff -N compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.problem; + +/** + * The abstract implementation of {@link IProblemReporter} to simplify code in + * tests, etc. + */ +public abstract class AbstractProblemReporter implements IProblemReporter { + + public void clearMarkers() { + // empty + } + + public boolean isMarkersCleaned() { + return false; + } + + public Object getAdapter(Class adapter) { + return null; + } + +} Index: compiler/org/eclipse/dltk/compiler/task/TodoTask.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/task/TodoTask.java diff -N compiler/org/eclipse/dltk/compiler/task/TodoTask.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/task/TodoTask.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.task; + +public class TodoTask { + public static final String PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$ + public static final String PRIORITY_LOW = "LOW"; //$NON-NLS-1$ + public static final String PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$ + + public TodoTask() { + // empty + } + + public TodoTask(String name, String priority) { + this.name = name; + this.priority = priority; + } + + public String name; + public String priority; + +} Index: compiler/org/eclipse/dltk/compiler/task/DLTKTaskReporter.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/task/DLTKTaskReporter.java diff -N compiler/org/eclipse/dltk/compiler/task/DLTKTaskReporter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/task/DLTKTaskReporter.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.task; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * Default implementation of the {@link ITaskReporter} + */ +public class DLTKTaskReporter implements ITaskReporter { + + private final IResource resource; + private boolean tasksCleared; + + public DLTKTaskReporter(IResource resource) { + this.resource = resource; + tasksCleared = false; + } + + public void clearTasks() { + if (!tasksCleared) { + try { + resource.deleteMarkers(IMarker.TASK, true, + IResource.DEPTH_INFINITE); + } catch (CoreException e) { + System.err.println(e); + } + tasksCleared = true; + } + } + + public void reportTask(String message, int lineNumber, int priority, + int charStart, int charEnd) throws CoreException { + IMarker m = resource.createMarker(IMarker.TASK); + m.setAttribute(IMarker.LINE_NUMBER, lineNumber + 1); + m.setAttribute(IMarker.MESSAGE, message); + m.setAttribute(IMarker.PRIORITY, priority); + m.setAttribute(IMarker.CHAR_START, charStart); + m.setAttribute(IMarker.CHAR_END, charEnd); + m.setAttribute(IMarker.USER_EDITABLE, Boolean.FALSE); + } + + public Object getAdapter(Class adapter) { + return null; + } + +} Index: compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java =================================================================== RCS file: compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java diff -N compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2008 xored software, Inc. + * + * 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 + * + * Contributors: + * xored software, Inc. - initial API and Implementation (Alex Panchenko) + *******************************************************************************/ +package org.eclipse.dltk.compiler.problem; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; + +/** + * The {@link IProblemReporter} implementation which forwards all methods call + * to the instance passed in the constructor. + */ +public class ProblemReporterProxy implements IProblemReporter { + + private final IProblemReporter original; + + /** + * @param original + */ + protected ProblemReporterProxy(IProblemReporter original) { + this.original = original; + } + + public void clearMarkers() { + if (original != null) { + original.clearMarkers(); + } + } + + public boolean isMarkersCleaned() { + return original != null && original.isMarkersCleaned(); + } + + public IMarker reportProblem(IProblem problem) throws CoreException { + if (original != null) { + return original.reportProblem(problem); + } + return null; + } + + public Object getAdapter(Class adapter) { + if (original != null) { + return original.getAdapter(adapter); + } + return null; + } + +} #P org.eclipse.dltk.ruby.core.tests Index: src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.dltk/ruby/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java,v retrieving revision 1.6 diff -u -r1.6 AbstractASTTest.java --- src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java 28 Mar 2008 11:49:50 -0000 1.6 +++ src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java 24 Apr 2008 11:24:57 -0000 @@ -14,8 +14,8 @@ import org.eclipse.dltk.ast.ASTNode; import org.eclipse.dltk.ast.ASTVisitor; import org.eclipse.dltk.ast.declarations.ModuleDeclaration; +import org.eclipse.dltk.compiler.problem.AbstractProblemReporter; import org.eclipse.dltk.compiler.problem.IProblem; -import org.eclipse.dltk.compiler.problem.IProblemReporter; import org.eclipse.dltk.core.DLTKLanguageManager; import org.eclipse.dltk.core.tests.model.AbstractModelTests; import org.eclipse.dltk.ruby.core.RubyNature; @@ -23,7 +23,7 @@ public abstract class AbstractASTTest extends AbstractModelTests { - protected static class CountingProblemReporter implements IProblemReporter { + protected static class CountingProblemReporter extends AbstractProblemReporter { public int count = 0; public String lastInfo = ""; @@ -46,12 +46,6 @@ return null; } - public void clearMarkers() { - } - - public boolean isMarkersCleaned() { - return false; - } } protected final static CountingProblemReporter problems = new CountingProblemReporter();