2 * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
4 package org.jetbrains.yaml.meta.model;
6 import com.intellij.codeInspection.ProblemsHolder;
7 import org.jetbrains.annotations.ApiStatus;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.yaml.psi.YAMLScalar;
11 @ApiStatus.Experimental
12 public class YamlNumberType extends YamlScalarType {
13 private static final YamlNumberType SHARED_INSTANCE = new YamlNumberType();
15 public static YamlNumberType getInstance() {
16 return SHARED_INSTANCE;
19 public YamlNumberType() {
21 setDisplayName("number");
25 protected void validateScalarValue(@NotNull YAMLScalar scalarValue, @NotNull ProblemsHolder holder) {
27 //noinspection ResultOfMethodCallIgnored
28 Float.parseFloat(scalarValue.getTextValue());
30 catch (NumberFormatException e) {
31 holder.registerProblem(scalarValue, "Numeric value expected");