Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Fix misc bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mundacho committed Oct 3, 2019
1 parent 9d9e6d3 commit 7b627b8
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 20 deletions.
3 changes: 2 additions & 1 deletion lsp-scala-plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.lsp4e,
org.eclipse.jface.text;bundle-version="3.15.300",
org.eclipse.ui.editors;bundle-version="3.12.0",
org.eclipse.gmf.runtime.draw2d.ui.render.awt;bundle-version="1.8.0",
org.apache.commons.io;bundle-version="2.6.0"
org.apache.commons.io;bundle-version="2.6.0",
com.google.gson;bundle-version="2.7.0"
Bundle-Activator: com.idiomaticsoft.lsp.scala.ScalaLSPPlugin
Bundle-Vendor: Idiomaticsoft S.R.L.
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ScalaLSPPlugin extends AbstractUIPlugin {
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "scala.meta.metals.Main")
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false)
wc.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, false)
val vmParams = "-XX:+UseG1GC -XX:+UseStringDeduplication -Xss4m -Xms100m -Xmx2G -Dmetals.http=true -Dmetals.status-bar=on -Dmetals.icons=unicode -Dmetals.slow-task=on -Dmetals.execute-client-command=on -Dmetals.input-box=on"
val vmParams = "-XX:+UseG1GC -XX:+UseStringDeduplication -Xss4m -Xms100m -Xmx2G -Dmetals.status-bar=on -Dmetals.icons=unicode -Dmetals.slow-task=on -Dmetals.execute-client-command=on -Dmetals.input-box=on -Dmetals.extensions=true -Dmetals.show-message-request=on "
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmParams))
wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID,"com.idiomaticsoft.lsp.scala.metalsprocess")
val config = wc.doSave()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ import com.idiomaticsoft.lsp.scala.metals.operations.inputbox.MetalsInputBoxPara
import org.eclipse.jface.dialogs.InputDialog
import org.eclipse.jface.window.Window
import com.idiomaticsoft.lsp.scala.metals.operations.inputbox.MetalsInputBoxResult
import org.eclipse.swt.layout.FillLayout
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.JsonParser


class MetalsLanguageClientImpl extends LanguageClientImpl with MetalsLanguageClient {

var shell: Shell = _
var browser:Browser = _

val parser = new JsonParser

override def metalsStatus(status: MetalsStatusParams) = {
ScalaLSPPlugin.setStatusBar(status)
Expand Down Expand Up @@ -78,28 +84,57 @@ class MetalsLanguageClientImpl extends LanguageClientImpl with MetalsLanguageCli

override def executeClientCommand(executeCommandParams: ExecuteCommandParams) = {
if (executeCommandParams.getCommand == "metals-doctor-run") {
println("Called " + executeCommandParams.getCommand)
shell = new Shell(Display.getCurrent())
browser = new Browser(shell, SWT.NONE );
browser.setText(executeCommandParams.getArguments().get(0).asInstanceOf[String])
Display.getDefault().asyncExec(() => {
shell = new Shell(Display.getCurrent())
shell.setLayout(new FillLayout)
browser = new Browser(shell, SWT.NONE);
browser.setText(
"""
<html>
<head>
<title>Metals Doctor</title>
</head>
<body>
""" +
parser.parse(executeCommandParams.getArguments().get(0).toString()).getAsString() +
"""
</body>
</html>
""")
shell.pack()
shell.setSize(400, 300)
shell.open()
})
} else if (executeCommandParams.getCommand == "metals-doctor-reload") {
println("Called " + executeCommandParams.getCommand)
if (shell.isEnabled()) {
browser.setText(executeCommandParams.getArguments().get(0).asInstanceOf[String])
if (Option(shell).map(_.isEnabled()).getOrElse(false)) {
browser.setText(
"""
<html>
<head>
<title>Metals Doctor</title>
</head>
<body>
""" +
parser.parse(executeCommandParams.getArguments().get(0).toString()).getAsString() +
"""
</body>
</html>
""")
browser.refresh()
}
} else if (executeCommandParams.getCommand == "metals-logs-toggle") {
Display.getCurrent().asyncExec(() => {
Display.getDefault().asyncExec(() => {
val id = IConsoleConstants.ID_CONSOLE_VIEW
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id)
})
} else if (executeCommandParams.getCommand == "metals-diagnostics-focus") {
Display.getCurrent().asyncExec(() => {
Display.getDefault().asyncExec(() => {
val id = IPageLayout.ID_PROBLEM_VIEW
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id)
})
} else if (executeCommandParams.getCommand == "metals-goto-location") {
val location = executeCommandParams.getArguments().get(0).asInstanceOf[Location]
Display.getCurrent().asyncExec(() => {
Display.getDefault().asyncExec(() => {
LSPEclipseUtils.openInEditor(location, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage())
})
} else if (executeCommandParams.getCommand == "metals-echo-command") {
Expand All @@ -114,7 +149,8 @@ class MetalsLanguageClientImpl extends LanguageClientImpl with MetalsLanguageCli

override def inputBox(metalsInputBoxParams: MetalsInputBoxParams) = {
val f = new CompletableFuture[MetalsInputBoxResult]
Display.getCurrent().asyncExec(() => {
Display.getDefault().asyncExec(() => {
println("Hello!")
val dialog = if (metalsInputBoxParams.getPassword()) {
new InputDialog(Display.getCurrent().getActiveShell(),
"Metals LSP",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.idiomaticsoft.lsp.scala.metals.operations.inputbox
import scala.beans.BeanProperty


class MetalsInputBoxParams(
@BeanProperty var value: String,
@BeanProperty var prompt: String,
@BeanProperty var placeHolder: String,
@BeanProperty var password: Boolean,
@BeanProperty var ignoreFocusOut: Boolean
)

class MetalsInputBoxResult(
@BeanProperty var value: String,
@BeanProperty var cancelled: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class MetalsTreeView extends ViewPart {
parentView = parent
parentView.pack()
parentView.update()
controller.initView()
}

def fillExpandBar(viewId: String, treeViewNodes: Array[TreeViewNode]) = {
Expand Down Expand Up @@ -204,6 +205,7 @@ class MetalsTreeView extends ViewPart {

def expandBar(viewId:String) = viewsTo.get(viewId).map(_._1)

override def setFocus(): Unit = {}
override def setFocus(): Unit = {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ trait MetalsTreeViewController {

def getChildren(treeViewNode: TreeViewNode): Array[TreeViewNode]

def initView(): Unit

def languageServer(): MetaslServerInterface
}

Expand All @@ -52,11 +54,11 @@ class MetalsTreeViewControllerImpl extends MetalsTreeViewController {

val childToParent = new scala.collection.mutable.HashMap[String, TreeViewNode]


var initialNodes: Array[TreeViewNode] = Array()

private var metalsTreeView: MetalsTreeView = _

override def parentNodes(viewId: String): List[TreeViewNode] = parentNodesMap(viewId).toList// parentNodesMap.keys.toList.sorted.map(parentNodesMap(_))
override def parentNodes(viewId: String): List[TreeViewNode] = parentNodesMap(viewId).toList

private def createUriChain(node: TreeViewNode, list: List[String]): List[String] = {
Option(node.getNodeUri()) match {
Expand All @@ -71,15 +73,19 @@ class MetalsTreeViewControllerImpl extends MetalsTreeViewController {
list
}
}

override def initView(): Unit = {
setParentNode(initialNodes)
}

override def setParentNode(nodes: Array[TreeViewNode]): Unit = {
Display.getDefault().asyncExec(() =>
for {
(for {
theView <- Option(view)
} {
} yield {
for {
node <- nodes
} yield {
} {
(parentNodesMap.get(node.getViewId()), Option(node.getNodeUri())) match {
case (None, None) =>
// this only happens with the top level values
Expand All @@ -99,9 +105,12 @@ class MetalsTreeViewControllerImpl extends MetalsTreeViewController {
// should not happen
}
}
}).getOrElse {
initialNodes = nodes
}
)
}
}


def contentProvider(viewId: String): MetalsTreeContentProvider = {
new MetalsTreeContentProvider(this, languageServer(), metalsTreeView, viewId)
Expand Down

0 comments on commit 7b627b8

Please sign in to comment.