Search in sources :

Example 1 with ProjectViewParser

use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.

the class ProjectViewManagerImpl method reloadProjectView.

@Nullable
@Override
public ProjectViewSet reloadProjectView(BlazeContext context, WorkspacePathResolver workspacePathResolver) {
    BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings();
    assert importSettings != null;
    assert importSettings.getProjectViewFile() != null;
    File projectViewFile = new File(importSettings.getProjectViewFile());
    ProjectViewParser parser = new ProjectViewParser(context, workspacePathResolver);
    parser.parseProjectView(projectViewFile);
    boolean success = !context.hasErrors();
    if (success) {
        ProjectViewSet projectViewSet = parser.getResult();
        File file = getCacheFile(project, importSettings);
        try {
            SerializationUtil.saveToDisk(file, projectViewSet);
        } catch (IOException e) {
            logger.error(e);
        }
        this.projectViewSet = projectViewSet;
    }
    return success ? projectViewSet : null;
}
Also used : BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) IOException(java.io.IOException) File(java.io.File) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser) Nullable(javax.annotation.Nullable)

Example 2 with ProjectViewParser

use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.

the class CPrefetchFileSourceTest method parseProjectView.

private ProjectViewSet parseProjectView(String... contents) {
    ProjectViewParser projectViewParser = new ProjectViewParser(new BlazeContext(), new WorkspacePathResolverImpl(workspaceRoot));
    projectViewParser.parseProjectView(Joiner.on("\n").join(contents));
    return projectViewParser.getResult();
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser)

Example 3 with ProjectViewParser

use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.

the class BlazeEditProjectViewControl method modifyInitialProjectView.

private static String modifyInitialProjectView(BuildSystem buildSystem, String initialProjectViewText, WorkspacePathResolver workspacePathResolver) {
    BlazeContext context = new BlazeContext();
    ProjectViewParser projectViewParser = new ProjectViewParser(context, workspacePathResolver);
    projectViewParser.parseProjectView(initialProjectViewText);
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    if (projectViewFile == null) {
        return initialProjectViewText;
    }
    ProjectView projectView = projectViewFile.projectView;
    // Sort default value providers to match the section order
    List<SectionKey> sectionKeys = Sections.getParsers().stream().map(SectionParser::getSectionKey).collect(toList());
    List<ProjectViewDefaultValueProvider> defaultValueProviders = Lists.newArrayList(ProjectViewDefaultValueProvider.EP_NAME.getExtensions());
    defaultValueProviders.sort(Comparator.comparingInt(val -> sectionKeys.indexOf(val.getSectionKey())));
    for (ProjectViewDefaultValueProvider defaultValueProvider : defaultValueProviders) {
        projectView = defaultValueProvider.addProjectViewDefaultValue(buildSystem, projectViewSet, projectView);
    }
    return ProjectViewParser.projectViewToString(projectView);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ScalarSection(com.google.idea.blaze.base.projectview.section.ScalarSection) LanguageSupport(com.google.idea.blaze.base.sync.projectview.LanguageSupport) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) Sections(com.google.idea.blaze.base.projectview.section.sections.Sections) JBLabel(com.intellij.ui.components.JBLabel) JPanelProvidingProject(com.google.idea.blaze.base.settings.ui.JPanelProvidingProject) UiUtil(com.google.idea.blaze.base.ui.UiUtil) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) BorderLayout(java.awt.BorderLayout) ProgressManager(com.intellij.openapi.progress.ProgressManager) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) BlazeValidationResult(com.google.idea.blaze.base.ui.BlazeValidationResult) RecentProjectsManager(com.intellij.ide.RecentProjectsManager) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) BorderFactory(javax.swing.BorderFactory) ProjectViewDefaultValueProvider(com.google.idea.blaze.base.projectview.section.ProjectViewDefaultValueProvider) TextComponentAccessor(com.intellij.openapi.ui.TextComponentAccessor) Component(java.awt.Component) JRadioButton(javax.swing.JRadioButton) TargetSection(com.google.idea.blaze.base.projectview.section.sections.TargetSection) Propagation(com.google.idea.blaze.base.scope.OutputSink.Propagation) List(java.util.List) SystemProperties(com.intellij.util.SystemProperties) ImportSection(com.google.idea.blaze.base.projectview.section.sections.ImportSection) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) GridBagLayout(java.awt.GridBagLayout) NotNull(org.jetbrains.annotations.NotNull) JPanel(javax.swing.JPanel) SectionParser(com.google.idea.blaze.base.projectview.section.SectionParser) SectionKey(com.google.idea.blaze.base.projectview.section.SectionKey) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeSelectWorkspaceOption(com.google.idea.blaze.base.wizard2.BlazeSelectWorkspaceOption) JTextField(javax.swing.JTextField) Paths(com.intellij.history.core.Paths) DirectorySection(com.google.idea.blaze.base.projectview.section.sections.DirectorySection) Hashing(com.google.common.hash.Hashing) Lists(com.google.common.collect.Lists) BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) Scope(com.google.idea.blaze.base.scope.Scope) BlazeDataStorage(com.google.idea.blaze.base.sync.data.BlazeDataStorage) BoolExperiment(com.google.idea.common.experiments.BoolExperiment) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) Nullable(javax.annotation.Nullable) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) ProjectDataDirectoryValidator(com.google.idea.blaze.base.wizard2.ProjectDataDirectoryValidator) ButtonGroup(javax.swing.ButtonGroup) HashCode(com.google.common.hash.HashCode) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser) StringUtil(com.intellij.openapi.util.text.StringUtil) BlazeSelectProjectViewOption(com.google.idea.blaze.base.wizard2.BlazeSelectProjectViewOption) IOException(java.io.IOException) BlazeNewProjectBuilder(com.google.idea.blaze.base.wizard2.BlazeNewProjectBuilder) ProjectViewStorageManager(com.google.idea.blaze.base.projectview.ProjectViewStorageManager) Disposable(com.intellij.openapi.Disposable) File(java.io.File) Category(com.google.idea.blaze.base.scope.output.IssueOutput.Category) JScrollPane(javax.swing.JScrollPane) Collectors.toList(java.util.stream.Collectors.toList) BlazeValidationError(com.google.idea.blaze.base.ui.BlazeValidationError) ProjectViewVerifier(com.google.idea.blaze.base.projectview.ProjectViewVerifier) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) ProjectViewUi(com.google.idea.blaze.base.settings.ui.ProjectViewUi) JLabel(javax.swing.JLabel) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Comparator(java.util.Comparator) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) SectionKey(com.google.idea.blaze.base.projectview.section.SectionKey) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) ProjectViewDefaultValueProvider(com.google.idea.blaze.base.projectview.section.ProjectViewDefaultValueProvider) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser)

Example 4 with ProjectViewParser

use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.

the class BlazeSyncIntegrationTestCase method setProjectView.

protected void setProjectView(String... contents) {
    ProjectViewParser projectViewParser = new ProjectViewParser(context, new WorkspacePathResolverImpl(workspaceRoot));
    projectViewParser.parseProjectView(Joiner.on("\n").join(contents));
    ProjectViewSet result = projectViewParser.getResult();
    assertThat(result.getProjectViewFiles()).isNotEmpty();
    errorCollector.assertNoIssues();
    setProjectViewSet(result);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser)

Example 5 with ProjectViewParser

use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.

the class ProjectViewUi method parseProjectView.

public ProjectViewSet parseProjectView(final List<IssueOutput> issues) {
    final String projectViewText = projectViewEditor.getDocument().getText();
    final OutputSink<IssueOutput> issueCollector = output -> {
        issues.add(output);
        return OutputSink.Propagation.Continue;
    };
    return Scope.root(context -> {
        context.addOutputSink(IssueOutput.class, issueCollector);
        ProjectViewParser projectViewParser = new ProjectViewParser(context, workspacePathResolver);
        projectViewParser.parseProjectView(projectViewText);
        return projectViewParser.getResult();
    });
}
Also used : UIManager(javax.swing.UIManager) WriteAction(com.intellij.openapi.application.WriteAction) EditorFactoryImpl(com.intellij.openapi.editor.impl.EditorFactoryImpl) ProjectViewLanguage(com.google.idea.blaze.base.lang.projectview.language.ProjectViewLanguage) Document(com.intellij.openapi.editor.Document) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx) JBLabel(com.intellij.ui.components.JBLabel) PsiManager(com.intellij.psi.PsiManager) OutputSink(com.google.idea.blaze.base.scope.OutputSink) UiUtil(com.google.idea.blaze.base.ui.UiUtil) BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) ProjectManager(com.intellij.openapi.project.ProjectManager) Scope(com.google.idea.blaze.base.scope.Scope) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) EditorEx(com.intellij.openapi.editor.ex.EditorEx) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) DataManager(com.intellij.ide.DataManager) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) Nullable(javax.annotation.Nullable) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Blaze(com.google.idea.blaze.base.settings.Blaze) FileManager(com.intellij.psi.impl.file.impl.FileManager) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser) ProjectViewFileType(com.google.idea.blaze.base.lang.projectview.language.ProjectViewFileType) FileDocumentManagerImpl(com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl) Disposable(com.intellij.openapi.Disposable) Dimension(java.awt.Dimension) List(java.util.List) EditorColors(com.intellij.openapi.editor.colors.EditorColors) KeyboardFocusManager(java.awt.KeyboardFocusManager) ProjectImpl(com.intellij.openapi.project.impl.ProjectImpl) MutablePicoContainer(org.picocontainer.MutablePicoContainer) WorkspacePathResolverProvider(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverProvider) Result(com.intellij.openapi.application.Result) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) EditorFactory(com.intellij.openapi.editor.EditorFactory) JCheckBox(javax.swing.JCheckBox) EditorSettings(com.intellij.openapi.editor.EditorSettings) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) UndoUtil(com.intellij.openapi.command.undo.UndoUtil) NotNull(org.jetbrains.annotations.NotNull) JPanel(javax.swing.JPanel) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) ProjectViewParser(com.google.idea.blaze.base.projectview.parser.ProjectViewParser)

Aggregations

ProjectViewParser (com.google.idea.blaze.base.projectview.parser.ProjectViewParser)5 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)3 Nullable (javax.annotation.Nullable)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 Scope (com.google.idea.blaze.base.scope.Scope)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 BuildSystem (com.google.idea.blaze.base.settings.Blaze.BuildSystem)2 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)2 WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)2 File (java.io.File)2 IOException (java.io.IOException)2 Lists (com.google.common.collect.Lists)1 HashCode (com.google.common.hash.HashCode)1 Hashing (com.google.common.hash.Hashing)1 ProjectViewFileType (com.google.idea.blaze.base.lang.projectview.language.ProjectViewFileType)1 ProjectViewLanguage (com.google.idea.blaze.base.lang.projectview.language.ProjectViewLanguage)1 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)1 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)1 ProjectViewFile (com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)1