Bug 475862 - Make working copy API more flexible
Summary: Make working copy API more flexible
Status: RESOLVED FIXED
Alias: None
Product: Handly
Classification: Technology
Component: Core (show other bugs)
Version: 0.4   Edit
Hardware: All All
: P3 enhancement
Target Milestone: 0.4   Edit
Assignee: Vladimir Piskarev CLA
QA Contact:
URL:
Whiteboard: breakingchange
Keywords: api
Depends on: 473417
Blocks:
  Show dependency tree
 
Reported: 2015-08-26 03:20 EDT by Vladimir Piskarev CLA
Modified: 2015-09-22 05:03 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Piskarev CLA 2015-08-26 03:20:03 EDT
This is a generalization of bug 473417.

As a litmus test, can working copy API of the JDT Java model be implemented on top of Handly? Some things to consider:

* Private working copies (WorkingCopyOwner)

* Reconcile problem reporting (IProblemRequestor)

* Reconcile parameters (AST level, reconcile flags) and return value (AST)

The last item will be taken care of in bug 473417.
Comment 1 Vladimir Piskarev CLA 2015-08-27 10:24:32 EDT
Pushed to master:
http://git.eclipse.org/c/handly/org.eclipse.handly.git/commit/?id=7b355e78bc055d526f598dde33334fa6e2179014

Breaking change: SourceFile#becomeWorkingCopy now takes an IWorkingCopyInfoFactory (new interface) in addition to other parameters.
Comment 2 Vladimir Piskarev CLA 2015-08-27 10:28:04 EDT
A reference implementation in Java model example:
http://git.eclipse.org/c/handly/org.eclipse.handly.git/commit/?id=4cd8079750351d647a187a70d0d44bf3cc75e5a9

Demonstrates problem reporting and private working copy.
Comment 3 Vladimir Piskarev CLA 2015-08-28 02:11:02 EDT
Reopened because one of the added JUnit tests failed on Hundson. It had succeeded on my machine. The nature of the failure suggests it has to to with Java compiler settings for a test project and can probably be fixed by introducing project-specific settings for Errors/Warnings.
Comment 4 Eclipse Genie CLA 2015-08-28 02:16:55 EDT
New Gerrit change created: https://git.eclipse.org/r/54738
Comment 5 Vladimir Piskarev CLA 2015-08-28 03:43:02 EDT
No, actually it has do with JDT compiler version: the test fails on the "Latest Platform" (4.5) but succeeds on the "Base Platform" (3.8).

Line 5 in Test010/src/X.java ("syntaxError") results in 3 errors [Pb(240) Syntax error, insert "Identifier (" to complete MethodHeaderName, Pb(240) Syntax error, insert ")" to complete MethodDeclaration, Pb(240) Syntax error, insert ";" to complete MethodDeclaration] with 4.5 compiler, whereas 3.8 compiler reports only 1 error [Pb(232) Syntax error on token "syntaxError", delete this token].

As a workaround, the test should check that the list of problems is not empty instead of checking the size of the list. This would be fine for the intended assertion that "problems are reported to the given problem requestor".
Comment 7 Vladimir Piskarev CLA 2015-08-28 03:59:14 EDT
Fixed the failing test as detailed in comment 5.
Comment 8 Vladimir Piskarev CLA 2015-09-22 05:03:47 EDT
Further polish:
http://git.eclipse.org/c/handly/org.eclipse.handly.git/commit/?id=70d8b1824741205ac6724afc3f7f1b64e6ad7c4a

Note that there are now two overloads of SourceFile#becomeWorkingCopy: one that takes the factory argument and one the doesn't. The latter is binary compatible with the 0.3 version, but with a noticeable contract change: it now returns the WorkingCopyInfo previously associated with the source file and doesn't throw IllegalStateException if the buffers are different.