Skip to content

Commit

Permalink
[ #87 ] enhance highlighter and navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
zxj5470 committed Jan 31, 2019
1 parent ed8e50c commit 989aade
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
16 changes: 12 additions & 4 deletions src/org/ice1000/julia/lang/editing/julia-annotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ $JULIA_DOC_SURROUNDING
}
JuliaSymbolKind.FunctionParameter -> holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.FUNCTION_PARAMETER
JuliaSymbolKind.TypeName -> holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.TYPE_NAME
JuliaSymbolKind.TypeName -> {
if (element.isAbstractTypeRef) holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.ABSTRACT_TYPE_NAME
holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.TYPE_NAME
}
JuliaSymbolKind.KeywordParameterName -> holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.KEYWORD_ARGUMENT
else -> {
Expand All @@ -220,8 +224,12 @@ $JULIA_DOC_SURROUNDING
.textAttributes = JuliaHighlighter.CONST_NAME
element.isTypeNameRef -> holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.TYPE_NAME
element.isAbstractTypeRef -> holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.ABSTRACT_TYPE_NAME
element.isSuperTypeExpr -> {
val attr = if (element.isAbstractTypeRef) JuliaHighlighter.ABSTRACT_TYPE_NAME
else JuliaHighlighter.TYPE_NAME
holder.createInfoAnnotation(element, null)
.textAttributes = attr
}
element.isModuleNameRef -> holder.createInfoAnnotation(element, null)
.textAttributes = JuliaHighlighter.MODULE_NAME
element.isQuoteCall -> holder.createInfoAnnotation(element.parent
Expand Down
12 changes: 6 additions & 6 deletions src/org/ice1000/julia/lang/psi/julia-navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class JuliaGotoDeclarationHandler : GotoDeclarationHandler {
JuliaSymbolKind.ApplyFunctionName -> {
if (juliaSymbol.text in IGNORED) return null
val executor = Executors.newCachedThreadPool()
var result: Array<PsiElement>? = null
val result: MutableCollection<PsiElement> = arrayListOf()
val future = executor.submit {
try {
ReadAction.compute<Array<PsiElement>?, Throwable> {
ReadAction.compute<Unit, Throwable> {
project.languageServer.searchFunctionsByName(juliaSymbol.text)?.let { ret ->
if (ret.startsWith("__INTELLIJ__")) return@let null
val unescaped = StringEscapeUtils.unescapeJava(ret.trim('"'))
Expand All @@ -82,20 +82,20 @@ class JuliaGotoDeclarationHandler : GotoDeclarationHandler {
val psiFile = PsiManager.getInstance(project).findFile(vf) ?: return@mapNotNull null
val elem = psiFile.findElementAt(psiOffset + 1) ?: return@mapNotNull null
PsiTreeUtil.getNonStrictParentOfType(elem, JuliaCompactFunction::class.java, JuliaFunction::class.java)
}.toTypedArray().also { result = it }
}.toTypedArray().also { result.addAll(it) }
} catch (e: Exception) {
e.printStackTrace()
result
}
} ?: result
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
return try {
future?.get(5000, TimeUnit.MILLISECONDS)
result
result.addAll(JuliaTypeDeclarationIndex.findElementsByName(project, juliaSymbol.text))
result.toTypedArray()
} catch (ignored: Throwable) {
null
}
Expand Down

0 comments on commit 989aade

Please sign in to comment.