Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 99830 Details for
Bug 228887
Incorrect/incomplete error in problem view: "Plug-ins declaring extensions or extension points must set the singleton directive to true"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated Patch
clipboard.txt (text/plain), 10.76 KB, created by
Curtis Windatt
on 2008-05-12 17:41:11 EDT
(
hide
)
Description:
Updated Patch
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2008-05-12 17:41:11 EDT
Size:
10.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java,v >retrieving revision 1.30 >diff -u -r1.30 ExtensionsErrorReporter.java >--- src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java 7 May 2008 14:10:15 -0000 1.30 >+++ src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java 12 May 2008 21:36:53 -0000 >@@ -52,6 +52,8 @@ > Element element = getDocumentRoot(); > if (element == null) > return; >+ >+ boolean foundExtensionsOrExtensionPoint = false; > String elementName = element.getNodeName(); > if (!"plugin".equals(elementName) && !"fragment".equals(elementName)) { //$NON-NLS-1$ //$NON-NLS-2$ > reportIllegalElement(element, CompilerFlags.ERROR); >@@ -72,8 +74,10 @@ > String name = child.getNodeName(); > if (name.equals("extension")) { //$NON-NLS-1$ > validateExtension(child); >+ foundExtensionsOrExtensionPoint = true; > } else if (name.equals("extension-point")) { //$NON-NLS-1$ > validateExtensionPoint(child); >+ foundExtensionsOrExtensionPoint = true; > } else { > if (!name.equals("runtime") && !name.equals("requires")) { //$NON-NLS-1$ //$NON-NLS-2$ > severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); >@@ -87,9 +91,12 @@ > } > } > >- IExtensions extensions = fModel.getExtensions(); >- if (extensions != null && extensions.getExtensions().length == 0 && extensions.getExtensionPoints().length == 0) >+ // fModel.getExtensions() cannot be used since singleton might not be set to true in which cases getExtensions always return 0 even if there is extension points defined. >+ //IExtensions extensions = fModel.getExtensions(); >+ //if (extensions != null && extensions.getExtensions().length == 0 && extensions.getExtensionPoints().length == 0) >+ if(!foundExtensionsOrExtensionPoint) { > report(PDECoreMessages.Builders_Manifest_useless_file, -1, IMarker.SEVERITY_WARNING, PDEMarkerFactory.P_USELESS_FILE, PDEMarkerFactory.CAT_OTHER); >+ } > } > } > >Index: src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java,v >retrieving revision 1.65 >diff -u -r1.65 BundleErrorReporter.java >--- src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java 7 May 2008 15:50:52 -0000 1.65 >+++ src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java 12 May 2008 21:36:53 -0000 >@@ -29,6 +29,9 @@ > import org.eclipse.pde.internal.core.search.PluginJavaSearchUtil; > import org.eclipse.pde.internal.core.util.*; > import org.osgi.framework.*; >+import org.w3c.dom.Element; >+import org.w3c.dom.NodeList; >+import org.xml.sax.SAXException; > > public class BundleErrorReporter extends JarManifestErrorReporter { > >@@ -47,7 +50,7 @@ > > fModel = PluginRegistry.findModel(fProject); > // be paranoid. something could have gone wrong reading the file etc. >- if (fModel == null || !validateBundleSymbolicName()) >+ if (fModel == null || !validateBundleSymbolicName(monitor)) > return; > > validateFragmentHost(); >@@ -132,7 +135,7 @@ > /** > * @return boolean false if fatal > */ >- private boolean validateBundleSymbolicName() { >+ private boolean validateBundleSymbolicName(IProgressMonitor monitor) { > IHeader header = validateRequiredHeader(Constants.BUNDLE_SYMBOLICNAME); > if (header == null) > return false; >@@ -147,7 +150,7 @@ > if (!validateBundleManifestVersion()) > return false; > validatePluginId(header, id); >- validateSingleton(header, elements[0]); >+ validateSingleton(monitor, header, elements[0]); > > return true; > } >@@ -162,15 +165,11 @@ > } > > // validateBundleManifestVersion must be called before this function. Relies on fOSGiR4 being set correctly >- private void validateSingleton(IHeader header, ManifestElement element) { >+ private void validateSingleton(IProgressMonitor monitor, IHeader header, ManifestElement element) { > String singletonAttr = element.getAttribute(ICoreConstants.SINGLETON_ATTRIBUTE); > String singletonDir = element.getDirective(Constants.SINGLETON_DIRECTIVE); >- IPluginBase base = fModel.getPluginBase(); >- // must check the existence of plugin.xml file instead of using IPluginBase because if the bundle is not a singleton, >- // it won't be registered with the extension registry and will always return 0 when querying extensions/extension points >- boolean hasExtensions = base != null && fProject.findMember(ICoreConstants.PLUGIN_PATH) != null; > >- if (hasExtensions) { >+ if (hasExtensions(monitor)) { > if (TargetPlatformHelper.getTargetVersion() >= 3.1) { > if (!"true".equals(singletonDir)) { //$NON-NLS-1$ > if ("true".equals(singletonAttr)) { //$NON-NLS-1$ >@@ -1083,4 +1082,83 @@ > } catch (CoreException e) { > } > } >+ >+ private boolean hasExtensions(IProgressMonitor monitor) { >+ // must check the existence and content of plugin.xml file instead of using IPluginBase because if the bundle is not a singleton, >+ // it won't be registered with the extension registry and will always return 0 when querying extensions/extension points >+ IPluginBase base = fModel.getPluginBase(); >+ if (base != null) { >+ IFile file = fProject.getFile(ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR); >+ if (file.exists()) { >+ PluginXMLEmptyReporter reporter = new PluginXMLEmptyReporter(file); >+ DefaultSAXParser.parse(file, reporter); >+ reporter.validateContent(monitor); >+ return reporter.hasExtensions(); >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Class to quickly scan plugin.xml for extensions or extension points >+ * Does no do any actual error or warning reporting, just uses the XMLErrorReporter to >+ * get its built-in fast SAX parsing. >+ ***/ >+ >+ static class PluginXMLEmptyReporter extends XMLErrorReporter { >+ >+ boolean fHasExtentions = false; >+ >+ public PluginXMLEmptyReporter(IFile file) { >+ super(file); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.builders.XMLErrorReporter#removeFileMarkers() >+ */ >+ protected void removeFileMarkers() { >+ // noop - we are just checking for content in another file so should not clear other file markers. >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.builders.XMLErrorReporter#validateContent(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public void validateContent(IProgressMonitor monitor) { >+ Element element = getDocumentRoot(); >+ if (element != null) { >+ String elementName = element.getNodeName(); >+ if ("plugin".equals(elementName) || "fragment".equals(elementName)) { //$NON-NLS-1$ //$NON-NLS-2$ >+ NodeList children = element.getChildNodes(); >+ for (int i = 0; i < children.getLength(); i++) { >+ if (monitor.isCanceled()) >+ break; >+ Element child = (Element) children.item(i); >+ String name = child.getNodeName(); >+ if (name.equals("extension")) { //$NON-NLS-1$ >+ fHasExtentions = true; >+ break; >+ } else if (name.equals("extension-point")) { //$NON-NLS-1$ >+ fHasExtentions = true; >+ break; >+ } >+ } >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.builders.XMLErrorReporter#characters(char[], int, int) >+ */ >+ public void characters(char[] characters, int start, int length) throws SAXException { >+ // Have to override this to avoid classcast exception on casting DOM nodes. >+ } >+ >+ /** >+ * @return whether the validated plugin.xml file has any extensions or extension points >+ */ >+ public boolean hasExtensions() { >+ return fHasExtentions; >+ } >+ >+ } > } >\ No newline at end of file >Index: src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java,v >retrieving revision 1.13 >diff -u -r1.13 XMLErrorReporter.java >--- src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java 2 Jan 2008 15:56:21 -0000 1.13 >+++ src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java 12 May 2008 21:36:53 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 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,38 +12,19 @@ > package org.eclipse.pde.internal.core.builders; > > import java.io.StringReader; >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.Stack; >- >+import java.util.*; > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; >- >-import org.eclipse.core.filebuffers.FileBuffers; >-import org.eclipse.core.filebuffers.ITextFileBufferManager; >-import org.eclipse.core.filebuffers.LocationKind; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IMarker; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >+import org.eclipse.core.filebuffers.*; >+import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.jface.text.BadLocationException; >-import org.eclipse.jface.text.FindReplaceDocumentAdapter; >-import org.eclipse.jface.text.IDocument; >-import org.eclipse.jface.text.IRegion; >-import org.eclipse.jface.text.Position; >+import org.eclipse.jface.text.*; > import org.eclipse.pde.internal.core.PDECore; > import org.eclipse.pde.internal.core.PDECoreMessages; >+import org.w3c.dom.*; > import org.w3c.dom.Document; >-import org.w3c.dom.Element; >-import org.w3c.dom.Node; >-import org.w3c.dom.Text; >-import org.xml.sax.Attributes; >-import org.xml.sax.InputSource; >-import org.xml.sax.Locator; >-import org.xml.sax.SAXException; >-import org.xml.sax.SAXParseException; >+import org.xml.sax.*; > import org.xml.sax.helpers.DefaultHandler; > > public class XMLErrorReporter extends DefaultHandler { >@@ -149,7 +130,7 @@ > return fErrorCount; > } > >- private void removeFileMarkers() { >+ protected void removeFileMarkers() { > try { > fFile.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO); > fFile.deleteMarkers(PDEMarkerFactory.MARKER_ID, false, IResource.DEPTH_ZERO);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 228887
:
99437
|
99438
|
99636
| 99830 |
99831