Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Issue 2610063004: Add ContentCache.getExists() and use it in AnalysisContextImpl.exists(). (Closed)

Created:
3 years, 11 months ago by scheglov
Modified:
3 years, 11 months ago
CC:
reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add ContentCache.getExists() and use it in AnalysisContextImpl.exists(). This allows us to avoid direct Source IO and be able to make analysis in an AnalysisContext hermetic. R=brianwilkerson@google.com, paulberry@google.com BUG= Committed: https://github.com/dart-lang/sdk/commit/9619a9f1570988ef6774658e627c9119331a336e

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -2 lines) Patch
M pkg/analyzer/lib/src/context/context.dart View 1 chunk +3 lines, -2 lines 1 comment Download
M pkg/analyzer/lib/src/generated/source.dart View 1 chunk +11 lines, -0 lines 3 comments Download

Messages

Total messages: 7 (1 generated)
scheglov
3 years, 11 months ago (2017-01-04 18:02:01 UTC) #1
Brian Wilkerson
lgtm https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/generated/source.dart File pkg/analyzer/lib/src/generated/source.dart (right): https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/generated/source.dart#newcode76 pkg/analyzer/lib/src/generated/source.dart:76: return _contentMap.containsKey(source.fullName) ? true : null; Did you ...
3 years, 11 months ago (2017-01-04 18:05:10 UTC) #2
Paul Berry
https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/context/context.dart File pkg/analyzer/lib/src/context/context.dart (right): https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/context/context.dart#newcode814 pkg/analyzer/lib/src/context/context.dart:814: if (overriddenExists != null) { Assuming you accept my ...
3 years, 11 months ago (2017-01-04 18:28:58 UTC) #3
scheglov
https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/generated/source.dart File pkg/analyzer/lib/src/generated/source.dart (right): https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/generated/source.dart#newcode70 pkg/analyzer/lib/src/generated/source.dart:70: * or `null` if this cache does not override ...
3 years, 11 months ago (2017-01-04 20:07:27 UTC) #4
scheglov
Committed patchset #1 (id:1) manually as 9619a9f1570988ef6774658e627c9119331a336e (presubmit successful).
3 years, 11 months ago (2017-01-04 20:31:52 UTC) #6
Paul Berry
3 years, 11 months ago (2017-01-04 20:33:01 UTC) #7
Message was sent while issue was closed.
On 2017/01/04 20:07:27, scheglov wrote:
>
https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/genera...
> File pkg/analyzer/lib/src/generated/source.dart (right):
> 
>
https://codereview.chromium.org/2610063004/diff/1/pkg/analyzer/lib/src/genera...
> pkg/analyzer/lib/src/generated/source.dart:70: * or `null` if this cache does
> not override existence of the source.
> On 2017/01/04 18:28:57, Paul Berry wrote:
> > It looks like you are trying to plan ahead to a possible future where we
might
> > want the content cache to be able to represent a deletion (i.e. the source
> > actually exists on disk but the content cache wants to pretend it doesn't). 
> But
> > this possible future doesn't exist yet (which is why the code below always
> > returns either `true` or `null`.
> > 
> > I find this really confusing, and it's hard to test well because we can't
> easily
> > write unit tests to exercise a feature that doesn't exist yet.
> > 
> > My recommendation: change this code so that it returns `true` if the given
> > source is overridden in the content cache, and `false` if it is not
> overridden. 
> > Then the implementation just becomes `return
> > _contentMap.containsKey(source.fullName);` and the caller can be changed the
> way
> > I mentioned earlier.
> 
> I'm trying to extend ContentCache to fully control AnalysisContext's view of
the
> world.
> So, we can provide a view of the world in the new analysis driver.
> We don't want an AnalysisContext to talk to any Source directly.
> So, we cannot do contentCache.getExists() || source.exists().
> 
> We already have this model for getContents() - it returns a value, or null as
"I
> don't know".

Ok, I see.  I'm not thrilled with the idea of using `null` to turn a boolean
into a tri-state, but I see how it's nice to have a parallel between
contentCache.getExists() and contentCache.getContents().

But since it sounds like you're going to follow up soon with a change to the
content cache where most of the time (always?) it returns either `true` or
`false` I'm a lot less worried.

lgtm.

Powered by Google App Engine
This is Rietveld 408576698