diff options
author | nitind | 2008-01-17 05:05:10 +0000 |
---|---|---|
committer | nitind | 2008-01-17 05:05:10 +0000 |
commit | 187c1657b57d9ce97e2c6320186d76c71fa7025e (patch) | |
tree | 089759c682539754e9667952c4c7f92f227ace22 | |
parent | 3ac51d5b0e37cea3ec23dfef8fdd660425daeee5 (diff) | |
download | webtools.sourceediting-187c1657b57d9ce97e2c6320186d76c71fa7025e.tar.gz webtools.sourceediting-187c1657b57d9ce97e2c6320186d76c71fa7025e.tar.xz webtools.sourceediting-187c1657b57d9ce97e2c6320186d76c71fa7025e.zip |
[215614] Support custom task marker types for each language
12 files changed, 99 insertions, 24 deletions
diff --git a/bundles/org.eclipse.wst.css.core/plugin.properties b/bundles/org.eclipse.wst.css.core/plugin.properties index 0b84cb7e5f..67fcec088c 100644 --- a/bundles/org.eclipse.wst.css.core/plugin.properties +++ b/bundles/org.eclipse.wst.css.core/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2004, 2006 IBM Corporation and others. +# Copyright (c) 2004, 2008 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 @@ -16,3 +16,4 @@ cssprofile_mobile1_0.name=CSS Mobile Profile 1.0 cssprofile_wap.name=WCSS 1.0 Structured_CSS_Document_Factory_Extension.name=Structured CSS Document Factory Extension CSS_Content_Type_Extension_Element.name=CSS +_taskMarker.name=CSS Task
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/plugin.xml b/bundles/org.eclipse.wst.css.core/plugin.xml index e6c7cd19c1..5aaf54ba35 100644 --- a/bundles/org.eclipse.wst.css.core/plugin.xml +++ b/bundles/org.eclipse.wst.css.core/plugin.xml @@ -37,9 +37,16 @@ <extension point="org.eclipse.wst.sse.core.taskscanner"> <scanner id="org.eclipse.wst.css.core.internal.tasks.CSSFileTaskScanner" - class="org.eclipse.wst.css.core.internal.tasks.CSSFileTaskScanner" + class="org.eclipse.wst.css.core.internal.tasks.CSSFileTaskScanner:org.eclipse.wst.css.core.taskMarker" contentTypeIds="org.eclipse.wst.css.core.csssource" /> </extension> + <extension + id="taskMarker" + name="%_taskMarker.name" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.wst.sse.core.task"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.core.filebuffers.documentCreation" diff --git a/bundles/org.eclipse.wst.dtd.core/plugin.properties b/bundles/org.eclipse.wst.dtd.core/plugin.properties index 17dd85c15f..33740d070e 100644 --- a/bundles/org.eclipse.wst.dtd.core/plugin.properties +++ b/bundles/org.eclipse.wst.dtd.core/plugin.properties @@ -17,4 +17,5 @@ pluginName=Structured Source DTD Core Structured_DTD_Document_Factory_Extension.name=Structured DTD Document Factory Extension DTD_Content_Type_Extension_Element.name=DTD _DTD_VALIDATOR_NAME = DTD Validator -_validationMarker.name=DTD Problem
\ No newline at end of file +_validationMarker.name=DTD Problem +_taskMarker.name=DTD Task
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.dtd.core/plugin.xml b/bundles/org.eclipse.wst.dtd.core/plugin.xml index 38bbcbe89d..0edc89820a 100644 --- a/bundles/org.eclipse.wst.dtd.core/plugin.xml +++ b/bundles/org.eclipse.wst.dtd.core/plugin.xml @@ -13,9 +13,16 @@ <extension point="org.eclipse.wst.sse.core.taskscanner"> <scanner id="org.eclipse.wst.dtd.core.internal.tasks.DTDFileTaskScanner" - class="org.eclipse.wst.dtd.core.internal.tasks.DTDFileTaskScanner" + class="org.eclipse.wst.dtd.core.internal.tasks.DTDFileTaskScanner:org.eclipse.wst.dtd.core.taskMarker" contentTypeIds="org.eclipse.wst.dtd.core.dtdsource" /> </extension> + <extension + id="taskMarker" + name="%_taskMarker.name" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.wst.sse.core.task"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.core.filebuffers.documentCreation" diff --git a/bundles/org.eclipse.wst.html.core/plugin.properties b/bundles/org.eclipse.wst.html.core/plugin.properties index 92a9e57ed8..e89986ffa0 100644 --- a/bundles/org.eclipse.wst.html.core/plugin.properties +++ b/bundles/org.eclipse.wst.html.core/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2004, 2006 IBM Corporation and others. +# Copyright (c) 2004, 2008 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 @@ -12,3 +12,4 @@ providerName=Eclipse.org pluginName=Structured Source HTML Model Structured_HTML_Document_Factory_Extension.name=Structured HTML Document Factory Extension HTML_Content_Type_Extension_Element.name=HTML +_taskMarker.name=HTML Task
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/plugin.xml b/bundles/org.eclipse.wst.html.core/plugin.xml index 9d6fc2c4ee..f4054dcf9e 100644 --- a/bundles/org.eclipse.wst.html.core/plugin.xml +++ b/bundles/org.eclipse.wst.html.core/plugin.xml @@ -20,9 +20,16 @@ <extension point="org.eclipse.wst.sse.core.taskscanner"> <scanner id="org.eclipse.wst.html.core.internal.tasks.HTMLFileTaskScanner" - class="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner" + class="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner:org.eclipse.wst.html.core.taskMarker" contentTypeIds="org.eclipse.wst.html.core.htmlsource" /> </extension> + <extension + id="taskMarker" + name="%_taskMarker.name" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.wst.sse.core.task"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.core.filebuffers.documentCreation" diff --git a/bundles/org.eclipse.wst.sse.core/plugin.properties b/bundles/org.eclipse.wst.sse.core/plugin.properties index 8fbaef9cb5..651ffccea6 100644 --- a/bundles/org.eclipse.wst.sse.core/plugin.properties +++ b/bundles/org.eclipse.wst.sse.core/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2001, 2006 IBM Corporation and others. +# Copyright (c) 2001, 2008 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 diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/provisional/tasks/IFileTaskScanner.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/provisional/tasks/IFileTaskScanner.java index 08c18d781e..d1655b2d5c 100644 --- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/provisional/tasks/IFileTaskScanner.java +++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/provisional/tasks/IFileTaskScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. + * Copyright (c) 2001, 2008 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 @@ -30,12 +30,18 @@ import org.eclipse.wst.sse.core.internal.SSECorePlugin; */ public interface IFileTaskScanner { /** - * Marker type ID of task markers that are created, all scanners are - * expected to use this type or subtypes + * Default marker type ID of task markers that are created. */ String TASK_MARKER_ID = SSECorePlugin.ID + ".task"; //$NON-NLS-1$; /** + * @return the task marker type that should be removed each time tasks are + * rescanned and used by default when creating task markers. + * Children of this marker type will be removed automatically. + */ + String getMarkerType(); + + /** * Requests that the list of automatically discovered tasks for the given * file be updated. Once completed, the list of tasks should correspond * exactly to the file's contents. @@ -46,8 +52,13 @@ public interface IFileTaskScanner { * the list of task tags for which to scan * @param monitor - * a progress monitor - * @return an array of maps containing the attributes for task markers to + * @return an array of maps containing the attributes of task markers to * be created + * <p> + * The reserved attribute name + * <b>org.eclipse.core.resources.taskmarker</b> may be used to + * specify a type to use when creating the task marker. + * </p> */ Map[] scan(IFile file, TaskTag[] taskTags, IProgressMonitor monitor); diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java index d40ea16b87..165e900a4d 100644 --- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java +++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2007 IBM Corporation and others. + * Copyright (c) 2001, 2008 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 @@ -30,6 +30,8 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; @@ -53,12 +55,13 @@ import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; /** * A delegate to create IMarker.TASKs for "todos" and similiar comments. */ -public abstract class StructuredFileTaskScanner implements IFileTaskScanner { +public abstract class StructuredFileTaskScanner implements IFileTaskScanner, IExecutableExtension { // the list of attributes for the new tasks for the current file protected List fNewMarkerAttributeMaps = null; List oldMarkers = null; private long time0; + private String runtimeMarkerType; public StructuredFileTaskScanner() { super(); @@ -78,7 +81,7 @@ public abstract class StructuredFileTaskScanner implements IFileTaskScanner { Map attributes = new HashMap(6); // marker line numbers are 1-based attributes.put(IMarker.LINE_NUMBER, new Integer(documentLine + 1)); - attributes.put(IMarker.TASK, IFileTaskScanner.TASK_MARKER_ID); + attributes.put(IMarker.TASK, getMarkerType()); attributes.put(IMarker.CHAR_START, new Integer(startOffset)); attributes.put(IMarker.CHAR_END, new Integer(startOffset + length)); attributes.put(IMarker.MESSAGE, text); @@ -102,6 +105,16 @@ public abstract class StructuredFileTaskScanner implements IFileTaskScanner { return attributes; } + /* (non-Javadoc) + * @see org.eclipse.wst.sse.core.internal.provisional.tasks.IFileTaskScanner#getMarkerType() + */ + public String getMarkerType() { + if (runtimeMarkerType != null) + return runtimeMarkerType; + + return IFileTaskScanner.TASK_MARKER_ID; + } + private String detectCharset(IFile file) { if (file.getType() == IResource.FILE && file.isAccessible()) { try { @@ -276,6 +289,15 @@ public abstract class StructuredFileTaskScanner implements IFileTaskScanner { } } } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object) + */ + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { + if (data != null && data instanceof String) { + runtimeMarkerType = data.toString(); + } + } boolean shouldScan(IResource r) { // skip "dot" files diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java index b3256712d9..849516e689 100644 --- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java +++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/WorkspaceTaskScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2007 IBM Corporation and others. + * Copyright (c) 2001, 2008 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 @@ -13,8 +13,10 @@ package org.eclipse.wst.sse.core.internal.tasks; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -244,7 +246,7 @@ class WorkspaceTaskScanner { } } - private void replaceTaskMarkers(final IFile file, final Map markerAttributes[], IProgressMonitor monitor) { + private void replaceTaskMarkers(final IFile file, final String[] markerTypes, final Map markerAttributes[], IProgressMonitor monitor) { final IFile finalFile = file; if (file.isAccessible()) { try { @@ -253,9 +255,11 @@ class WorkspaceTaskScanner { try { /* * Delete old Task markers (don't delete regular - * Tasks since that includes user-defined ones + * Tasks since that includes user-defined ones) */ - file.deleteMarkers(DEFAULT_MARKER_TYPE, true, IResource.DEPTH_ZERO); + for (int i = 0; i < markerTypes.length; i++) { + file.deleteMarkers(markerTypes[i], true, IResource.DEPTH_ZERO); + } } catch (CoreException e) { Logger.logException("exception deleting old tasks", e); //$NON-NLS-1$ @@ -336,6 +340,11 @@ class WorkspaceTaskScanner { List markerAttributes = null; IContentType[] types = detectContentTypes(file); + Set markerTypes = new HashSet(3); + // Always included for safety and migration + markerTypes.add(DEFAULT_MARKER_TYPE); + + monitor.worked(1); IFileTaskScanner[] fileScanners = null; @@ -368,6 +377,7 @@ class WorkspaceTaskScanner { fileScanners[j].startup(file.getProject()); fActiveScanners.add(fileScanners[j]); } + markerTypes.add(fileScanners[j].getMarkerType()); Map[] taskMarkerAttributes = fileScanners[j].scan(file, taskTags, new SubProgressMonitor(scannerMonitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); /* * TODO: pool the marker results so there's only one @@ -377,6 +387,9 @@ class WorkspaceTaskScanner { if (markerAttributes == null) { markerAttributes = new ArrayList(); } + if (!taskMarkerAttributes[i].containsKey(IMarker.TASK)) { + taskMarkerAttributes[i].put(IMarker.TASK, fileScanners[j].getMarkerType()); + } markerAttributes.add(taskMarkerAttributes[i]); } } @@ -397,10 +410,7 @@ class WorkspaceTaskScanner { if (fileScanners != null && fileScanners.length > 0) { IProgressMonitor markerUpdateMonitor = new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); if (markerAttributes != null) { - replaceTaskMarkers(file, (Map[]) markerAttributes.toArray(new Map[markerAttributes.size()]), markerUpdateMonitor); - } - else { - replaceTaskMarkers(file, null, markerUpdateMonitor); + replaceTaskMarkers(file, (String[]) markerTypes.toArray(new String[markerTypes.size()]), (Map[]) markerAttributes.toArray(new Map[markerAttributes.size()]), markerUpdateMonitor); } } else { diff --git a/bundles/org.eclipse.wst.xml.core/plugin.properties b/bundles/org.eclipse.wst.xml.core/plugin.properties index 24000fda01..b9544908e4 100644 --- a/bundles/org.eclipse.wst.xml.core/plugin.properties +++ b/bundles/org.eclipse.wst.xml.core/plugin.properties @@ -23,4 +23,5 @@ XSL_Content_Type_Extension_Element.name=XSL XMI_Content_Type=XMI XML_Validator.name=XML Validator XML_Validation_Error_Customizer.name=XML Validator Error Customizer Extension Point -_validationMarker.name=XML Problem
\ No newline at end of file +_validationMarker.name=XML Problem +_taskMarker.name=XML Task
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xml.core/plugin.xml b/bundles/org.eclipse.wst.xml.core/plugin.xml index 2a08e48f53..75090bb796 100644 --- a/bundles/org.eclipse.wst.xml.core/plugin.xml +++ b/bundles/org.eclipse.wst.xml.core/plugin.xml @@ -31,9 +31,16 @@ <extension point="org.eclipse.wst.sse.core.taskscanner"> <scanner id="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner" - class="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner" + class="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner:org.eclipse.wst.xml.core.taskMarker" contentTypeIds="org.eclipse.core.runtime.xml" /> </extension> + <extension + id="taskMarker" + name="%_taskMarker.name" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.wst.sse.core.task"/> + <persistent value="true"/> + </extension> <!-- Here we define a new extension point. This extension point is used to programmatically contribute catalog entries to the XML Catalog. --> |