MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / start

Method start

src/common/lsp/server/serverapplication.cpp:44–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void ServerApplication::start()
45{
46 _globalServer = this;
47 QObject::connect(qApp, &QCoreApplication::destroyed, qApp, [=](){
48 delete this;
49 });
50 if (ServerCmdParse::parentPid()) {
51 unsigned int ppid = ServerCmdParse::parentPid().value();
52 d->globalPPidWatcher = new QTimer;
53 d->globalPPidWatcher->setInterval(300);
54 QObject::connect(d->globalPPidWatcher, &QTimer::timeout, [=](){
55 QProcess process;
56#ifdef __linux__
57 process.setProgram("ps");
58 process.setArguments({"--pid", QString::number(ppid)});
59 process.start();
60 process.waitForFinished();
61 QByteArray queryPidLines = process.readAllStandardOutput();
62 if (queryPidLines.isEmpty() || queryPidLines.count('\n') < 2) {
63 lspServErr << "not found parent pid:"
64 << std::to_string(ppid)
65 << "qApp quit";
66 exit(1001);
67 }
68#endif
69 });
70 d->globalPPidWatcher->start();
71 }
72
73 auto doStdioLauch = [=](){
74 if (!d->stdinParser) {
75 d->stdinParser = new StdinJsonRpcParser;
76 QObject::connect(d->stdinParser, &StdinJsonRpcParser::readedJsonObject,
77 this, &ServerApplication::identifyJsonObject,
78 Qt::ConnectionType::DirectConnection);
79 d->stdinParser->start();
80 }
81 lspServOut << "Initialization succeeded, mode's stdio";
82 };
83
84 if (ServerCmdParse::mode()) {
85 std::string mode = ServerCmdParse::mode().value();
86 if (mode == newlsp::tcp.toStdString()) {
87 lspServErr << "This function is not implemented yet. "
88 "It is started in stdio mode by default";
89 }
90 if (ServerCmdParse::mode() == newlsp::stdio.toStdString()) {
91 doStdioLauch();
92 }
93 }
94 doStdioLauch();
95}
96
97ServerApplication::ServerApplication(const QCoreApplication &app)
98 : ServerCmdParse (app)

Callers 1

ClientPrivateMethod · 0.45

Calls 10

connectFunction · 0.85
numberClass · 0.85
to_stringFunction · 0.85
exitFunction · 0.85
readAllStandardOutputMethod · 0.80
valueMethod · 0.45
setProgramMethod · 0.45
setArgumentsMethod · 0.45
isEmptyMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected