Skip to content

Commit

Permalink
add bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilja Postnovs committed May 10, 2024
1 parent 8ac7534 commit 50076ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/classes/registrators/DiagnosticsRegistrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class DiagnosticsRegistrator {
const changeActiveTextEditor = vscode.window.onDidChangeActiveTextEditor(editor => {
const fileName = editor?.document.fileName;
if (editor && fileName) {
this.updateDiagnosticCollection(editor.document);
this.updateDiagnosticCollection(editor.document, true);
}
});

Expand Down Expand Up @@ -96,7 +96,7 @@ export class DiagnosticsRegistrator {
}
}

static updateDiagnosticCollection(document: vscode.TextDocument) {
static updateDiagnosticCollection(document: vscode.TextDocument, refreshCode = false) {
const fileName = document.fileName;
const parser = ParserPool.getParserForFile(fileName);
if (!parser) {
Expand All @@ -110,16 +110,16 @@ export class DiagnosticsRegistrator {
}
this._updateXMLDiagnostics(document, xmlDiagnosticCollection);
} else if (fileName.endsWith(".js")) {
// const className = parser.fileReader.getClassNameFromPath(fileName);
// if (className) {
// parser.classFactory.setNewCodeForClass(className, document.getText(), bForce);
// }
const className = parser.fileReader.getClassNameFromPath(fileName);
if (className && refreshCode) {
parser.classFactory.setNewCodeForClass(className, document.getText(), true);
}
this._updateJSDiagnostics(document, jsDiagnosticCollection);
} else if (fileName.endsWith(".ts")) {
// const className = parser.fileReader.getClassNameFromPath(fileName);
// if (className) {
// parser.classFactory.setNewCodeForClass(className, document.getText(), bForce);
// }
const className = parser.fileReader.getClassNameFromPath(fileName);
if (className && refreshCode) {
parser.classFactory.setNewCodeForClass(className, document.getText(), true);
}
this._updateTSDiagnostics(document, tsDiagnosticCollection);
} else if (fileName.endsWith(".properties")) {
this._updatePropertiesDiagnostics(document, propertiesDiagnosticCollection);
Expand Down
13 changes: 12 additions & 1 deletion src/classes/utils/FileWatcherMediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export class FileWatcherMediator {
const currentClassNameDotNotation = parser.fileReader.getClassNameFromPath(document.fileName);
if (currentClassNameDotNotation) {
const UIClass = parser.classFactory.getUIClass(currentClassNameDotNotation) as AbstractCustomClass;
const textChanged = force || UIClass.classText !== document.getText();
const textChanged =
force ||
UIClass.classText.length !== document.getText().length ||
UIClass.classText !== document.getText();
if (FileWatcherMediator._parsingTimeout[document.fileName]) {
clearTimeout(FileWatcherMediator._parsingTimeout[document.fileName]);
}
Expand Down Expand Up @@ -106,12 +109,20 @@ export class FileWatcherMediator {
} else if (document.fileName.endsWith(".view.xml")) {
const viewContent = document.getText();
parser.fileReader.setNewViewContentToCache(viewContent, toNative(document.uri.fsPath), true);

EventBus.fireCodeUpdated(document);
} else if (document.fileName.endsWith(".fragment.xml")) {
parser.fileReader.setNewFragmentContentToCache(document.getText(), toNative(document.fileName), true);

EventBus.fireCodeUpdated(document);
} else if (document.fileName.endsWith("18n.properties")) {
parser.resourceModelData.updateCache(new TextDocumentAdapter(document));

EventBus.fireCodeUpdated(document);
} else if (document.fileName.endsWith("manifest.json")) {
parser.fileReader.rereadAllManifests();

EventBus.fireCodeUpdated(document);
}

this._updateDiagnosticsIfNecessary(document);
Expand Down

0 comments on commit 50076ed

Please sign in to comment.