Bug 515526 - PHP syntax check reports errors when it should not
Summary: PHP syntax check reports errors when it should not
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Thierry BLIND CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 454847
Blocks:
  Show dependency tree
 
Reported: 2017-04-20 11:23 EDT by Thierry BLIND CLA
Modified: 2020-05-14 10:16 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry BLIND CLA 2017-04-20 11:23:19 EDT
Hi,
now that all patches for Bug 514748 are merged, I'm opening a separate bug report to fix glitches seen while testing https://git.eclipse.org/r/#/c/94800/

Steps to reproduce :
- create a new php file in a new php project
- copy&paste php content of file errors/php54/testUseStatementUsage04.pdtt in the new php file
- try some undo-redo using ctrl-z/ctrl-y to delete/re-add copied text, in some cases you will have "cannot be resolved" errors reported, sometimes none

It's due to the fact that the ValidatorBuildParticipantFactory works on an obsolete DLTK indexed source module. Why?
Because ValidatorBuildParticipantFactory calls ValidatorVisitor BEFORE the source module was reconciled by PhpReconcilingStrategy (using unit.reconcile()).

PhpReconcilingStrategy and ValidatorVisitor are called asynchronously and the unit.reconcile() call is much slower than the ValidatorVisitor call, so ValidatorVisitor has few chance to be called with an up-to-date source module.

It's also funny to see that when we click around with the mouse in the eclipse UI (somewhere outside the opened php editors -to hide text cursor- and then inside again -to show text cursor again-), or when we toggle between opened php editors, the glitches vanish because ValidatorBuildParticipantFactory is called again, but this time on a up-to-date reconciled source module.

Somehow we should call ValidatorVisitor only after unit.reconcile() has finished, so any suggestions to do that are welcome!

Thierry.
Comment 1 Dawid Pakula CLA 2017-04-24 20:31:43 EDT
Same problems I had in PEX validators. My idea from past:

1. Introduce class loader type into project metadata, bug 472758
2. Auto create correct class loader types for composer projects
3. Introduce PSR validator (bug 381650). With class loader type should be simple
4. During validation don't use index when possible, but search class via class loader implementation. Today most php project is based on PSR-0 or PSR-4 classloaders. In this case, searching for declaration will be relatively simple.
5. Finally we will need bug 424750, so after structure change (rename method, namespace etc...) all references will be re-validated.

Ideally if we could order index request, and index vendors (libs) and phars before standard buildpaths.
Comment 2 Thierry BLIND CLA 2017-04-25 05:19:26 EDT
If I understand well, the idea is to find&cache classes based on class loaders, and this in parallel of the DLTK indexer?
Comment 3 Dawid Pakula CLA 2017-04-25 07:00:56 EDT
In this case cache isn't necessary, because for PSR-0/4 class loaders we can walk over existing model directly (like between) categories.

Off course we can also modify DLTK API to allow control indexing during build process. Except build participant, this will not affect PDT code, but require changes in DLTK Indexing API.
Comment 4 Thierry BLIND CLA 2017-04-25 09:19:05 EDT
I would clearly prefer changing the DLTK Indexing API, because I always feel a bit scared when you have more than one way to retrieve a given information and that those informations are not centralized and synchronized ;) 
The biggest problem for me (except the unit.reconcile() slowness) is that models and TI informations are not synchronized together.
It would be nice to have easy notifications when the indexer updated a given model, so model validation would only trigger at this point.

Hope I was clear ;)
Comment 5 Eclipse Genie CLA 2017-05-03 02:10:15 EDT
New Gerrit change created: https://git.eclipse.org/r/96253
Comment 7 Eclipse Genie CLA 2017-06-08 11:16:24 EDT
New Gerrit change created: https://git.eclipse.org/r/98925
Comment 8 Thierry BLIND CLA 2017-06-08 11:21:24 EDT
Second patch is just to remove some (now) useless IPHPScriptReconcilingListener.
Comment 9 Eclipse Genie CLA 2017-06-12 03:58:48 EDT
New Gerrit change created: https://git.eclipse.org/r/99102
Comment 10 Thierry BLIND CLA 2017-06-22 06:08:30 EDT
See also related bug 518128 and bug 518410.
Comment 11 Eclipse Genie CLA 2017-06-23 08:01:50 EDT
New Gerrit change created: https://git.eclipse.org/r/99953
Comment 13 Eclipse Genie CLA 2017-06-24 19:36:25 EDT
New Gerrit change created: https://git.eclipse.org/r/99999