use of com.android.tools.idea.gradle.project.GradleProjectInfo in project android by JetBrains.
the class AndroidGeneratedSourcesFilter method isGeneratedSource.
// See: https://code.google.com/p/android/issues/detail?id=121156
// Alternative could be marking the entire build folder as generated source folder, but this have many side affects, e.g. a broken source
// file (e.g. have some syntax error / warning) under build folder that is not actually used in the project would be marked as red too and
// the user might be asked to fix it.
@Override
public boolean isGeneratedSource(@NotNull VirtualFile file, @NotNull Project project) {
GradleProjectInfo projectInfo = GradleProjectInfo.getInstance(project);
AndroidModuleModel androidModel = projectInfo.findAndroidModelInModule(file);
if (androidModel != null) {
return isAncestor(androidModel.getAndroidProject().getBuildFolder(), virtualToIoFile(file), false);
}
// Gradle projects also sometimes create a "build" folder at the top level (where there is no AndroidFacet module). Unfortunately, this
// folder is not available in the Gradle project model so we have to look for it by hardcoded name.
VirtualFile rootFolder = project.getBaseDir();
if (rootFolder == null) {
return false;
}
VirtualFile buildFolder = rootFolder.findChild(BUILD_DIR_DEFAULT_NAME);
return buildFolder != null && projectInfo.isBuildWithGradle() && isAncestor(buildFolder, file, false);
}
use of com.android.tools.idea.gradle.project.GradleProjectInfo in project android by JetBrains.
the class AndroidFrameworkDetectorTest method testDetectWithProjectWithBuildFile.
public void testDetectWithProjectWithBuildFile() {
GradleProjectInfo projectInfo = IdeComponents.replaceServiceWithMock(getProject(), GradleProjectInfo.class);
when(projectInfo.isBuildWithGradle()).thenReturn(false);
when(projectInfo.hasTopLevelGradleBuildFile()).thenReturn(true);
List<? extends DetectedFrameworkDescription> descriptions = myDetector.detect(Collections.emptyList(), myContext);
assertThat(descriptions).isEmpty();
}
use of com.android.tools.idea.gradle.project.GradleProjectInfo in project android by JetBrains.
the class AndroidFrameworkDetectorTest method testDetectWithGradleProject.
public void testDetectWithGradleProject() {
GradleProjectInfo projectInfo = IdeComponents.replaceServiceWithMock(getProject(), GradleProjectInfo.class);
when(projectInfo.isBuildWithGradle()).thenReturn(true);
List<? extends DetectedFrameworkDescription> descriptions = myDetector.detect(Collections.emptyList(), myContext);
assertThat(descriptions).isEmpty();
}
Aggregations