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 104371 Details for
Bug 234023
Tag scanner does not respect source level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated patch 2
234023_3.patch (text/plain), 16.77 KB, created by
Michael Rennie
on 2008-06-10 15:11:05 EDT
(
hide
)
Description:
updated patch 2
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2008-06-10 15:11:05 EDT
Size:
16.77 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.api.tools.tests >Index: src/org/eclipse/pde/api/tools/model/tests/TagScannerTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/TagScannerTests.java,v >retrieving revision 1.10 >diff -u -r1.10 TagScannerTests.java >--- src/org/eclipse/pde/api/tools/model/tests/TagScannerTests.java 8 Apr 2008 20:06:42 -0000 1.10 >+++ src/org/eclipse/pde/api/tools/model/tests/TagScannerTests.java 10 Jun 2008 19:10:18 -0000 >@@ -79,7 +79,7 @@ > */ > protected void doScan(String name, IApiDescription manifest, IClassFileContainer cfc) { > try { >- TagScanner.newScanner().scan(getCompilationUnit(name), manifest, cfc); >+ TagScanner.newScanner().scan(getCompilationUnit(name), manifest, cfc, null); > } > catch(CoreException e) { > fail(MessageFormat.format("Error scanning: {0}", new String[] {name})); >@@ -93,7 +93,7 @@ > */ > protected void doScan(String name, IApiDescription manifest) { > try { >- TagScanner.newScanner().scan(getCompilationUnit(name), manifest, null); >+ TagScanner.newScanner().scan(getCompilationUnit(name), manifest, null, null); > } > catch(CoreException e) { > fail(MessageFormat.format("Error scanning: {0}", new String[] {name})); >@@ -152,7 +152,7 @@ > }; > IApiDescription manifest = newDescription(); > try { >- TagScanner.newScanner().scan(getCompilationUnit("a/b/c/TestMethod10.java"), manifest, container); >+ TagScanner.newScanner().scan(getCompilationUnit("a/b/c/TestMethod10.java"), manifest, container, null); > } catch (CoreException e) { > return; > } >#P org.eclipse.pde.api.tools >Index: src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiFileGeneratorTask.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiFileGeneratorTask.java,v >retrieving revision 1.3 >diff -u -r1.3 ApiFileGeneratorTask.java >--- src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiFileGeneratorTask.java 26 May 2008 16:38:05 -0000 1.3 >+++ src_ant/org/eclipse/pde/api/tools/internal/tasks/ApiFileGeneratorTask.java 10 Jun 2008 19:10:21 -0000 >@@ -30,6 +30,7 @@ > import org.apache.tools.ant.BuildException; > import org.apache.tools.ant.Task; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.JavaCore; > import org.eclipse.osgi.util.ManifestElement; > import org.eclipse.pde.api.tools.internal.ApiDescription; > import org.eclipse.pde.api.tools.internal.ApiSettingsXmlVisitor; >@@ -40,6 +41,7 @@ > import org.eclipse.pde.api.tools.internal.provisional.scanner.TagScanner; > import org.eclipse.pde.api.tools.internal.util.Util; > import org.osgi.framework.BundleException; >+import org.osgi.framework.Constants; > import org.xml.sax.Attributes; > import org.xml.sax.InputSource; > import org.xml.sax.SAXException; >@@ -158,6 +160,35 @@ > return (path.isFile() && Util.isJavaFileName(path.getName())) || path.isDirectory(); > } > }); >+ File manifestFile = null; >+ Map manifestMap = null; >+ if (targetProjectFolder.exists() && targetProjectFolder.isDirectory()) { >+ File manifestDir = new File(targetProjectFolder, "META-INF"); //$NON-NLS-1$ >+ if (manifestDir.exists() && manifestDir.isDirectory()) { >+ manifestFile = new File(manifestDir, "MANIFEST.MF"); //$NON-NLS-1$ >+ } >+ if (manifestFile.exists()) { >+ BufferedInputStream inputStream = null; >+ try { >+ inputStream = new BufferedInputStream(new FileInputStream(manifestFile)); >+ manifestMap = ManifestElement.parseBundleManifest(inputStream, null); >+ } catch (FileNotFoundException e) { >+ ApiPlugin.log(e); >+ } catch (IOException e) { >+ ApiPlugin.log(e); >+ } catch (BundleException e) { >+ ApiPlugin.log(e); >+ } finally { >+ if (inputStream != null) { >+ try { >+ inputStream.close(); >+ } catch(IOException e) { >+ // ignore >+ } >+ } >+ } >+ } >+ } > ApiDescription apiDescription = new ApiDescription(this.projectName); > TagScanner tagScanner = TagScanner.newScanner(); > if (allFiles != null) { >@@ -167,7 +198,11 @@ > System.out.println("Unit name[" + i + "] : " + unit.getName()); //$NON-NLS-1$ //$NON-NLS-2$ > } > try { >- tagScanner.scan(unit, apiDescription, classFileContainer); >+ //default to highest, since we have no EE context >+ //TODO should use EE context to resolve a compliance level >+ Map options = JavaCore.getOptions(); >+ options.put(JavaCore.COMPILER_COMPLIANCE, resolveCompliance(manifestMap)); >+ tagScanner.scan(unit, apiDescription, classFileContainer, options); > } catch (CoreException e) { > ApiPlugin.log(e); > } >@@ -176,75 +211,47 @@ > // check the manifest file > String componentName = this.projectName; > String componentID = this.projectName; >- if (targetProjectFolder.exists() && targetProjectFolder.isDirectory()) { >- File manifestDir = new File(targetProjectFolder, "META-INF"); //$NON-NLS-1$ >- if (manifestDir.exists() && manifestDir.isDirectory()) { >- File manifestFile = new File(manifestDir, "MANIFEST.MF"); //$NON-NLS-1$ >- if (manifestFile.exists()) { >- BufferedInputStream inputStream = null; >- Map manifestMap = null; >- try { >- inputStream = new BufferedInputStream(new FileInputStream(manifestFile)); >- manifestMap = ManifestElement.parseBundleManifest(inputStream, null); >- } catch (FileNotFoundException e) { >- ApiPlugin.log(e); >- } catch (IOException e) { >- ApiPlugin.log(e); >- } catch (BundleException e) { >- ApiPlugin.log(e); >- } finally { >- if (inputStream != null) { >- try { >- inputStream.close(); >- } catch(IOException e) { >- // ignore >- } >- } >- } >- if (manifestMap != null && DEBUG) { >- for (Iterator iterator = manifestMap.keySet().iterator(); iterator.hasNext(); ) { >- Object key = iterator.next(); >- System.out.print("key = " + key); //$NON-NLS-1$ >- System.out.println(" value = " + manifestMap.get(key)); //$NON-NLS-1$ >- } >- } >- String localization = (String) manifestMap.get(org.osgi.framework.Constants.BUNDLE_LOCALIZATION); >- String name = (String) manifestMap.get(org.osgi.framework.Constants.BUNDLE_NAME); >- String nameKey = (name != null && name.startsWith("%")) ? name.substring(1) : null; //$NON-NLS-1$; >- if (nameKey != null) { >- Properties properties = new Properties(); >- inputStream = null; >+ if (manifestMap != null && DEBUG) { >+ for (Iterator iterator = manifestMap.keySet().iterator(); iterator.hasNext(); ) { >+ Object key = iterator.next(); >+ System.out.print("key = " + key); //$NON-NLS-1$ >+ System.out.println(" value = " + manifestMap.get(key)); //$NON-NLS-1$ >+ } >+ String localization = (String) manifestMap.get(org.osgi.framework.Constants.BUNDLE_LOCALIZATION); >+ String name = (String) manifestMap.get(org.osgi.framework.Constants.BUNDLE_NAME); >+ String nameKey = (name != null && name.startsWith("%")) ? name.substring(1) : null; //$NON-NLS-1$; >+ if (nameKey != null) { >+ Properties properties = new Properties(); >+ BufferedInputStream inputStream = null; >+ try { >+ inputStream = new BufferedInputStream(new FileInputStream(new File(targetProjectFolder, localization + ".properties"))); //$NON-NLS-1$ >+ properties.load(inputStream); >+ } catch(IOException e) { >+ ApiPlugin.log(e); >+ } finally { >+ if (inputStream != null) { > try { >- inputStream = new BufferedInputStream(new FileInputStream(new File(targetProjectFolder, localization + ".properties"))); //$NON-NLS-1$ >- properties.load(inputStream); >+ inputStream.close(); > } catch(IOException e) { >- ApiPlugin.log(e); >- } finally { >- if (inputStream != null) { >- try { >- inputStream.close(); >- } catch(IOException e) { >- // ignore >- } >- } >- } >- String property = properties.getProperty(nameKey); >- if (property != null) { >- componentName = property.trim(); >- } >- } else { >- componentName = name; >- } >- String symbolicName = (String) manifestMap.get(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME); >- if (symbolicName != null) { >- int indexOf = symbolicName.indexOf(';'); >- if (indexOf == -1) { >- componentID = symbolicName.trim(); >- } else { >- componentID = symbolicName.substring(0, indexOf).trim(); >+ // ignore > } > } > } >+ String property = properties.getProperty(nameKey); >+ if (property != null) { >+ componentName = property.trim(); >+ } >+ } else { >+ componentName = name; >+ } >+ String symbolicName = (String) manifestMap.get(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME); >+ if (symbolicName != null) { >+ int indexOf = symbolicName.indexOf(';'); >+ if (indexOf == -1) { >+ componentID = symbolicName.trim(); >+ } else { >+ componentID = symbolicName.substring(0, indexOf).trim(); >+ } > } > } > try { >@@ -260,6 +267,36 @@ > } > } > >+ /** >+ * Resolves the compiler compliance based on the BREE entry in the MANIFEST.MF file >+ * @param manifestmap >+ * @return The derived {@link JavaCore#COMPILER_COMPLIANCE} from the BREE in the manifest map, >+ * or {@link JavaCore#VERSION_1_3} if there is no BREE entry in the map or if the BREE entry does not directly map >+ * to one of {"1.3", "1.4", "1.5", "1.6"}. >+ */ >+ private String resolveCompliance(Map manifestmap) { >+ if(manifestmap != null) { >+ String eename = (String) manifestmap.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT); >+ if(eename != null) { >+ if("J2SE-1.4".equals(eename)) { //$NON-NLS-1$ >+ return JavaCore.VERSION_1_4; >+ } >+ if("J2SE-1.5".equals(eename)) { //$NON-NLS-1$ >+ return JavaCore.VERSION_1_5; >+ } >+ if("JavaSE-1.6".equals(eename)) { //$NON-NLS-1$ >+ return JavaCore.VERSION_1_6; >+ } >+ } >+ } >+ return JavaCore.VERSION_1_3; >+ } >+ >+ /** >+ * Resolves if the '.project' file belongs to an API enabled project or not >+ * @param dotProjectFile >+ * @return true if the '.project' file is for an API enabled project, false otherwise >+ */ > private boolean isAPIToolsNature(File dotProjectFile) { > if (!dotProjectFile.exists()) return false; > BufferedInputStream stream = null; >Index: src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java,v >retrieving revision 1.12 >diff -u -r1.12 TagScanner.java >--- src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java 7 May 2008 15:53:16 -0000 1.12 >+++ src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java 10 Jun 2008 19:10:21 -0000 >@@ -24,6 +24,7 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.dom.AST; >@@ -461,7 +462,7 @@ > private TagScanner() {} > > /** >- * Scans the specified source {@linkplain CompilationUnit} for contributed API javadoc tags. >+ * Scans the specified source {@linkplain CompilationUnit} for contributed API Javadoc tags. > * Tags on methods will have unresolved signatures. > * > * @param source the source file to scan for tags >@@ -469,20 +470,37 @@ > * @throws CoreException > */ > public void scan(CompilationUnit source, IApiDescription description) throws CoreException { >- scan(source, description, null); >+ scan(source, description, null, null); >+ } >+ >+ /** >+ * Scans the specified {@link ICompilationUnit} for contributed API Javadoc tags. >+ * Tags on methods will have unresolved signatures. >+ * @param unit the compilation unit source >+ * @param description the API description to annotate with any new tag rules found >+ * @param container optional class file container containing the class file for the given source >+ * that can be used to resolve method signatures if required (for tags on methods). If >+ * not provided (<code>null</code>), method signatures will be unresolved. >+ * @throws CoreException >+ */ >+ public void scan(ICompilationUnit unit, IApiDescription description, IClassFileContainer container) throws CoreException { >+ scan(new CompilationUnit(unit), description, container, unit.getJavaProject().getOptions(true)); > } > > /** > * Scans the specified source {@linkplain CompilationUnit} for contributed API javadoc tags. >+ * Tags on methods will have unresolved signatures. > * > * @param source the source file to scan for tags > * @param description the API description to annotate with any new tag rules found > * @param container optional class file container containing the class file for the given source > * that can be used to resolve method signatures if required (for tags on methods). If > * not provided (<code>null</code>), method signatures will be unresolved. >+ * @param options a map of Java compiler options to use when creating the AST to scan >+ * > * @throws CoreException > */ >- public void scan(CompilationUnit source, IApiDescription description, IClassFileContainer container) throws CoreException { >+ public void scan(CompilationUnit source, IApiDescription description, IClassFileContainer container, Map options) throws CoreException { > ASTParser parser = ASTParser.newParser(AST.JLS3); > InputStream inputStream = null; > try { >@@ -506,7 +524,9 @@ > } > } > } >- Map options = JavaCore.getOptions(); >+ if(options == null) { >+ options = JavaCore.getOptions(); >+ } > options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); > parser.setCompilerOptions(options); > org.eclipse.jdt.core.dom.CompilationUnit cunit = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(new NullProgressMonitor()); >Index: src/org/eclipse/pde/api/tools/internal/PluginProjectApiComponent.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/PluginProjectApiComponent.java,v >retrieving revision 1.29 >diff -u -r1.29 PluginProjectApiComponent.java >--- src/org/eclipse/pde/api/tools/internal/PluginProjectApiComponent.java 22 May 2008 16:09:46 -0000 1.29 >+++ src/org/eclipse/pde/api/tools/internal/PluginProjectApiComponent.java 10 Jun 2008 19:10:21 -0000 >@@ -196,18 +196,16 @@ > } > TagScanner scanner = TagScanner.newScanner(); > Iterator iterator = sourceRoots.iterator(); >+ ICompilationUnit[] units = null; >+ IJavaElement[] pkgs = null; > while (iterator.hasNext()) { >- IPackageFragmentRoot root = (IPackageFragmentRoot) iterator.next(); >- IJavaElement[] pkgs = root.getChildren(); >+ pkgs = ((IPackageFragmentRoot) iterator.next()).getChildren(); > for (int i = 0; i < pkgs.length; i++) { > if (pkgs[i] instanceof IPackageFragment) { >- IPackageFragment pkg = (IPackageFragment) pkgs[i]; >- ICompilationUnit[] units = pkg.getCompilationUnits(); >+ units = ((IPackageFragment) pkgs[i]).getCompilationUnits(); > for (int j = 0; j < units.length; j++) { >- ICompilationUnit unit = units[j]; >- CompilationUnit cu = new CompilationUnit(unit.getResource().getLocation().toOSString()); > try { >- scanner.scan(cu, apiDescription, this); >+ scanner.scan(units[j], apiDescription, this); > } catch (CoreException e) { > abort("Unable to initialize from Javadoc tags", e); //$NON-NLS-1$ > } >Index: src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java,v >retrieving revision 1.21 >diff -u -r1.21 ProjectApiDescription.java >--- src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java 27 May 2008 15:42:23 -0000 1.21 >+++ src/org/eclipse/pde/api/tools/internal/ProjectApiDescription.java 10 Jun 2008 19:10:21 -0000 >@@ -227,7 +227,7 @@ > restrictions = RestrictionModifiers.NO_RESTRICTIONS; > fTimeStamp = resource.getModificationStamp(); > try { >- TagScanner.newScanner().scan(new CompilationUnit(unit), ProjectApiDescription.this, >+ TagScanner.newScanner().scan(unit, ProjectApiDescription.this, > getClassFileContainer((IPackageFragmentRoot) fType.getPackageFragment().getParent())); > } catch (CoreException e) { > ApiPlugin.log(e.getStatus());
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 234023
:
102084
|
104190
| 104371