Skip to content

Commit

Permalink
feat: navigation for class signature
Browse files Browse the repository at this point in the history
Add navigation for class signature. By the way, fix method navigation behavior.
  • Loading branch information
ceclin committed Apr 20, 2022
1 parent 38c0bda commit 814eb92
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
# BDLH Changelog

## [Unreleased]
### Added
- Navigation for class signature

### Changed
- Update pluginIcon.svg

### Fixed
- Subclasses resolving
- Method navigation behavior

## [0.1.0]
### Added
Expand Down
27 changes: 22 additions & 5 deletions src/main/gen/com/github/ceclin/bdlh/lang/BDLParser.java

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

2 changes: 1 addition & 1 deletion src/main/kotlin/com/github/ceclin/bdlh/lang/BDL.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ root ::= (signature|fallback)*

private fallback ::= LA | RA | LS | RS | LP | RP | DOT | SPACE | DOLLAR | COLON | COMMA | id | any

signature ::= LA class_name COLON SPACE (method|field) RA
signature ::= LA class_name (COLON SPACE (method|field))? RA
{methods=[getReference]}

class_name ::= type_name
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/com/github/ceclin/bdlh/lang/ImplExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RefToJava(element: BDLSignature) : PsiReferenceBase<BDLSignature>(element,
}

private fun resolveMethod(clazz: PsiClass, method: BDLMethod): PsiMethod? {
clazz.findMethodsByName(method.methodName.text, false).firstOrNull {
return clazz.findMethodsByName(method.methodName.text, false).firstOrNull {
val parameter = method.parameter
if (parameter == null)
it.hasParameters()
Expand All @@ -26,7 +26,6 @@ class RefToJava(element: BDLSignature) : PsiReferenceBase<BDLSignature>(element,
} == parameter.text
}
}
return clazz.findMethodsByName(method.methodName.text, false).firstOrNull()
}
}

Expand All @@ -36,8 +35,9 @@ class RefToJava(element: BDLSignature) : PsiReferenceBase<BDLSignature>(element,
// I don't know what jvmCompatible means. No document for this param.
val clazz = ClassUtil.findPsiClass(PsiManager.getInstance(project), className, null, true)
?: return null
return element.field?.let { resolveField(clazz, it) }
?: element.method?.let { resolveMethod(clazz, it) }
element.field?.let { return resolveField(clazz, it) }
element.method?.let { return resolveMethod(clazz, it) }
return clazz
}
}

0 comments on commit 814eb92

Please sign in to comment.