Search in sources :

Example 1 with OCWorkspace

use of com.jetbrains.cidr.lang.workspace.OCWorkspace in project intellij by bazelbuild.

the class BlazeCppIntegrationTestCase method enableCSupportInIde.

private static void enableCSupportInIde(Project project) {
    OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project);
    assertThat(workspace).isNotNull();
    if (LANGUAGE_SUPPORT_DISABLED.get(project, false)) {
        LANGUAGE_SUPPORT_DISABLED.set(project, false);
    }
}
Also used : OCWorkspace(com.jetbrains.cidr.lang.workspace.OCWorkspace)

Example 2 with OCWorkspace

use of com.jetbrains.cidr.lang.workspace.OCWorkspace in project intellij by bazelbuild.

the class SyncStatusHelper method isUnsynced.

static boolean isUnsynced(Project project, VirtualFile virtualFile) {
    if (!virtualFile.isInLocalFileSystem()) {
        return false;
    }
    if (ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(virtualFile) == null) {
        return false;
    }
    OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project);
    if (!(workspace instanceof BlazeCWorkspace)) {
        // Skip if the project isn't a Blaze project or doesn't have C support enabled anyway.
        return false;
    }
    if (workspace.getConfigurations().isEmpty()) {
        // The workspace configurations may not have been loaded yet.
        return false;
    }
    SourceToTargetMap sourceToTargetMap = SourceToTargetMap.getInstance(project);
    return sourceToTargetMap.getRulesForSourceFile(VfsUtilCore.virtualToIoFile(virtualFile)).isEmpty();
}
Also used : SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) OCWorkspace(com.jetbrains.cidr.lang.workspace.OCWorkspace) BlazeCWorkspace(com.google.idea.blaze.cpp.BlazeCWorkspace)

Example 3 with OCWorkspace

use of com.jetbrains.cidr.lang.workspace.OCWorkspace in project intellij by bazelbuild.

the class BlazeCSyncPlugin method updateInMemoryState.

@Override
public void updateInMemoryState(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, Module workspaceModule) {
    if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.C)) {
        return;
    }
    Scope.push(context, childContext -> {
        childContext.push(new TimingScope("Setup C Workspace", EventType.Other));
        OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project);
        if (workspace instanceof BlazeCWorkspace) {
            BlazeCWorkspace blazeCWorkspace = (BlazeCWorkspace) workspace;
            blazeCWorkspace.update(childContext, workspaceRoot, projectViewSet, blazeProjectData);
        }
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) OCWorkspace(com.jetbrains.cidr.lang.workspace.OCWorkspace)

Example 4 with OCWorkspace

use of com.jetbrains.cidr.lang.workspace.OCWorkspace in project intellij by bazelbuild.

the class BlazeCppSymbolRebuildSyncListener method onSyncComplete.

@Override
public void onSyncComplete(Project project, BlazeContext context, BlazeImportSettings importSettings, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, SyncMode syncMode, SyncResult syncResult) {
    if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.C)) {
        return;
    }
    OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project);
    if (!(workspace instanceof BlazeCWorkspace)) {
        return;
    }
    loadOrRebuildSymbolTables(project);
}
Also used : OCWorkspace(com.jetbrains.cidr.lang.workspace.OCWorkspace)

Example 5 with OCWorkspace

use of com.jetbrains.cidr.lang.workspace.OCWorkspace in project intellij by bazelbuild.

the class BlazeNdkSupportEnabler method enableCSupportInIde.

/**
 * If {@code enabled} is true, this method will enable C support in the IDE if it is not already
 * enabled. if {@code enabled} is false this method will clear out any currently stored
 * information in the IDE about C and will disable C support in the IDE, unless support is already
 * disabled. In either case, if the value of enabled matches what the IDE currently does, this
 * method will do nothing.
 *
 * @param project the project to enable or disable c support in.
 * @param enabled if true, turn on C support in the IDE. If false, turn off C support in the IDE.
 */
private static void enableCSupportInIde(Project project, boolean enabled) {
    OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project);
    if (workspace == null) {
        // NDK workspace manager plugin isn't enabled.
        return;
    }
    Boolean isCurrentlyEnabled = !LANGUAGE_SUPPORT_DISABLED.get(project, false);
    if (isCurrentlyEnabled != enabled) {
        NdkHelper.disableCppLanguageSupport(project, !enabled);
        rebuildSymbols(project);
    }
}
Also used : OCWorkspace(com.jetbrains.cidr.lang.workspace.OCWorkspace)

Aggregations

OCWorkspace (com.jetbrains.cidr.lang.workspace.OCWorkspace)6 TimingScope (com.google.idea.blaze.base.scope.scopes.TimingScope)1 SourceToTargetMap (com.google.idea.blaze.base.targetmaps.SourceToTargetMap)1 BlazeCWorkspace (com.google.idea.blaze.cpp.BlazeCWorkspace)1