Merge pull request #484 from twpayne/check-goog-requires

Check requires from Closure Library
This commit is contained in:
Tom Payne
2013-04-06 05:52:58 -07:00
77 changed files with 197 additions and 10 deletions

View File

@@ -383,8 +383,22 @@ def _strip_comments(lines):
@target('build/check-requires-timestamp', SRC, INTERNAL_SRC, EXTERNAL_SRC,
EXAMPLES_SRC, SHADER_SRC, SPEC)
def build_check_requires_timestamp(t):
from zipfile import ZipFile
unused_count = 0
all_provides = set()
zf = ZipFile(PLOVR_JAR)
for zi in zf.infolist():
if zi.filename.endswith('.js'):
if not zi.filename.startswith('closure/goog/'):
continue
# Skip goog.i18n because it contains so many modules that it causes
# the generated regular expression to exceed Python's limits
if zi.filename.startswith('closure/goog/i18n/'):
continue
for line in zf.open(zi):
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
if m:
all_provides.add(m.group(1))
for filename in sorted(t.dependencies):
if filename == 'build/src/internal/src/requireall.js':
continue
@@ -412,10 +426,46 @@ def build_check_requires_timestamp(t):
filename, require_linenos[require], require))
unused_count += 1
all_provides.discard('ol')
all_provides.discard('ol.Map')
all_provides.discard('ol.MapProperty')
provide_res = [(provide, re.compile(r'\b%s\b' % (re.escape(
provide)),)) for provide in sorted(all_provides, reverse=True)]
class Node(object):
def __init__(self):
self.present = False
self.children = {}
def _build_re(self, key):
if len(self.children) == 1:
child_key, child = next(self.children.iteritems())
child_re = '\\.' + child._build_re(child_key)
if self.present:
return key + '(' + child_re + ')?'
else:
return key + child_re
elif self.children:
children_re = '(?:\\.(?:' + '|'.join(
self.children[k]._build_re(k)
for k in sorted(self.children.keys())) + '))'
if self.present:
return key + children_re + '?'
else:
return key + children_re
else:
assert self.present
return key
def build_re(self, key):
return re.compile('\\b' + self._build_re(key) + '\\b')
root = Node()
for provide in all_provides:
node = root
for component in provide.split('.'):
if component not in node.children:
node.children[component] = Node()
node = node.children[component]
node.present = True
provide_res = [child.build_re(key)
for key, child in root.children.iteritems()]
missing_count = 0
for filename in sorted(t.dependencies):
if filename in INTERNAL_SRC or filename in EXTERNAL_SRC:
@@ -432,10 +482,15 @@ def build_check_requires_timestamp(t):
if m:
requires.add(m.group(1))
continue
for provide, provide_re in provide_res:
if provide_re.search(line):
line = line.replace(provide, '')
uses.add(provide)
while True:
for provide_re in provide_res:
m = provide_re.search(line)
if m:
uses.add(m.group())
line = line[:m.start()] + line[m.end():]
break
else:
break
if filename == 'src/ol/renderer/layerrenderer.js':
uses.discard('ol.renderer.Map')
m = re.match(

View File

@@ -1,6 +1,7 @@
goog.provide('ol.array');
goog.require('goog.array');
goog.require('goog.asserts');
/**

View File

@@ -3,6 +3,7 @@
goog.provide('ol.control.Attribution');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.object');

View File

@@ -2,8 +2,9 @@ goog.provide('ol.control.Control');
goog.provide('ol.control.ControlOptions');
goog.require('goog.Disposable');
goog.require('goog.array');
goog.require('goog.dom');
goog.require('goog.events');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');

View File

@@ -5,6 +5,7 @@ goog.provide('ol.control.MousePosition');
goog.require('goog.array');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.style');

View File

@@ -1,7 +1,11 @@
goog.provide('ol.control.ScaleLine');
goog.provide('ol.control.ScaleLineUnits');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.math');
goog.require('goog.style');
goog.require('ol.FrameState');
goog.require('ol.ProjectionUnits');

View File

@@ -4,11 +4,16 @@
goog.provide('ol.control.ZoomSlider');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.fx.Dragger');
goog.require('goog.fx.Dragger.EventType');
goog.require('goog.math');
goog.require('goog.math.Rect');
goog.require('goog.style');
goog.require('ol.control.Control');
goog.require('ol.css');

View File

@@ -4,6 +4,7 @@
goog.provide('ol.dom');
goog.provide('ol.dom.BrowserFeature');
goog.require('goog.asserts');
goog.require('goog.vec.Mat4');

View File

@@ -1,6 +1,8 @@
goog.provide('ol.dom.Input');
goog.provide('ol.dom.InputProperty');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.Object');

View File

@@ -4,6 +4,7 @@
goog.provide('ol.Geolocation');
goog.provide('ol.GeolocationProperty');
goog.require('goog.events');
goog.require('goog.functions');
goog.require('goog.math');
goog.require('ol.Coordinate');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.geom.GeometryCollection');
goog.require('goog.asserts');
goog.require('ol.geom.AbstractCollection');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryType');

View File

@@ -2,9 +2,11 @@ goog.provide('ol.Image');
goog.provide('ol.ImageState');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.Attribution');
goog.require('ol.Extent');

View File

@@ -1,8 +1,10 @@
goog.provide('ol.ImageTile');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.Tile');
goog.require('ol.TileCoord');
goog.require('ol.TileState');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.DblClickZoom');
goog.require('goog.asserts');
goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.View2D');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.interaction.Drag');
goog.require('goog.asserts');
goog.require('goog.events.BrowserEvent');
goog.require('goog.functions');
goog.require('ol.Coordinate');
goog.require('ol.MapBrowserEvent');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('goog.asserts');
goog.require('goog.math.Vec2');
goog.require('ol.View2D');
goog.require('ol.interaction.ConditionType');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.interaction.DragRotate');
goog.require('goog.asserts');
goog.require('ol.View2D');
goog.require('ol.ViewHint');
goog.require('ol.interaction.ConditionType');

View File

@@ -3,6 +3,7 @@
goog.provide('ol.interaction.DragZoom');
goog.require('goog.asserts');
goog.require('ol.Extent');
goog.require('ol.Size');
goog.require('ol.View2D');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.Keyboard');
goog.require('goog.events.KeyHandler.EventType');
goog.require('ol.interaction.Interaction');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.KeyboardPan');
goog.require('goog.asserts');
goog.require('goog.events.KeyCodes');
goog.require('goog.events.KeyHandler.EventType');
goog.require('ol.View2D');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.KeyboardZoom');
goog.require('goog.asserts');
goog.require('goog.events.KeyHandler.EventType');
goog.require('ol.View2D');
goog.require('ol.interaction.Interaction');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.MouseWheelZoom');
goog.require('goog.asserts');
goog.require('goog.events.MouseWheelEvent');
goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.math');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.interaction.Touch');
goog.require('goog.functions');
goog.require('goog.object');
goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.Pixel');

View File

@@ -3,6 +3,7 @@
goog.provide('ol.interaction.TouchRotate');
goog.require('goog.asserts');
goog.require('goog.style');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Touch');

View File

@@ -3,6 +3,7 @@
goog.provide('ol.interaction.TouchZoom');
goog.require('goog.asserts');
goog.require('goog.style');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Touch');

View File

@@ -1,6 +1,8 @@
goog.provide('ol.layer.Vector');
goog.require('goog.asserts');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.Feature');
goog.require('ol.geom.SharedVertices');
goog.require('ol.layer.Layer');

View File

@@ -8,10 +8,14 @@ goog.provide('ol.RendererHint');
goog.provide('ol.RendererHints');
goog.require('goog.Uri.QueryData');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.async.AnimationDelay');
goog.require('goog.async.Delay');
goog.require('goog.debug.Logger');
goog.require('goog.dispose');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.dom.ViewportSizeMonitor');
goog.require('goog.events');
goog.require('goog.events.BrowserEvent');
@@ -21,7 +25,9 @@ goog.require('goog.events.KeyHandler');
goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.events.MouseWheelHandler');
goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.object');
goog.require('goog.style');
goog.require('goog.vec.Mat4');
goog.require('ol.BrowserFeature');
goog.require('ol.Collection');
goog.require('ol.Color');

View File

@@ -3,6 +3,7 @@ goog.provide('ol.MapBrowserEvent.EventType');
goog.provide('ol.MapBrowserEventHandler');
goog.require('goog.array');
goog.require('goog.events');
goog.require('goog.events.BrowserEvent');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');

View File

@@ -1,5 +1,7 @@
goog.provide('ol.math');
goog.require('goog.asserts');
/**
* @param {number} x X.

View File

@@ -1,6 +1,7 @@
goog.provide('ol');
goog.require('goog.debug.Logger');
goog.require('goog.debug.Logger.Level');
if (goog.DEBUG) {

View File

@@ -2,7 +2,9 @@ goog.provide('ol.Overlay');
goog.provide('ol.OverlayPositioning');
goog.provide('ol.OverlayProperty');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.style');
goog.require('ol.Coordinate');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.parser.GeoJSON');
goog.require('goog.asserts');
goog.require('ol.Feature');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryType');

View File

@@ -1,4 +1,6 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_0_0');
goog.require('goog.object');
goog.require('goog.string');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_0');

View File

@@ -1,4 +1,6 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1');
goog.require('goog.object');
goog.require('ol.parser.ogc.WMSCapabilities_v1');

View File

@@ -1,4 +1,6 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1_0');
goog.require('goog.object');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1');

View File

@@ -1,4 +1,6 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1_1');
goog.require('goog.object');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1');

View File

@@ -1,4 +1,6 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC');
goog.require('goog.object');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1');

View File

@@ -1,4 +1,6 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_3_0');
goog.require('goog.object');
goog.require('ol.parser.ogc.WMSCapabilities_v1');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.projection.EPSG3857');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.Extent');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');

View File

@@ -1,5 +1,7 @@
goog.provide('ol.renderer.canvas.ImageLayer');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.vec.Mat4');
goog.require('ol.Image');
goog.require('ol.ImageState');

View File

@@ -3,7 +3,9 @@
goog.provide('ol.renderer.canvas.Map');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.style');
goog.require('goog.vec.Mat4');
goog.require('ol.Size');

View File

@@ -4,7 +4,10 @@
goog.provide('ol.renderer.canvas.TileLayer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.object');
goog.require('goog.vec.Mat4');
goog.require('ol.Extent');
goog.require('ol.Size');

View File

@@ -1,5 +1,10 @@
goog.provide('ol.renderer.canvas.VectorLayer');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('goog.vec.Mat4');
goog.require('ol.Extent');
goog.require('ol.Size');

View File

@@ -2,6 +2,10 @@ goog.provide('ol.renderer.canvas.VectorRenderer');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.vec.Mat4');
goog.require('ol.Feature');
goog.require('ol.Pixel');

View File

@@ -1,6 +1,9 @@
goog.provide('ol.renderer.dom.ImageLayer');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.vec.Mat4');
goog.require('ol.Image');
goog.require('ol.ImageState');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.renderer.dom.Layer');
goog.require('goog.dom');
goog.require('ol.layer.Layer');
goog.require('ol.renderer.Layer');

View File

@@ -3,8 +3,11 @@
goog.provide('ol.renderer.dom.TileLayer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.object');
goog.require('goog.style');
goog.require('goog.vec.Mat4');
goog.require('ol.Coordinate');

View File

@@ -3,8 +3,11 @@ goog.provide('ol.renderer.Map');
goog.require('goog.Disposable');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dispose');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.functions');
goog.require('goog.object');
goog.require('goog.vec.Mat4');
goog.require('ol.CollectionEvent');
goog.require('ol.CollectionEventType');

View File

@@ -1,6 +1,10 @@
goog.provide('ol.renderer.webgl.ImageLayer');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.vec.Mat4');
goog.require('goog.webgl');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Image');

View File

@@ -3,6 +3,7 @@
goog.provide('ol.renderer.webgl.Layer');
goog.require('goog.vec.Mat4');
goog.require('goog.webgl');
goog.require('ol.FrameState');
goog.require('ol.layer.Layer');
goog.require('ol.renderer.Layer');

View File

@@ -3,11 +3,13 @@
goog.provide('ol.renderer.webgl.Map');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.debug.Logger');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.Event');
goog.require('goog.object');
goog.require('goog.style');
goog.require('goog.webgl');
goog.require('ol.FrameState');

View File

@@ -2,6 +2,8 @@ goog.provide('ol.source.BingMaps');
goog.require('goog.Uri');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.math');
goog.require('goog.net.Jsonp');
goog.require('ol.Attribution');
goog.require('ol.Extent');

View File

@@ -1,5 +1,7 @@
goog.provide('ol.source.DebugTileSource');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('ol.Size');
goog.require('ol.Tile');
goog.require('ol.TileCache');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.source.ImageSource');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.Image');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.source.ImageTileSource');
goog.provide('ol.source.ImageTileSourceOptions');
goog.require('goog.asserts');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.ImageTile');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.source.Stamen');
goog.require('goog.asserts');
goog.require('ol.Attribution');
goog.require('ol.source.XYZ');

View File

@@ -2,8 +2,8 @@
goog.provide('ol.source.TiledWMS');
goog.require('goog.array');
goog.require('goog.math');
goog.require('ol.Extent');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');

View File

@@ -10,6 +10,7 @@ goog.provide('ol.source.TileJSON');
goog.provide('ol.tilejson');
goog.require('goog.asserts');
goog.require('goog.math');
goog.require('goog.net.jsloader');
goog.require('ol.Attribution');
goog.require('ol.Extent');

View File

@@ -1,5 +1,8 @@
goog.provide('ol.source.wms');
goog.require('goog.object');
goog.require('goog.uri.utils');
/**
* @param {string} baseUrl WMS base url.

View File

@@ -1,7 +1,11 @@
goog.provide('ol.source.WMTS');
goog.provide('ol.source.WMTSRequestEncoding');
goog.require('ol.Attribution');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.math');
goog.require('goog.object');
goog.require('goog.uri.utils');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.structs.Buffer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.webgl');
goog.require('ol.structs.IntegerSet');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.structs.RTree');
goog.require('goog.object');
goog.require('ol.Rectangle');

View File

@@ -2,6 +2,7 @@ goog.provide('ol.style.Icon');
goog.provide('ol.style.IconLiteral');
goog.provide('ol.style.IconType');
goog.require('goog.asserts');
goog.require('ol.Expression');
goog.require('ol.ExpressionLiteral');
goog.require('ol.style.Point');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.style.Line');
goog.provide('ol.style.LineLiteral');
goog.require('goog.asserts');
goog.require('ol.Expression');
goog.require('ol.ExpressionLiteral');
goog.require('ol.style.Symbolizer');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.style.Polygon');
goog.provide('ol.style.PolygonLiteral');
goog.require('goog.asserts');
goog.require('ol.Expression');
goog.require('ol.ExpressionLiteral');
goog.require('ol.style.Symbolizer');

View File

@@ -2,6 +2,7 @@ goog.provide('ol.style.Shape');
goog.provide('ol.style.ShapeLiteral');
goog.provide('ol.style.ShapeType');
goog.require('goog.asserts');
goog.require('ol.Expression');
goog.require('ol.ExpressionLiteral');
goog.require('ol.style.Point');

View File

@@ -1,5 +1,7 @@
goog.provide('ol.tilegrid.WMTS');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.Size');
goog.require('ol.projection');
goog.require('ol.tilegrid.TileGrid');

View File

@@ -2,6 +2,7 @@ goog.provide('ol.View');
goog.provide('ol.ViewHint');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.IView');
goog.require('ol.Object');

View File

@@ -4,6 +4,7 @@
goog.provide('ol.View2D');
goog.provide('ol.View2DProperty');
goog.require('goog.asserts');
goog.require('ol.Constraints');
goog.require('ol.Extent');
goog.require('ol.IView2D');

View File

@@ -1,6 +1,9 @@
goog.provide('ol.webgl');
goog.provide('ol.webgl.WebGLContextEventType');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
/**
* @const

View File

@@ -275,5 +275,7 @@ describe('ol.collection', function() {
});
goog.require('goog.events');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');

View File

@@ -25,5 +25,6 @@ describe('ol.control.Control', function() {
});
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('ol.Map');
goog.require('ol.control.Control');

View File

@@ -475,4 +475,6 @@ describe('ol.Object', function() {
});
});
goog.require('goog.events');
goog.require('ol.Object');

View File

@@ -357,6 +357,7 @@ describe('ol.projection', function() {
});
goog.require('goog.array');
goog.require('goog.asserts.AssertionError');
goog.require('ol.Extent');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');

View File

@@ -547,4 +547,5 @@ describe('ol.Sphere', function() {
});
goog.require('goog.math');
goog.require('ol.Sphere');

View File

@@ -615,5 +615,6 @@ describe('ol.structs.IntegerSet', function() {
goog.require('goog.array');
goog.require('goog.math');
goog.require('goog.object');
goog.require('ol.structs.IntegerSet');

View File

@@ -58,5 +58,6 @@ describe('ol.structs.RTree', function() {
});
goog.require('goog.object');
goog.require('ol.Rectangle');
goog.require('ol.structs.RTree');