Skip to content

Commit 58562c2

Browse files
author
Steve Ramage
committed
Checkpoint #290 - All tests passing
1 parent d370de9 commit 58562c2

File tree

13 files changed

+575
-507
lines changed

13 files changed

+575
-507
lines changed

build.gradle.kts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,21 @@ tasks.register<GenerateParserTask>("generateParserTask") {
202202

203203

204204
tasks.register<Copy>("generateOptionValidator") {
205-
from("./systemd-build/build/load-fragment-gperf.gperf")
205+
listOf(
206+
"journald-gperf.gperf",
207+
"link-config-gperf.gperf",
208+
"load-fragment-gperf.gperf",
209+
"logind-gperf.gperf",
210+
"netdev-gperf.gperf",
211+
"networkd-gperf.gperf",
212+
"networkd-network-gperf.gperf",
213+
"nspawn-gperf.gperf",
214+
"resolved-dnssd-gperf.gperf",
215+
"resolved-gperf.gperf",
216+
"timesyncd-gperf.gperf").forEach {
217+
fileName -> from("./systemd-build/build/${fileName}")
218+
}
219+
206220
into("${sourceSets["main"].output.resourcesDir?.getAbsolutePath()}/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/")
207221
}
208222

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileKeyCompletionContributor.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ class UnitFileKeyCompletionContributor : CompletionContributor() {
3535
val sectionName = section.sectionName
3636
val definedKeys = section.propertyList.stream().map { obj: UnitFileProperty -> obj.key }.collect(Collectors.toSet())
3737
val sdr = SemanticDataRepository.instance
38-
for (keyword in sdr.getDocumentedKeywordsInSection(sectionName)) {
38+
39+
val filename = section.containingFile.name
40+
41+
for (keyword in sdr.getDocumentedKeywordsInSection(filename, sectionName)) {
3942
if (definedKeys.contains(keyword)) continue
40-
val deprecated = sdr.isDeprecated(sectionName, keyword)
43+
val deprecated = sdr.isDeprecated(filename, sectionName, keyword)
4144
val builder = LookupElementBuilder
4245
.create(keyword)
4346
.withInsertHandler(KeyInsertHandler())

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/UnitFileValueCompletionContributor.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class UnitFileValueCompletionContributor : CompletionContributor() {
4444
val sectionName = section.sectionName
4545
val keyName = property.key
4646
val sdr = SemanticDataRepository.instance
47-
val validator = sdr.getOptionValidator(sectionName, keyName)
47+
val filename = section.containingFile.name
48+
49+
val validator = sdr.getOptionValidator(filename, sectionName, keyName)
4850
resultSet.addAllElements(
4951
validator.getAutoCompleteOptions(property.project)
5052
.stream()

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/documentation/UnitFileDocumentationProvider.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class UnitFileDocumentationProvider : AbstractDocumentationProvider() {
2626
val sectionName = section.sectionName
2727
val keyName = element.node.text
2828
val sdr: SemanticDataRepository = SemanticDataRepository.instance
29-
val keyComment = sdr.getDocumentationContentForKeyInSection(sectionName, keyName)
29+
val filename = section.containingFile.name
30+
31+
val keyComment = sdr.getDocumentationContentForKeyInSection(filename, sectionName, keyName)
3032
if (keyComment != null) {
3133
return DocumentationMarkup.DEFINITION_START + keyName + DocumentationMarkup.DEFINITION_END + DocumentationMarkup.CONTENT_START + keyComment + DocumentationMarkup.CONTENT_END
3234
}
@@ -53,13 +55,14 @@ class UnitFileDocumentationProvider : AbstractDocumentationProvider() {
5355
val section = PsiTreeUtil.getParentOfType(element, UnitFileSectionType::class.java) ?: return null
5456
val sectionName = section.sectionName
5557
val keyName = element.text
58+
val fname = section.containingFile.name
5659
val sdr: SemanticDataRepository = SemanticDataRepository.instance
57-
val url = sdr.getKeywordDocumentationUrl(sectionName, keyName)
60+
val url = sdr.getKeywordDocumentationUrl(fname, sectionName, keyName)
5861
if (url != null) {
5962
return listOf(url)
6063
}
61-
val keyNameToPointTo = sdr.getKeywordLocationInDocumentation(sectionName, keyName)
62-
val filename = sdr.getKeywordFileLocationInDocumentation(sectionName, keyName)
64+
val keyNameToPointTo = sdr.getKeywordLocationInDocumentation(fname, sectionName, keyName)
65+
val filename = sdr.getKeywordFileLocationInDocumentation(fname, sectionName, keyName)
6366
if (keyNameToPointTo != null && filename != null) {
6467
return listOf(
6568
"https://www.freedesktop.org/software/systemd/man/" + filename.replaceFirst(".xml$".toRegex(), ".html") + "#"

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/DeprecatedOptionsInspection.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ class DeprecatedOptionsInspection : LocalInspectionTool() {
2626
val sdr = SemanticDataRepository.instance
2727
val sectionName = section.sectionName
2828
val key = property.key
29-
if (sdr.isDeprecated(sectionName, key)) {
30-
val text = sdr.getDeprecationReason(sectionName, key, false)
29+
val filename = section.containingFile.name
30+
31+
if (sdr.isDeprecated(filename, sectionName, key)) {
32+
val text = sdr.getDeprecationReason(filename, sectionName, key, false)
3133
holder.registerProblem(property.keyNode.psi, text!!, ProblemHighlightType.LIKE_DEPRECATED)
3234
}
3335
}

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/InvalidValueInspection.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class InvalidValueInspection : LocalInspectionTool() {
2424
val section = PsiTreeUtil.getParentOfType(property, UnitFileSectionGroups::class.java) ?: return
2525
property.valueText ?: return
2626
val key = property.key
27-
val ovi = SemanticDataRepository.instance.getOptionValidator(section.sectionName, key)
27+
val filename = section.containingFile.name
28+
val ovi = SemanticDataRepository.instance.getOptionValidator(filename, section.sectionName, key)
2829
ovi.generateProblemDescriptors(property, holder)
2930
}
3031
}

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/ShellSyntaxInExecDirectiveInspection.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class ShellSyntaxInExecDirectiveInspection : LocalInspectionTool() {
3838
val section = PsiTreeUtil.getParentOfType(property, UnitFileSectionGroups::class.java) ?: return
3939
val value = property.valueText ?: return
4040
val key = property.key
41-
if (SemanticDataRepository.instance.getOptionValidator(section.sectionName, key) !is ExecOptionValue) return
41+
val filename = section.containingFile.name
42+
if (SemanticDataRepository.instance.getOptionValidator(filename, section.sectionName, key) !is ExecOptionValue) return
4243
val completedString = StringBuilder()
4344
val im = holder.manager
4445
while (completedString.length < value.length) {

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/inspections/UnknownKeyInSectionInspection.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class UnknownKeyInSectionInspection : LocalInspectionTool() {
4545
return
4646
}
4747

48-
if (!SemanticDataRepository.instance.getAllowedKeywordsInSectionFromValidators(sectionName).contains(key)) {
48+
val filename = section.containingFile.name
49+
if (!SemanticDataRepository.instance.getAllowedKeywordsInSectionFromValidators(filename, sectionName).contains(key)) {
4950
// TODO Figure out what highlight to use
5051
holder.registerProblem(property.keyNode.psi, INSPECTION_TOOL_TIP_TEXT, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)
5152
}

0 commit comments

Comments
 (0)