Bug 550188 - ApiAnalyzer flags false positive error due to extension point schema include
Summary: ApiAnalyzer flags false positive error due to extension point schema include
Status: NEW
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.13   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 547665
  Show dependency tree
 
Reported: 2019-08-19 02:49 EDT by Niko Stotz CLA
Modified: 2023-08-01 12:40 EDT (History)
2 users (show)

See Also:


Attachments
Example launch file to start API Analysis from IDE (8.14 KB, application/octet-stream)
2019-08-19 06:10 EDT, Mickael Istria CLA
no flags Details
Example launch config to reproduce the issue in the IDE (8.83 KB, application/octet-stream)
2019-08-19 08:55 EDT, Mickael Istria CLA
no flags Details
Target Platform to use with Launch Config to reproduce issue in IDE (476 bytes, text/x-systemd-unit)
2019-08-19 08:56 EDT, Mickael Istria CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niko Stotz CLA 2019-08-19 02:49:51 EDT
My reference case is in Eclipse Platform (https://ci-staging.eclipse.org/platform/job/eclipse.platform.text-Gerrit/2470/console).

Expected behavior: No validation error found.

Actual behavior:

12:48:22 * Marker [on: /org.eclipse.ui.workbench.texteditor/plugin.xml, id: 295, type: org.eclipse.pde.core.problem, attributes: [categoryId: fatal, compilerKey: compilers.p.unknown-element, lineNumber: 1384, message: Element 'with' is not legal as a child of element 'enabledWhen'., problemId: 12289, severity: 2, xmlTree.locationPath: (0)plugin>(16)extension>(0)codeMiningProvider>(0)enabledWhen>(0)with], created: 8/17/19 10:48 AM]

It complains about the <with> in the following part of plugin.xml
<extension 
point="org.eclipse.ui.workbench.texteditor.codeMiningProviders"> 
  <codeMiningProvider class="org.eclipse.ui.internal.texteditor.codemining.annotation.AnnotationCodeMiningProvider" id="org.eclipse.ui.workbench.texteditor.annotationCodeMiningProvider"> 
    <enabledWhen> 
      <with variable="editorInput"> 
        <adapt type="org.eclipse.core.resources.IFile"> 
          <test property="org.eclipse.core.resources.contentTypeId" value="org.eclipse.core.runtime.text" args="kindOf"> 
          </test> 
        </adapt> 
      </with> 
    </enabledWhen> 
  </codeMiningProvider> 
</extension> 

* The exact same snippet worked when I had it in org.eclipse.ui.genericeditor.
* The content is also picked up at runtime (i.e. it works).
* The issue is not present in the IDE.

The snipped adheres to the schema in the same plugin (schema/codeMiningProviders.exsd).
This schema defines the structure up to <enabledWhen> and refers the remaining part to an included schema:
<include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/> 

Our plug-in has a dependency on org.eclipse.core.expressions.
Comment 1 Mickael Istria CLA 2019-08-19 04:04:14 EDT
Here is the relevant stack
Thread [app thread - org.eclipse.pde.api.tools.apiAnalyzer.0] (Suspended (entry into method addMarkerAttribute in ManifestErrorReporter))	
	ExtensionsErrorReporter(ManifestErrorReporter).addMarkerAttribute(IncrementalErrorReporter$VirtualMarker, String, String) line: 196	
	ExtensionsErrorReporter(ManifestErrorReporter).reportIllegalElement(Element, int) line: 48	
	ExtensionsErrorReporter.validateElement(Element, ISchema, boolean) line: 229	
	ExtensionsErrorReporter.validateElement(Element, ISchema, boolean) line: 263	
	ExtensionsErrorReporter.validateElement(Element, ISchema, boolean) line: 263	
	ExtensionsErrorReporter.validateElement(Element, ISchema, boolean) line: 263	
	ExtensionsErrorReporter.validateExtension(Element) line: 167	
	ExtensionsErrorReporter.validate(IProgressMonitor) line: 125	
	ExtensionsErrorReporter(XMLErrorReporter).validateContent(IProgressMonitor) line: 400	
	ManifestConsistencyChecker.validateFiles(IFile, int, IProgressMonitor) line: 326	
	ManifestConsistencyChecker.validateProject(int, IProgressMonitor) line: 245	
	ManifestConsistencyChecker.build(int, Map<String,String>, IProgressMonitor) line: 177	
	BuildManager$2.run() line: 833	
	SafeRunner.run(ISafeRunnable) line: 45	
	BuildManager.basicBuild(int, IncrementalProjectBuilder, Map<String,String>, MultiStatus, IProgressMonitor) line: 220	
	BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, ICommand[], MultiStatus, IProgressMonitor) line: 263	
	BuildManager$1.run() line: 316	
	SafeRunner.run(ISafeRunnable) line: 45	
	BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, MultiStatus, IProgressMonitor) line: 319	
	BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, IProgressMonitor) line: 278	
	BuildManager.build(IBuildConfiguration, int, String, Map<String,String>, IProgressMonitor) line: 468	
	Project$1.run(IProgressMonitor) line: 566	
	Workspace.run(ICoreRunnable, ISchedulingRule, int, IProgressMonitor) line: 2295	
	Project.internalBuild(IBuildConfiguration, int, String, Map<String,String>, IProgressMonitor) line: 540	
	Project.build(int, IProgressMonitor) line: 116	
	ApiAnalysisApplication.start(IApplicationContext) line: 125	
	EclipseAppHandle.run(Object) line: 203	
	AnyThreadAppLauncher.run() line: 30	
	Thread.run() line: 834	

You can get it easily by
1. running a local build from org.eclipse.ui.workbench.texteditor (patched) `mvn clean verify -Pbuild-individual-bundles,api-check`
2. Copy the Java command of the API Analysis, and add the debug flags `-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=1044` just after java
3. Debug as remote Java app in the IDE.
Comment 2 Eclipse Genie CLA 2019-08-19 05:13:15 EDT
New Gerrit change created: https://git.eclipse.org/r/147904
Comment 3 Vikas Chandra CLA 2019-08-19 05:17:44 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/147904

With this change, API analysis (as the name suggests) would not call any other builders except API Analysis.

Michael, do you think this would still catch all the API analysis issues?
Comment 4 Vikas Chandra CLA 2019-08-19 05:21:48 EDT
>>IIRC, it's necessary to have the compilation running and some form of >>validation before invoking the API Builder. 

I think API builder would run on by itself and other compilation issues would be caught elsewhere.

However, if java builder is required for class file , I could add java builder + api analysis build. That should definitely work. ( in my opinion)
Comment 5 Mickael Istria CLA 2019-08-19 05:27:30 EDT
If you think your proposal should work, I trust you.
I don't have as deep knowledge of the API Tools as you do (my work was only about ochestrating it for build purpose)
I'm fine if you want to try it.

In the meantime, I found the cause of this specific message in Niko's patch. The reason is that the target platform doesn't include org.eclipse.core.expressions schemas; they're in the source bundle which is not included by default. As a result, the plugin validation fails.
I think this could be reproduced in a plain IDE which doesn't have the org.eclipse.core.expressions.source in its target platform.
Comment 6 Vikas Chandra CLA 2019-08-19 05:38:10 EDT
>>If you think your proposal 

Does the api.analysis task in gerrit build use the current eclipse's api.analysis task or previous I build's api analysis task.

If it uses the current build's api task then I could combine my change with a https://git.eclipse.org/r/#/c/147726/ to check if api analysis is NOT broken with this change.

If it uses previous I build's api analysis, then we have to wait for next I build to check if it works indeed.
Comment 7 Vikas Chandra CLA 2019-08-19 05:39:25 EDT
>> they're in the source bundle which is not included by default

More such inconsistencies will come in. I will recommend

1) Log this into another bug
2) Remove manifest builder and schema builder in api.analysis ( if possible)
Comment 8 Mickael Istria CLA 2019-08-19 05:48:29 EDT
(In reply to Vikas Chandra from comment #6)
> Does the api.analysis task in gerrit build use the current eclipse's
> api.analysis task or previous I build's api analysis task.

At the moment, it uses the baseline (last release) itself as both the runner and baseline: https://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/tree/eclipse-platform-parent/pom.xml#n1013
This could be changed to decorrelate runner (use latest I-Build) and baseline (use last release), but we'd need the build to generate a .target file describing the baseline, which isn't trivial (but still achievable).
Comment 9 Vikas Chandra CLA 2019-08-19 06:05:08 EDT
(In reply to Mickael Istria from comment #8)
> (In reply to Vikas Chandra from comment #6)
> > Does the api.analysis task in gerrit build use the current eclipse's
> > api.analysis task or previous I build's api analysis task.
> 
> At the moment, it uses the baseline (last release) itself as both the runner
> and baseline:
> https://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/
> tree/eclipse-platform-parent/pom.xml#n1013
> This could be changed to decorrelate runner (use latest I-Build) and
> baseline (use last release), but we'd need the build to generate a .target
> file describing the baseline, which isn't trivial (but still achievable).

Is there an easy way to check if https://git.eclipse.org/r/147904 would still ensure that api.analysis would report api analysis problems.

Can you try out a test case locally to see if api analysis works with this change?
Comment 10 Mickael Istria CLA 2019-08-19 06:10:46 EDT
Created attachment 279620 [details]
Example launch file to start API Analysis from IDE

> Is there an easy way to check if https://git.eclipse.org/r/147904 would still
ensure that api.analysis would report api analysis problems.

The attached launch file starts the API analysis from the IDE. You may be able to tweak it and see the change in action.
I'll also attach a .target file that can be used as a baseline instead of the default one.
Comment 11 Mickael Istria CLA 2019-08-19 08:55:59 EDT
Created attachment 279623 [details]
Example launch config to reproduce the issue in the IDE
Comment 12 Mickael Istria CLA 2019-08-19 08:56:36 EDT
Created attachment 279624 [details]
Target Platform to use with Launch Config to reproduce issue in IDE
Comment 13 Niko Stotz CLA 2019-08-19 09:12:01 EDT
I got a hint that Jenkins jobs are thrown away pretty quickly, thus the link from the initial issue doesn't work any more. It was a build of this gerrit: https://git.eclipse.org/r/#/c/142835/
Comment 14 Eclipse Genie CLA 2019-08-19 12:18:45 EDT
New Gerrit change created: https://git.eclipse.org/r/147936
Comment 15 Vikas Chandra CLA 2019-08-20 04:57:48 EDT
opened Bug 550250 for removing ManifestBuilder and Schemabuilder.

>In the meantime, I found the cause of this specific message in Niko's patch. >The reason is that the target platform doesn't include >org.eclipse.core.expressions schemas; they're in the source bundle which is not >included by default. As a result, the plugin validation fails.
>I think this could be reproduced in a plain IDE which doesn't have the >org.eclipse.core.expressions.source in its target platform.

I will investigate this via this bug
Comment 16 Eclipse Genie CLA 2021-08-10 08:45:57 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 17 Eclipse Genie CLA 2023-08-01 12:40:33 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.