-
Here is my naive simple code. I want to add errors to a file (without LSP). Just from within my code. import {injectable} from 'inversify';
import {Diagnostic, DiagnosticCollection, DiagnosticSeverity, languages, Position, Range, Uri} from '@theia/plugin';
@injectable()
export class ProblemContributor {
private diagnosticsCollection: DiagnosticCollection;
constructor() {
this.diagnosticsCollection = languages.createDiagnosticCollection('formula-editor');
}
addProblem(filePath: string, line: number, message: string) {
const uri = Uri.file(filePath);
const range = new Range(new Position(line, 0), new Position(line, 100)); // Adjust as needed
const diagnostic = new Diagnostic(range, message, DiagnosticSeverity.Error);
this.diagnosticsCollection.set(uri, [diagnostic]);
}
} I tried it in node and in the browser. Adding I get:
Then I added And I get
Then I added Lots of errors. The I tried:
Now I get the following build Error
...and many more variations -- each one leading to another error. I cannot figure out what dependency I am missing. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
may be related to TypeFox/monaco-languageclient#242 |
Beta Was this translation helpful? Give feedback.
-
...many hours later.... it boild down to
I simply cannot figure out how to use anything in I guess I have to do some magic inject or something else... Google is not your friend when it comes to searching solutions for theia.... |
Beta Was this translation helpful? Give feedback.
-
It would be very helpful to have at least a hint small of how to use the API in the packages/plugin/README.md. There are plenty of documents and videos describing all kinds of concepts, but a basic code snippet (including imports and the required packages) would be extremely helpful to explain how to consume anything in In the packages/plugin/README.md there is a basic snippet, but it does not explain how I get to the variable theia.commands.registerCommand({id:'say.hello.command'}, ()=>{
console.log("Hello World!");
}); |
Beta Was this translation helpful? Give feedback.
-
Hey @scharf, The You could either write a VS Code extension that contributes that feature to your IDE (the |
Beta Was this translation helpful? Give feedback.
Hey @scharf,
The
@theia/plugin
package/API isn't designed to be used by Theia applications, but rather Theia plugins (more commonly known as VS Code extensions).You could either write a VS Code extension that contributes that feature to your IDE (the
Diagnostic
API is available there without going through the hoops of building a language server) and include that in your Theia app, or use the underlying Theia API (which would be the@theia/markers
package) in your Theia extension.