Skip to content

Commit

Permalink
Hints does not work for sln files
Browse files Browse the repository at this point in the history
Issue: #34
  • Loading branch information
dtretyakov committed Mar 6, 2017
1 parent 8308bfe commit ed38a2e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class DotnetModelParser {
return null
}

fun getCsProjectModels(element: Element): List<CsProject>? {
if (!element.isContentAvailable) {
fun getCsProjectModels(element: Element?): List<CsProject>? {
if (element == null || !element.isContentAvailable) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@ abstract class DotnetProjectsDataFetcher(private val myModelParser: DotnetModelP

for (projectPath in projectsPaths) {
val path = projectPath.trimEnd('/')
val jsonProjectFile: String = getJsonProject(path)
myModelParser.getProjectModel(browser.getElement(jsonProjectFile))?.let {
items.addAll(getDataItems(it))

getJsonProject(path).let {
myModelParser.getProjectModel(browser.getElement(it))?.let {
items.addAll(getDataItems(it))
}
}

val csProjectFile: String = getCsProject(path, browser)
myModelParser.getCsProjectModel(browser.getElement(csProjectFile))?.let {
items.addAll(getDataItems(it))
getCsProject(path, browser)?.let {
myModelParser.getCsProjectModel(browser.getElement(it))?.let {
items.addAll(getDataItems(it))
}
}

getCsProjects(path, browser)?.let {
myModelParser.getCsProjectModels(browser.getElement(it))?.let {
it.forEach {
items.addAll(getDataItems(it))
}
}
}
}

Expand All @@ -65,8 +76,10 @@ abstract class DotnetProjectsDataFetcher(private val myModelParser: DotnetModelP
return projectFile
}

private fun getCsProject(projectPath: String, browser: Browser): String {
if (!projectPath.endsWith(DotnetConstants.PROJECT_CSPROJ, ignoreCase = true)) {
private fun getCsProject(projectPath: String, browser: Browser): String? {
if (projectPath.endsWith(DotnetConstants.PROJECT_CSPROJ, ignoreCase = true)) {
return projectPath
} else {
browser.getElement(projectPath)?.let {
it.children?.let {
it.firstOrNull {
Expand All @@ -78,7 +91,25 @@ abstract class DotnetProjectsDataFetcher(private val myModelParser: DotnetModelP
}
}

return projectPath
return null
}

private fun getCsProjects(projectPath: String, browser: Browser): String? {
if (projectPath.endsWith(DotnetConstants.PROJECT_SLN, ignoreCase = true)) {
return projectPath
} else {
browser.getElement(projectPath)?.let {
it.children?.let {
it.firstOrNull {
it.fullName.endsWith(DotnetConstants.PROJECT_SLN, ignoreCase = true)
}?.let {
return it.fullName
}
}
}
}

return null
}

protected abstract fun getDataItems(project: Project?): Collection<String>
Expand Down

0 comments on commit ed38a2e

Please sign in to comment.