Skip to content

Instantly share code, notes, and snippets.

@carchrae
Created May 21, 2013 14:56
Show Gist options
  • Save carchrae/5620444 to your computer and use it in GitHub Desktop.
Save carchrae/5620444 to your computer and use it in GitHub Desktop.
03:09:02 PM - atomatom: is it possible to: a) watch a directory of files to determine if a generator should be re-run (eg, say a generator that includes all files in a directory) or b) force it to re-generate the Impl code each time?
03:10:34 PM - icfantv has left the room (Quit: Leaving.).
03:11:28 PM - stefan_ [~stefan@89.204.155.184] entered the room.
03:13:25 PM - Twiner [~Twiner@c-75-68-119-219.hsd1.nh.comcast.net] entered the room.
03:20:37 PM - xjrn: if intellij is any lesson, the file-watcher is platform specific
03:21:19 PM - xjrn: but then roo seems to do what you're saying without an exe
03:21:29 PM - xjrn: with glitches
03:27:44 PM - atomatom: thanks xjrn - yeah, i'm thinking being too automatic is going to get frustrating
03:29:36 PM - xjrn: once roo derails, it stays down
03:31:10 PM - atomatom: btw, i'm not using roo/intellij, just eclipse + gwt's incremental compilation
03:31:31 PM - niloc132: atomatom: there incremental generator is supposed to give you those hints
03:31:56 PM - niloc132: but you have to prime it, based on what you know about the generator's dependencies i think
03:32:08 PM - niloc132: been a while since i looked at that, and haven't ported anything to use it yet
03:33:54 PM - atomatom: i dug through a lot of code and couldn't find any specific examples of how to 'prime it' - and unfortunately most of the generator code is pretty cryptic. annoyingly, it seemed to work yesterday, but today i had to change classnames to force it
03:34:38 PM - atomatom: no worries, i was mostly just wondering if anyone had/knew of a generator that watched/included a directory instead of just a file
03:35:09 PM - atomatom: *directory=all the files in a directory
03:40:48 PM - niloc132: IncrementalGenerator (in 2.5.1) is the starting point, and you return the rebind result full of stuff
03:41:05 PM - niloc132: you get to wire up what 'stuff' defines in terms of differences, and you can check it when you get called from the context
03:41:50 PM - niloc132: com.google.gwt.core.ext.GeneratorContext#isGeneratorResultCachingEnabled and com.google.gwt.core.ext.GeneratorContext#getCachedGeneratorResult
03:42:37 PM - niloc132: since these only run when you refresh, you don't wait to be told of changes, you check when you are rebuilding
03:43:59 PM - niloc132: looks like (from the rpc generator code, ProxyCreator.create around 397) that you can stack whatever you want in there
03:44:00 PM - atomatom: niloc132: thanks, just looking at IncrementalGenerator now. i can see how it wraps all non incremental generators
03:45:06 PM - niloc132: at 328, com.google.gwt.user.rebind.rpc.ProxyCreator#checkCachedGeneratorResultValid does the check "did i already do this?"
03:45:19 PM - niloc132: yeah - that is different than 2.4 which is when i last read this
03:45:48 PM - cbrock [~cbrock@redhat/jboss/cbrock] entered the room.
03:45:58 PM - niloc132: com.google.gwt.user.rebind.rpc.CachedRpcTypeInformation#checkTypeInformation looks like it actually walks the differences
03:46:05 PM - niloc132: rpc is really extensive though on this check
03:46:18 PM - niloc132: it needs to see if any type that might go over the wire changes, transitively
03:46:33 PM - niloc132: start at rpc interfaces, and walk all reachable types
03:46:40 PM - niloc132: hopefully yours isn't that bad ;)
03:49:48 PM - niloc132: com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator#generateIncrementally seems a lot more readable, and probably closer to 'normal'
03:51:09 PM - atomatom: i think i got it
03:51:20 PM - atomatom: yeah, i tried to go through abstractclientbundle....
03:51:26 PM - atomatom: it looks a lot like what i wanted
03:51:38 PM - atomatom: but... i don't think it can pick up new files
03:51:54 PM - atomatom: what i am doing: scanning a package for template files and loading them
03:51:56 PM - niloc132: resource oracle should have access to any file in the sourcepath
03:52:21 PM - atomatom: yep, it's all working, it just was not regenerating, say, when i added a new file
03:52:24 PM - niloc132: and you can always grab the classloader and try grabbing other resources
03:52:40 PM - niloc132: oh, so it is seeing the *old* file? that doesnt seem right at all
03:52:46 PM - atomatom: i just extended the IncrementalGenerator and return return new RebindResult(RebindMode.USE_ALL_NEW_WITH_NO_CACHING, name)
03:52:52 PM - niloc132: heh
03:53:19 PM - niloc132: think though of how cssresource generation has to work - we need to start with the css files, mangle them a bit, emit java
03:53:25 PM - atomatom: well, at first, i was injecting the templates myself, then i realized this was a bit dumb, and created TextResources for the existing files
03:53:29 PM - niloc132: then have the user tweak them and have the generator do it again
03:53:53 PM - atomatom: so, i switched to reuse the textresource in my generated code
03:54:48 PM - atomatom: seems good now. if i have some more time i might dig deeper to see if i can find something more efficient than USE_ALL_NEW_WITH_NO_CACHING - but this is not takign a long time
03:55:09 PM - atomatom: thanks for taking the time to point me in the right direction
03:55:24 PM - niloc132: yeah - i'll let you know if i ever get to cachify my own generators
03:55:32 PM - niloc132: probably this summer sometime :p
03:56:01 PM - atomatom: USE_PARTIAL_CACHED seems the way
03:56:11 PM - atomatom: but then i'd need to get my head fully aroudn the context
03:57:06 PM - atomatom: DelegatingGeneratorContext seems a place to go
03:57:24 PM - atomatom: anyway, i'm done with this for today. need to make some actual progress. ;) thanks again
03:58:04 PM - niloc132: 'need to make actual progress' yeah, that's my day too so far
03:58:20 PM - atomatom: hmm - yeah - tryReuseTypeFromCache - where it scans the dir for changes would be it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment