-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support blazerc section in project view
PiperOrigin-RevId: 553927607
- Loading branch information
1 parent
21581b5
commit 59f10f2
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
base/src/com/google/idea/blaze/base/projectview/section/sections/BuildConfigSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2023 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.projectview.section.sections; | ||
|
||
import com.google.idea.blaze.base.model.primitives.WorkspacePath; | ||
import com.google.idea.blaze.base.projectview.parser.ParseContext; | ||
import com.google.idea.blaze.base.projectview.parser.ProjectViewParser; | ||
import com.google.idea.blaze.base.projectview.section.ScalarSection; | ||
import com.google.idea.blaze.base.projectview.section.ScalarSectionParser; | ||
import com.google.idea.blaze.base.projectview.section.SectionKey; | ||
import com.google.idea.blaze.base.projectview.section.SectionParser; | ||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
/** A section to specify build-system's configuration file. */ | ||
public final class BuildConfigSection { | ||
public static final SectionKey<WorkspacePath, ScalarSection<WorkspacePath>> KEY = | ||
SectionKey.of("build_config_file"); | ||
public static final SectionParser PARSER = new BuildConfigSectionParser(); | ||
|
||
private static class BuildConfigSectionParser extends ScalarSectionParser<WorkspacePath> { | ||
public BuildConfigSectionParser() { | ||
super(KEY, ':'); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected WorkspacePath parseItem( | ||
ProjectViewParser parser, ParseContext parseContext, String text) { | ||
String error = WorkspacePath.validate(text); | ||
if (error != null) { | ||
parseContext.addError(error); | ||
return null; | ||
} | ||
|
||
WorkspacePath workspacePath = new WorkspacePath(text); | ||
if (parser.isRecursive()) { | ||
File rcFile = parseContext.getWorkspacePathResolver().resolveToFile(workspacePath); | ||
if (rcFile == null || !rcFile.exists()) { | ||
parseContext.addError( | ||
String.format( | ||
"Could not resolve the build configuration file: %s", | ||
workspacePath.relativePath())); | ||
} | ||
} | ||
return workspacePath; | ||
} | ||
|
||
@Override | ||
protected void printItem(StringBuilder sb, WorkspacePath section) { | ||
sb.append(section); | ||
} | ||
|
||
@Override | ||
public ItemType getItemType() { | ||
return ItemType.FileItem; | ||
} | ||
|
||
@Override | ||
public String quickDocs() { | ||
return "Specifies build configuration file for the remote build services"; | ||
} | ||
} | ||
|
||
private BuildConfigSection() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters