use of com.android.tools.idea.gradle.dsl.model.GradleSettingsModel in project android by JetBrains.
the class GradleDslExpression method resolveProjectReference.
@Nullable
private static GradleDslFile resolveProjectReference(GradleDslElement startElement, @NotNull String projectReference) {
GradleDslFile dslFile = startElement.getDslFile();
if ("project".equals(projectReference)) {
return dslFile;
}
if ("parent".equals(projectReference)) {
return dslFile.getParentModuleDslFile();
}
if ("rootProject".equals(projectReference)) {
while (dslFile != null && !filesEqual(dslFile.getDirectoryPath(), virtualToIoFile(dslFile.getProject().getBaseDir()))) {
dslFile = dslFile.getParentModuleDslFile();
}
return dslFile;
}
String standardProjectKey = getStandardProjectKey(projectReference);
if (standardProjectKey != null) {
// project(':project:path')
String modulePath = standardProjectKey.substring(standardProjectKey.indexOf("'") + 1, standardProjectKey.lastIndexOf("'"));
GradleSettingsModel model = GradleSettingsModel.get(dslFile.getProject());
if (model == null) {
return null;
}
File moduleDirectory = model.moduleDirectory(modulePath);
if (moduleDirectory == null) {
return null;
}
while (dslFile != null && !filesEqual(dslFile.getDirectoryPath(), virtualToIoFile(dslFile.getProject().getBaseDir()))) {
dslFile = dslFile.getParentModuleDslFile();
}
if (dslFile == null) {
return null;
}
// root module dsl File.
return findDslFile(dslFile, moduleDirectory);
}
return null;
}
Aggregations