Java 类org.eclipse.lsp4j.MessageType 实例源码

项目:camel-language-server    文件:CamelLanguageServer.java   
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
    sendLogMessageNotification(MessageType.Info, "Initializing capabilities of the server...");
    Integer processId = params.getProcessId();
    if(processId != null) {
        setParentProcessId(processId.longValue());
    } else {
        sendLogMessageNotification(MessageType.Info, "Missing Parent process ID!!");
        setParentProcessId(0);
    }

    InitializeResult result = new InitializeResult();

    ServerCapabilities capabilities = new ServerCapabilities();
    capabilities.setTextDocumentSync(TextDocumentSyncKind.Full);
    capabilities.setCompletionProvider(new CompletionOptions(Boolean.TRUE, Arrays.asList(".","?","&", "\"", "=")));
    capabilities.setHoverProvider(Boolean.TRUE);

    result.setCapabilities(capabilities);
    return CompletableFuture.completedFuture(result);
}
项目:che    文件:ShowMessageRequestTest.java   
@Test
public void testName() throws Exception {
  CompletableFuture<MessageActionItem> future = new CompletableFuture<>();
  when(transmitter.sendShowMessageRequest(any())).thenReturn(future);

  ServerInitializerImpl initializer = new ServerInitializerImpl();
  CheLanguageClient client = new CheLanguageClient(eventService, transmitter, "id");
  CompletableFuture<Pair<LanguageServer, InitializeResult>> initialize =
      initializer.initialize(launcher, client, "/tmp");
  Pair<LanguageServer, InitializeResult> resultPair = initialize.get();
  server = resultPair.first;
  ArgumentCaptor<ShowMessageRequestParams> captor =
      ArgumentCaptor.forClass(ShowMessageRequestParams.class);
  verify(transmitter, timeout(1500)).sendShowMessageRequest(captor.capture());

  ShowMessageRequestParams value = captor.getValue();
  assertNotNull(value);
  assertEquals(value.getType(), MessageType.Error);
  assertEquals(value.getMessage(), "Error Message!!!!");
}
项目:SOMns-vscode    文件:SomLanguageServer.java   
private void loadWorkspace(final InitializeParams params) {
  try {
    som.loadWorkspace(params.getRootUri());
  } catch (URISyntaxException e) {
    MessageParams msg = new MessageParams();
    msg.setType(MessageType.Error);
    msg.setMessage("Workspace root URI invalid: " + params.getRootUri());

    client.logMessage(msg);

    ServerLauncher.logErr(msg.getMessage());
  }
}
项目:SOMns-vscode    文件:SomAdapter.java   
public void reportError(final String msgStr) {
  MessageParams msg = new MessageParams();
  msg.setType(MessageType.Log);
  msg.setMessage(msgStr);

  client.logMessage(msg);

  ServerLauncher.logErr(msgStr);
}
项目:eclipse.jdt.ls    文件:ProjectsManager.java   
public void fileChanged(String uriString, CHANGE_TYPE changeType) {
    if (uriString == null) {
        return;
    }
    IResource resource = JDTUtils.findFile(uriString);
    if (resource == null) {
        return;
    }
    try {
        if (changeType == CHANGE_TYPE.DELETED) {
            resource = resource.getParent();
        }
        if (resource != null) {
            resource.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
        }
        if (isBuildFile(resource)) {
            FeatureStatus status = preferenceManager.getPreferences().getUpdateBuildConfigurationStatus();
            switch (status) {
                case automatic:
                    updateProject(resource.getProject());
                    break;
                case disabled:
                    break;
                default:
                    if (client != null) {
                        String cmd = "java.projectConfiguration.status";
                        TextDocumentIdentifier uri = new TextDocumentIdentifier(uriString);
                        ActionableNotification updateProjectConfigurationNotification = new ActionableNotification().withSeverity(MessageType.Info)
                                .withMessage("A build file was modified. Do you want to synchronize the Java classpath/configuration?").withCommands(asList(new Command("Never", cmd, asList(uri, FeatureStatus.disabled)),
                                        new Command("Now", cmd, asList(uri, FeatureStatus.interactive)), new Command("Always", cmd, asList(uri, FeatureStatus.automatic))));
                        client.sendActionableNotification(updateProjectConfigurationNotification);
                    }
            }
        }
    } catch (CoreException e) {
        JavaLanguageServerPlugin.logException("Problem refreshing workspace", e);
    }
}
项目:eclipse.jdt.ls    文件:LogHandler.java   
private MessageType getMessageTypeFromSeverity(int severity) {
    switch (severity) {
    case IStatus.ERROR:
        return MessageType.Error;
    case IStatus.WARNING:
        return MessageType.Warning;
    case IStatus.INFO:
        return MessageType.Info;
    default:
        return MessageType.Log;
    }
}
项目:eclipse.jdt.ls    文件:Preferences.java   
public MessageType toMessageType() {
    for (MessageType type : MessageType.values()) {
        if (name().equalsIgnoreCase(type.name())) {
            return type;
        }
    }
    //'ignore' has no MessageType equivalent
    return null;
}
项目:eclipse.jdt.ls    文件:JavaClientConnection.java   
/**
 * Sends the logMessage message back to the client as a notification
 * @param msg The message to send back to the client
 */
public void logMessage(MessageType type, String msg) {
    MessageParams $= new MessageParams();
    $.setMessage(msg);
    $.setType(type);
    client.logMessage($);
}
项目:eclipse.jdt.ls    文件:JavaClientConnection.java   
/**
 * Sends the message to the client, to be displayed on a UI element.
 *
 * @param type
 * @param msg
 */
public void showNotificationMessage(MessageType type, String msg){
    MessageParams $ = new MessageParams();
    $.setMessage(msg);
    $.setType(type);
    client.showMessage($);
}
项目:lsp4j    文件:LauncherTest.java   
@Test public void testNotification() throws IOException {

    MessageParams p = new MessageParams();
    p.setMessage("Hello World");
    p.setType(MessageType.Info);

    client.expectedNotifications.put("window/logMessage", p);
    serverLauncher.getRemoteProxy().logMessage(p);
    client.joinOnEmpty();
}
项目:che    文件:PomReconciler.java   
public void reconcilePath(String fileLocation, String projectPath) {
  String fileName = new Path(fileLocation).lastSegment();
  if (!POM_FILE_NAME.equals(fileName)) {
    return;
  }

  EditorWorkingCopy workingCopy = editorWorkingCopyManager.getWorkingCopy(fileLocation);
  if (workingCopy == null) {
    return;
  }

  String newPomContent = workingCopy.getContentAsString();
  if (isNullOrEmpty(newPomContent)) {
    return;
  }

  List<Problem> problems;
  try {
    problems = reconcile(fileLocation, projectPath, newPomContent);
    List<Diagnostic> diagnostics = convertProblems(newPomContent, problems);
    client.publishDiagnostics(
        new PublishDiagnosticsParams(LanguageServiceUtils.prefixURI(fileLocation), diagnostics));
  } catch (ServerException | NotFoundException e) {
    LOG.error(e.getMessage(), e);
    client.showMessage(new MessageParams(MessageType.Error, "Error reconciling " + fileLocation));
  }
}
项目:che    文件:PomReconciler.java   
public void reconcileUri(String uri, String text) {
  try {
    String pomPath = LanguageServiceUtils.removePrefixUri(uri);
    List<Problem> problems = reconcile(pomPath, new File(pomPath).getParent(), text);
    List<Diagnostic> diagnostics = convertProblems(text, problems);
    client.publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
  } catch (ServerException | NotFoundException e) {
    LOG.error("Error reconciling content: " + uri, e);
    client.showMessage(new MessageParams(MessageType.Error, "Error reconciling " + uri));
  }
}
项目:camel-language-server    文件:CamelLanguageServer.java   
@Override
public void connect(LanguageClient client) {
    this.client = client;
    sendLogMessageNotification(MessageType.Info, "Connected to Language Server...");
}
项目:SOMns-vscode    文件:MessageParams.java   
public MessageParams(@NonNull final MessageType type, @NonNull final String message) {
  this.type = type;
  this.message = message;
}
项目:SOMns-vscode    文件:MessageParams.java   
/**
 * The message type.
 */
@Pure
@NonNull
public MessageType getType() {
  return this.type;
}
项目:SOMns-vscode    文件:MessageParams.java   
/**
 * The message type.
 */
public void setType(@NonNull final MessageType type) {
  this.type = type;
}
项目:eclipse.jdt.ls    文件:ActionableNotification.java   
public ActionableNotification withSeverity(MessageType severity) {
    this.severity = severity;
    return this;
}
项目:eclipse.jdt.ls    文件:JavaClientConnection.java   
/**
 * Sends a message to the client to be presented to users, with possible commands to execute
 */
public void sendActionableNotification(MessageType severity, String message, Object data, List<Command> commands) {
    ActionableNotification notification = new ActionableNotification().withSeverity(severity).withMessage(message).withData(data).withCommands(commands);
    sendActionableNotification(notification);
}
项目:lsp4j    文件:MessageParams.java   
public MessageParams(@NonNull final MessageType type, @NonNull final String message) {
  this.type = type;
  this.message = message;
}
项目:lsp4j    文件:MessageParams.java   
/**
 * The message type.
 */
public void setType(@NonNull final MessageType type) {
  this.type = type;
}
项目:eclipse.jdt.ls    文件:JavaClientConnection.java   
/**
 * Sends the message to the client, to be displayed on a UI element.
 * Waits for an answer from the user and returns the selected
 * action.
 *
 * @param type
 * @param msg
 * @return
 */
public MessageActionItem showNotificationMessageRequest(MessageType type, String msg, List<MessageActionItem> actions){
    ShowMessageRequestParams $ = new ShowMessageRequestParams();
    $.setMessage(msg);
    $.setType(type);
    $.setActions(actions);
    return client.showMessageRequest($).join();
}
项目:lsp4j    文件:MessageParams.java   
/**
 * The message type.
 */
@Pure
@NonNull
public MessageType getType() {
  return this.type;
}
项目:camel-language-server    文件:CamelLanguageServer.java   
/**
 * Sends the given <code>log message notification</code> back to the client
 * as a notification
 * 
 * @param type
 *            the type of message
 * @param msg
 *            The message to send back to the client
 */
public void sendLogMessageNotification(final MessageType type, final String msg) {
    client.logMessage(new MessageParams(type, msg));
}
项目:camel-language-server    文件:CamelLanguageServer.java   
/**
 * Sends the given <code>show message notification</code> back to the client
 * as a notification
 * 
 * @param type
 *            the type of message
 * @param msg
 *            The message to send back to the client
 */
public void sendShowMessageNotification(final MessageType type, final String msg) {
    client.showMessage(new MessageParams(type, msg));
}
项目:eclipse.jdt.ls    文件:ActionableNotification.java   
/**
 * The message severity. See {@link MessageType}.
 *
 * @return
 *     The severity
 */
public MessageType getSeverity() {
    return severity;
}
项目:eclipse.jdt.ls    文件:ActionableNotification.java   
/**
 * The message severity. See {@link MessageType}.
 *
 * @param severity
 *     The message severity
 */
public void setSeverity(MessageType severity) {
    this.severity = severity;
}