blob: 7f12f083863d3a17022552d7ada52a60942d15f1 [file] [log] [blame]
/*
* Copyright 2016 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.base.lang.buildfile.language.semantics;
import com.google.common.collect.ImmutableSet;
import com.intellij.openapi.project.Project;
/**
* The built-in names available in the BUILD language. This is not a complete list, and is only
* intended to be used for syntax highlighting.
*/
public class BuiltInNamesProvider {
// https://www.bazel.io/versions/master/docs/skylark/lib/globals.html
private static final ImmutableSet<String> GLOBALS =
ImmutableSet.of(
"Actions",
"DATA_CFG",
"False",
"HOST_CFG",
"None",
"PACKAGE_NAME",
"REPOSITORY_NAME",
"True",
"all",
"any",
"aspect",
"bool",
"dict",
"dir",
"enumerate",
"fail",
"getattr",
"hasattr",
"hash",
"int",
"len",
"list",
"max",
"min",
"print",
"provider",
"range",
"repository_rule",
"repr",
"reversed",
"rule",
"select",
"set",
"sorted",
"str",
"struct",
"type",
"zip");
public static ImmutableSet<String> getBuiltInNames(Project project) {
BuildLanguageSpec spec = BuildLanguageSpecProvider.getInstance().getLanguageSpec(project);
if (spec == null) {
return GLOBALS;
}
return ImmutableSet.<String>builder().addAll(GLOBALS).addAll(spec.getKnownRuleNames()).build();
}
}