From cc46fea80da6b3527a4adba3bea8d210d9ac8046 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Wed, 1 Aug 2018 12:09:02 -0700 Subject: [PATCH] Address review comments: - "FormattedExpression" -> "FormatExpression" (reasoning: the expression itself is a verb, the result is a noun) - Remove dead/debug code - Add comments --- build/generate-style-code.js | 1 - src/style-spec/expression/definitions/formatted.js | 4 ++-- src/style-spec/expression/definitions/index.js | 4 ++-- src/style-spec/validate/validate.js | 3 --- src/symbol/shaping.js | 2 +- src/symbol/transform_text.js | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/build/generate-style-code.js b/build/generate-style-code.js index 70e7b852b2b..e9fa58b72bc 100644 --- a/build/generate-style-code.js +++ b/build/generate-style-code.js @@ -5,7 +5,6 @@ const fs = require('fs'); const ejs = require('ejs'); const spec = require('../src/style-spec/reference/v8'); const Color = require('../src/style-spec/util/color'); -const {Formatted} = require('../src/style-spec/expression/definitions/formatted'); global.camelize = function (str) { return str.replace(/(?:^|-)(.)/g, function (_, x) { diff --git a/src/style-spec/expression/definitions/formatted.js b/src/style-spec/expression/definitions/formatted.js index b9f5238e51e..9a87d99d31a 100644 --- a/src/style-spec/expression/definitions/formatted.js +++ b/src/style-spec/expression/definitions/formatted.js @@ -50,7 +50,7 @@ type FormattedSectionExpression = { font: Expression | null; } -export class FormattedExpression implements Expression { +export class FormatExpression implements Expression { type: Type; sections: Array; @@ -94,7 +94,7 @@ export class FormattedExpression implements Expression { sections.push({text, scale, font}); } - return new FormattedExpression(sections); + return new FormatExpression(sections); } evaluate(ctx: EvaluationContext) { diff --git a/src/style-spec/expression/definitions/index.js b/src/style-spec/expression/definitions/index.js index c36001e97db..2b50821baa0 100644 --- a/src/style-spec/expression/definitions/index.js +++ b/src/style-spec/expression/definitions/index.js @@ -26,7 +26,7 @@ import { GreaterThanOrEqual } from './comparison'; import { CollatorExpression } from './collator'; -import { Formatted, FormattedExpression } from './formatted'; +import { Formatted, FormatExpression } from './formatted'; import Length from './length'; import type { Type } from '../types'; @@ -47,7 +47,7 @@ const expressions: ExpressionRegistry = { 'case': Case, 'coalesce': Coalesce, 'collator': CollatorExpression, - 'format': FormattedExpression, + 'format': FormatExpression, 'interpolate': Interpolate, 'length': Length, 'let': Let, diff --git a/src/style-spec/validate/validate.js b/src/style-spec/validate/validate.js index 5caa8d75800..09543fd4580 100644 --- a/src/style-spec/validate/validate.js +++ b/src/style-spec/validate/validate.js @@ -69,9 +69,6 @@ export default function validate(options) { const valid = validateObject(extend({}, options, { valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec })); - if (!valid) { - console.log("not valid"); - } return valid; } } diff --git a/src/symbol/shaping.js b/src/symbol/shaping.js index 30022a3a737..fc6036fed9d 100644 --- a/src/symbol/shaping.js +++ b/src/symbol/shaping.js @@ -44,7 +44,7 @@ type TextJustify = 'left' | 'center' | 'right'; class TaggedString { text: string; - sectionIndex: Array + sectionIndex: Array // maps each character in 'text' to its corresponding entry in 'sections' sections: Array<{ scale: number, fontStack: string }> constructor() { diff --git a/src/symbol/transform_text.js b/src/symbol/transform_text.js index 45040543618..e7058086c90 100644 --- a/src/symbol/transform_text.js +++ b/src/symbol/transform_text.js @@ -24,7 +24,6 @@ function transformText(text: string, layer: SymbolStyleLayer, feature: Feature) export default function(text: string | Formatted, layer: SymbolStyleLayer, feature: Feature) { if (text instanceof Formatted) { - // OK to transform in place? text.sections.forEach(section => { section.text = transformText(section.text, layer, feature); });