Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions gen/oap/application/plugin/gen/parser/OapParser.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions grammars/oap.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ module ::=
[]
module_name_pair
( &'enabled' module_enabled )?
( &'include' module_include )?
( &'include' module_include )*
( &'dependsOn' module_depends_on )?
( &'include' module_include )?
( &'include' module_include )*
( &'services' module_services )?
( &'include' module_include )?
( &'include' module_include )*
( &'configurations' module_configurations )? {
pin = 1
recoverWhile=recover_module
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package oap.application.plugin.ref

import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.stubs.StubIndex
import oap.application.plugin.gen.psi.OapModuleDependsOnName
import oap.application.plugin.psi.ModuleUtils
import oap.application.plugin.stub.OapModuleNameIndex

class ValidParametersInspection : LocalInspectionTool() {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
return object : PsiElementVisitor() {
override fun visitElement(element: PsiElement) {
if (element is OapModuleDependsOnName) {
// val project: Project = element.project
//
// var allKeys: Collection<String> = StubIndex.getInstance().getAllKeys(OapModuleNameIndex.KEY, project)
//
// val moduleName: String? = element.text
//
// val thisModuleName: String? = ModuleUtils.getModuleName(element.containingFile)
//
// if (thisModuleName != null && thisModuleName == moduleName) {
// holder.registerProblem(
// element,
// "Cycle reference to self",
// ProblemHighlightType.ERROR
// )
// }
//
// if (!allKeys.contains(moduleName)) {
// holder.registerProblem(
// element,
// "Module '${moduleName ?: ""}' not found",
// ProblemHighlightType.ERROR
// )
// }
} else {
super.visitElement(element)
}
}
}
}
}
5 changes: 5 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
displayName="Required valid module name" groupName="OAP" enabledByDefault="true"
level="ERROR"/>

<localInspection language="OAP"
implementationClass="oap.application.plugin.ref.ValidParametersInspection"
displayName="Required valid parameter name" groupName="OAP" enabledByDefault="true"
level="ERROR"/>

<!-- index -->
<stubIndex implementation="oap.application.plugin.stub.OapModuleNameIndex"/>
<stubIndex implementation="oap.application.plugin.stub.OapModuleServicesServiceIndex"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package oap.application.plugin.inspection

import oap.application.plugin.OapFixtureTestCase
import oap.application.plugin.ref.ValidParametersInspection

class OapParametersTest : OapFixtureTestCase() {
protected override fun setUp() {
super.setUp()

myFixture.enableInspections(ValidParametersInspection::class.java)
}

override fun getBasePath(): String {
return "inspection"
}

fun testParameterAsField() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class OapParserTest : ParsingTestCase("parser", "oap", OapParserDefinition()) {
fun testInclude() {
doTest(false)
}
fun testInclude2() {
doTest(false)
}

fun testInvalidServices() {
doTest(true)
Expand Down
7 changes: 7 additions & 0 deletions testdata/parser/Include2.oap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = Include2

include required("1")
include required("2")
include required("3")
include required("4")
include required("5")
48 changes: 48 additions & 0 deletions testdata/parser/Include2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
OAP_FILE
OAP_MODULE_NAME_PAIR
PsiElement(name)('name')
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
OAP_MODULE_NAME
PsiElement(key_value)('Include2')
PsiWhiteSpace('\n\n')
OAP_MODULE_INCLUDE
PsiElement(include)('include')
PsiWhiteSpace(' ')
PsiElement(required)('required')
PsiElement(()('(')
PsiElement(include_resource_name)('"1"')
PsiElement())(')')
PsiWhiteSpace('\n')
OAP_MODULE_INCLUDE
PsiElement(include)('include')
PsiWhiteSpace(' ')
PsiElement(required)('required')
PsiElement(()('(')
PsiElement(include_resource_name)('"2"')
PsiElement())(')')
PsiWhiteSpace('\n')
OAP_MODULE_INCLUDE
PsiElement(include)('include')
PsiWhiteSpace(' ')
PsiElement(required)('required')
PsiElement(()('(')
PsiElement(include_resource_name)('"3"')
PsiElement())(')')
PsiWhiteSpace('\n')
OAP_MODULE_INCLUDE
PsiElement(include)('include')
PsiWhiteSpace(' ')
PsiElement(required)('required')
PsiElement(()('(')
PsiElement(include_resource_name)('"4"')
PsiElement())(')')
PsiWhiteSpace('\n')
OAP_MODULE_INCLUDE
PsiElement(include)('include')
PsiWhiteSpace(' ')
PsiElement(required)('required')
PsiElement(()('(')
PsiElement(include_resource_name)('"5"')
PsiElement())(')')