MCPcopy Create free account
hub / github.com/bazelbuild/bazel / isValid

Method isValid

src/main/java/net/starlark/java/syntax/Identifier.java:75–87  ·  view source on GitHub ↗

Reports whether the string is a valid identifier.

(String name)

Source from the content-addressed store, hash-verified

73
74 /** Reports whether the string is a valid identifier. */
75 public static boolean isValid(String name) {
76 // Keep consistent with Lexer.scanIdentifier.
77 for (int i = 0; i < name.length(); i++) {
78 char c = name.charAt(i);
79 if (!(('a' <= c && c <= 'z')
80 || ('A' <= c && c <= 'Z')
81 || (i > 0 && '0' <= c && c <= '9')
82 || (c == '_'))) {
83 return false;
84 }
85 }
86 return !name.isEmpty();
87 }
88
89 /**
90 * Returns all names bound by an LHS expression.

Callers 2

useMethod · 0.95
parseTypeParameterMethod · 0.95

Calls 3

charAtMethod · 0.80
lengthMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected