Skip to content

Commit

Permalink
Add names before types for lambda types and object indexer types (map…
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer authored and mike-unearth committed Mar 18, 2020
1 parent 05f3df1 commit befd6d1
Show file tree
Hide file tree
Showing 82 changed files with 219 additions and 219 deletions.
4 changes: 2 additions & 2 deletions build/generate-flow-typed-style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function flowType(property) {
case 'light':
return 'LightSpecification';
case 'sources':
return '{[string]: SourceSpecification}';
return '{[_: string]: SourceSpecification}';
case '*':
return 'mixed';
default:
Expand Down Expand Up @@ -122,7 +122,7 @@ export type FormattedSpecification = string;
export type ResolvedImageSpecification = string;
export type PromoteIdSpecification = {[string]: string} | string;
export type PromoteIdSpecification = {[_: string]: string} | string;
export type FilterSpecification =
| ['has', string]
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/vector-tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type Point from '@mapbox/point-geometry';
import type { GeoJSONFeature } from '@mapbox/geojson-types';

declare interface VectorTile {
layers: {[string]: VectorTileLayer};
layers: {[_: string]: VectorTileLayer};
}

declare interface VectorTileLayer {
Expand All @@ -18,7 +18,7 @@ declare interface VectorTileFeature {
extent: number;
type: 1 | 2 | 3;
id: number;
properties: {[string]: string | number | boolean};
properties: {[_: string]: string | number | boolean};

loadGeometry(): Array<Array<Point>>;
toGeoJSON(x: number, y: number, z: number): GeoJSONFeature;
Expand Down
6 changes: 3 additions & 3 deletions src/data/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type BucketFeature = {|
properties: Object,
type: 1 | 2 | 3,
id?: any,
+patterns: {[string]: {"min": string, "mid": string, "max": string}},
+patterns: {[_: string]: {"min": string, "mid": string, "max": string}},
sortKey?: number
|};

Expand Down Expand Up @@ -75,7 +75,7 @@ export interface Bucket {
+stateDependentLayers: Array<any>;
+stateDependentLayerIds: Array<string>;
populate(features: Array<IndexedFeature>, options: PopulateParameters): void;
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}): void;
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}): void;
isEmpty(): boolean;

upload(context: Context): void;
Expand All @@ -91,7 +91,7 @@ export interface Bucket {
destroy(): void;
}

export function deserialize(input: Array<Bucket>, style: Style): {[string]: Bucket} {
export function deserialize(input: Array<Bucket>, style: Style): {[_: string]: Bucket} {
const output = {};

// Guard against the case where the map's style has been set to null while
Expand Down
2 changes: 1 addition & 1 deletion src/data/bucket/circle_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CircleBucket<Layer: CircleStyleLayer | HeatmapStyleLayer> implements Bucke
}
}

update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}) {
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
if (!this.stateDependentLayers.length) return;
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
}
Expand Down
6 changes: 3 additions & 3 deletions src/data/bucket/fill_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ class FillBucket implements Bucket {
}
}

update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}) {
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
if (!this.stateDependentLayers.length) return;
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
}

addFeatures(options: PopulateParameters, imagePositions: {[string]: ImagePosition}) {
addFeatures(options: PopulateParameters, imagePositions: {[_: string]: ImagePosition}) {
for (const feature of this.patternFeatures) {
this.addFeature(feature, feature.geometry, feature.index, imagePositions);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ class FillBucket implements Bucket {
this.segments2.destroy();
}

addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, imagePositions: {[string]: ImagePosition}) {
addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, imagePositions: {[_: string]: ImagePosition}) {
for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {
let numVertices = 0;
for (const ring of polygon) {
Expand Down
6 changes: 3 additions & 3 deletions src/data/bucket/fill_extrusion_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ class FillExtrusionBucket implements Bucket {
}
}

addFeatures(options: PopulateParameters, imagePositions: {[string]: ImagePosition}) {
addFeatures(options: PopulateParameters, imagePositions: {[_: string]: ImagePosition}) {
for (const feature of this.features) {
const {geometry} = feature;
this.addFeature(feature, geometry, feature.index, imagePositions);
}
}

update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}) {
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
if (!this.stateDependentLayers.length) return;
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
}
Expand Down Expand Up @@ -157,7 +157,7 @@ class FillExtrusionBucket implements Bucket {
this.segments.destroy();
}

addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, imagePositions: {[string]: ImagePosition}) {
addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, imagePositions: {[_: string]: ImagePosition}) {
for (const polygon of classifyRings(geometry, EARCUT_MAX_RINGS)) {
let numVertices = 0;
for (const ring of polygon) {
Expand Down
8 changes: 4 additions & 4 deletions src/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ class LineBucket implements Bucket {
}
}

update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}) {
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
if (!this.stateDependentLayers.length) return;
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
}

addFeatures(options: PopulateParameters, imagePositions: {[string]: ImagePosition}) {
addFeatures(options: PopulateParameters, imagePositions: {[_: string]: ImagePosition}) {
for (const feature of this.patternFeatures) {
this.addFeature(feature, feature.geometry, feature.index, imagePositions);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ class LineBucket implements Bucket {
this.segments.destroy();
}

addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, imagePositions: {[string]: ImagePosition}) {
addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, imagePositions: {[_: string]: ImagePosition}) {
const layout = this.layers[0].layout;
const join = layout.get('line-join').evaluate(feature, {});
const cap = layout.get('line-cap');
Expand All @@ -215,7 +215,7 @@ class LineBucket implements Bucket {
}
}

addLine(vertices: Array<Point>, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number, index: number, imagePositions: {[string]: ImagePosition}) {
addLine(vertices: Array<Point>, feature: BucketFeature, join: string, cap: string, miterLimit: number, roundLimit: number, index: number, imagePositions: {[_: string]: ImagePosition}) {
this.distance = 0;
this.scaledDistance = 0;
this.totalDistance = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class SymbolBucket implements Bucket {
sortKeyRanges: Array<SortKeyRange>;
pixelRatio: number;
tilePixelRatio: number;
compareText: {[string]: Array<Point>};
compareText: {[_: string]: Array<Point>};
fadeStartTime: number;
sortFeaturesByKey: boolean;
sortFeaturesByY: boolean;
Expand Down Expand Up @@ -387,7 +387,7 @@ class SymbolBucket implements Bucket {
this.symbolInstances = new SymbolInstanceArray();
}

calculateGlyphDependencies(text: string, stack: {[number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {
calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {
for (let i = 0; i < text.length; i++) {
stack[text.charCodeAt(i)] = true;
if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {
Expand Down Expand Up @@ -523,7 +523,7 @@ class SymbolBucket implements Bucket {
}
}

update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}) {
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
if (!this.stateDependentLayers.length) return;
this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
Expand Down
12 changes: 6 additions & 6 deletions src/data/feature_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FeatureIndex {
rawTileData: ArrayBuffer;
bucketLayerIDs: Array<Array<string>>;

vtLayers: {[string]: VectorTileLayer};
vtLayers: {[_: string]: VectorTileLayer};
sourceLayerCoder: DictionaryCoder;

constructor(tileID: OverscaledTileID, promoteId?: ?PromoteIdSpecification) {
Expand Down Expand Up @@ -92,7 +92,7 @@ class FeatureIndex {
}
}

loadVTLayers(): {[string]: VectorTileLayer} {
loadVTLayers(): {[_: string]: VectorTileLayer} {
if (!this.vtLayers) {
this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers;
this.sourceLayerCoder = new DictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers).sort() : ['_geojsonTileLayer']);
Expand All @@ -101,7 +101,7 @@ class FeatureIndex {
}

// Finds non-symbol features in this tile at a particular position.
query(args: QueryParameters, styleLayers: {[string]: StyleLayer}, sourceFeatureState: SourceFeatureState): {[string]: Array<{ featureIndex: number, feature: GeoJSONFeature }>} {
query(args: QueryParameters, styleLayers: {[_: string]: StyleLayer}, sourceFeatureState: SourceFeatureState): {[_: string]: Array<{ featureIndex: number, feature: GeoJSONFeature }>} {
this.loadVTLayers();

const params = args.params || {},
Expand Down Expand Up @@ -164,13 +164,13 @@ class FeatureIndex {
}

loadMatchingFeature(
result: {[string]: Array<{ featureIndex: number, feature: GeoJSONFeature }>},
result: {[_: string]: Array<{ featureIndex: number, feature: GeoJSONFeature }>},
bucketIndex: number,
sourceLayerIndex: number,
featureIndex: number,
filter: FeatureFilter,
filterLayerIDs: Array<string>,
styleLayers: {[string]: StyleLayer},
styleLayers: {[_: string]: StyleLayer},
intersectionTest?: (feature: VectorTileFeature, styleLayer: StyleLayer, id: string | number | void) => boolean | number) {

const layerIDs = this.bucketLayerIDs[bucketIndex];
Expand Down Expand Up @@ -219,7 +219,7 @@ class FeatureIndex {
sourceLayerIndex: number,
filterSpec: FilterSpecification,
filterLayerIDs: Array<string>,
styleLayers: {[string]: StyleLayer}) {
styleLayers: {[_: string]: StyleLayer}) {
const result = {};
this.loadVTLayers();

Expand Down
28 changes: 14 additions & 14 deletions src/data/program_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function packColor(color: Color): [number, number] {
*/

interface AttributeBinder {
populatePaintArray(length: number, feature: Feature, imagePositions: {[string]: ImagePosition}, formattedSection?: FormattedSection): void;
updatePaintArray(start: number, length: number, feature: Feature, featureState: FeatureState, imagePositions: {[string]: ImagePosition}): void;
populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, formattedSection?: FormattedSection): void;
updatePaintArray(start: number, length: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}): void;
upload(Context): void;
destroy(): void;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ class SourceExpressionBinder implements AttributeBinder {
this.paintVertexArray = new PaintVertexArray();
}

populatePaintArray(newLength: number, feature: Feature, imagePositions: {[string]: ImagePosition}, formattedSection?: FormattedSection) {
populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, formattedSection?: FormattedSection) {
const start = this.paintVertexArray.length;
const value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, [], formattedSection);
this.paintVertexArray.resize(newLength);
Expand Down Expand Up @@ -232,7 +232,7 @@ class CompositeExpressionBinder implements AttributeBinder, UniformBinder {
this.paintVertexArray = new PaintVertexArray();
}

populatePaintArray(newLength: number, feature: Feature, imagePositions: {[string]: ImagePosition}, formattedSection?: FormattedSection) {
populatePaintArray(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, formattedSection?: FormattedSection) {
const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, [], formattedSection);
const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, [], formattedSection);
const start = this.paintVertexArray.length;
Expand Down Expand Up @@ -319,14 +319,14 @@ class CrossFadedCompositeBinder implements AttributeBinder {
this.zoomOutPaintVertexArray = new PaintVertexArray();
}

populatePaintArray(length: number, feature: Feature, imagePositions: {[string]: ImagePosition}) {
populatePaintArray(length: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}) {
const start = this.zoomInPaintVertexArray.length;
this.zoomInPaintVertexArray.resize(length);
this.zoomOutPaintVertexArray.resize(length);
this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions);
}

updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[string]: ImagePosition}) {
updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState, imagePositions: {[_: string]: ImagePosition}) {
this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions);
}

Expand Down Expand Up @@ -388,13 +388,13 @@ class CrossFadedCompositeBinder implements AttributeBinder {
* @private
*/
export default class ProgramConfiguration {
binders: { [string]: (AttributeBinder | UniformBinder) };
binders: {[_: string]: (AttributeBinder | UniformBinder) };
cacheKey: string;
layoutAttributes: Array<StructArrayMember>;

_buffers: Array<VertexBuffer>;

constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (string) => boolean, layoutAttributes: Array<StructArrayMember>) {
constructor(layer: TypedStyleLayer, zoom: number, filterProperties: (_: string) => boolean, layoutAttributes: Array<StructArrayMember>) {
this.binders = {};
this.layoutAttributes = layoutAttributes;
this._buffers = [];
Expand Down Expand Up @@ -442,7 +442,7 @@ export default class ProgramConfiguration {
return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0;
}

populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[string]: ImagePosition}, formattedSection?: FormattedSection) {
populatePaintArrays(newLength: number, feature: Feature, imagePositions: {[_: string]: ImagePosition}, formattedSection?: FormattedSection) {
for (const property in this.binders) {
const binder = this.binders[property];
if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)
Expand All @@ -457,7 +457,7 @@ export default class ProgramConfiguration {
}
}

updatePaintArrays(featureStates: FeatureStates, featureMap: FeaturePositionMap, vtLayer: VectorTileLayer, layer: TypedStyleLayer, imagePositions: {[string]: ImagePosition}): boolean {
updatePaintArrays(featureStates: FeatureStates, featureMap: FeaturePositionMap, vtLayer: VectorTileLayer, layer: TypedStyleLayer, imagePositions: {[_: string]: ImagePosition}): boolean {
let dirty: boolean = false;
for (const id in featureStates) {
const positions = featureMap.getPositions(id);
Expand Down Expand Up @@ -554,12 +554,12 @@ export default class ProgramConfiguration {
}

export class ProgramConfigurationSet<Layer: TypedStyleLayer> {
programConfigurations: {[string]: ProgramConfiguration};
programConfigurations: {[_: string]: ProgramConfiguration};
needsUpload: boolean;
_featureMap: FeaturePositionMap;
_bufferOffset: number;

constructor(layoutAttributes: Array<StructArrayMember>, layers: $ReadOnlyArray<Layer>, zoom: number, filterProperties: (string) => boolean = () => true) {
constructor(layoutAttributes: Array<StructArrayMember>, layers: $ReadOnlyArray<Layer>, zoom: number, filterProperties: (_: string) => boolean = () => true) {
this.programConfigurations = {};
for (const layer of layers) {
this.programConfigurations[layer.id] = new ProgramConfiguration(layer, zoom, filterProperties, layoutAttributes);
Expand All @@ -569,7 +569,7 @@ export class ProgramConfigurationSet<Layer: TypedStyleLayer> {
this._bufferOffset = 0;
}

populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[string]: ImagePosition}, formattedSection?: FormattedSection) {
populatePaintArrays(length: number, feature: Feature, index: number, imagePositions: {[_: string]: ImagePosition}, formattedSection?: FormattedSection) {
for (const key in this.programConfigurations) {
this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, formattedSection);
}
Expand All @@ -582,7 +582,7 @@ export class ProgramConfigurationSet<Layer: TypedStyleLayer> {
this.needsUpload = true;
}

updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: $ReadOnlyArray<TypedStyleLayer>, imagePositions: {[string]: ImagePosition}) {
updatePaintArrays(featureStates: FeatureStates, vtLayer: VectorTileLayer, layers: $ReadOnlyArray<TypedStyleLayer>, imagePositions: {[_: string]: ImagePosition}) {
for (const layer of layers) {
this.needsUpload = this.programConfigurations[layer.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer, imagePositions) || this.needsUpload;
}
Expand Down
2 changes: 1 addition & 1 deletion src/data/segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type Segment = {
primitiveOffset: number,
vertexLength: number,
primitiveLength: number,
vaos: {[string]: VertexArrayObject}
vaos: {[_: string]: VertexArrayObject}
}

class SegmentVector {
Expand Down
4 changes: 2 additions & 2 deletions src/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class Transform {
_center: LngLat;
_edgeInsets: EdgeInsets;
_constraining: boolean;
_posMatrixCache: {[string]: Float32Array};
_alignedPosMatrixCache: {[string]: Float32Array};
_posMatrixCache: {[_: string]: Float32Array};
_alignedPosMatrixCache: {[_: string]: Float32Array};

constructor(minZoom: ?number, maxZoom: ?number, minPitch: ?number, maxPitch: ?number, renderWorldCopies: boolean | void) {
this.tileSize = 512; // constant
Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type SymbolTileRenderState = {
}
};

function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array<OverscaledTileID>, variableOffsets: {[CrossTileID]: VariableOffset}) {
function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array<OverscaledTileID>, variableOffsets: {[_: CrossTileID]: VariableOffset}) {
if (painter.renderPass !== 'translucent') return;

// Disable the stencil test so that labels aren't clipped to tile boundaries.
Expand Down
Loading

0 comments on commit befd6d1

Please sign in to comment.