Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisPower1 committed Sep 29, 2024
1 parent dc227a3 commit 627f8ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/interjs/inter-intellisense.git"
},
"module": "esnext",
"version": "1.2.0",
"version": "1.2.1",
"engines": {
"vscode": "^1.57.1"
},
Expand Down
23 changes: 14 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import { commentsParser, parserInfoInterface } from "./htmlcommentsparser";

const extensionVersion: string = "1.2.0";
const extensionVersion: string = "1.2.1";
const openTagRegExp = /<(:?[A-Z]+)>/gi;
interface configI {
text: string;
Expand All @@ -18,29 +18,32 @@ function getRegistered(
type: registeredT
): parserInfoInterface | undefined {
const registered = new commentsParser().parse(document);


let returnValue;
if (registered[0].type == type) returnValue = registered[0];
else if (registered[1].type == type) returnValue = registered[1];

if (registered[0]?.type == type) returnValue = registered[0];
else if (registered[1]?.type == type) returnValue = registered[1];
return returnValue;
}

function findUnregisteredRef(
documentContent: string,
document: vscode.TextDocument
): configI[] {
): configI[] | undefined {
const refReg = /\{(:?\s+)*(:?[A-Z]+)(:?\s+)*\}/gi;
const allRefs = documentContent.match(refReg) || [];
const unregistered = [];
const registered = getRegistered(documentContent, "ref");

if (!registered) return;

for (const ref of allRefs) {
const text = ref.replace("{", "").replace("}", "").trim();
const start = documentContent.indexOf(ref) + 1;
const position = document.positionAt(start);


const refSet = new Set(registered?.content);
const refSet = new Set(registered ? registered.content : []);

if (refSet.has(text)) continue;
else if (outOfCompletionArea(document, position)) continue;
Expand All @@ -59,13 +62,15 @@ function findUnregisteredRef(
return unregistered;
}

function findUnregisteredConditionalProps(documentContent: string): configI[] {
function findUnregisteredConditionalProps(documentContent: string): configI[] | undefined {
const attrsReg: RegExp =
/_if="(:?\s)*(:?[A-Z]+)(:?\s)*"|_elseIf="(:?\s)*(:?[A-Z]+)(:?\s)*"|_ifNot="(:?\s)*(:?[A-Z]+)(:?\s)*"|_else="(:?\s)*(:?[A-Z]+)(:?\s)*"/gi;
const allAttrs = documentContent.match(attrsReg) || [];
const unregistered = [];
const registered = getRegistered(documentContent, "conditional");

if (!registered) return;

for (const attr of allAttrs) {
let theConditionalAttrsLength: number = 0;
let attrName: string = "";
Expand Down Expand Up @@ -410,8 +415,8 @@ export function activate(context: vscode.ExtensionContext) {
findUnregisteredConditionalProps(documentContent);
const unregisteredRef = findUnregisteredRef(documentContent, document);

runDiagnosticLoop(unregisteredConditional, diagnostics, toPosition);
runDiagnosticLoop(unregisteredRef, diagnostics, toPosition);
if (unregisteredConditional) runDiagnosticLoop(unregisteredConditional, diagnostics, toPosition);
if (unregisteredRef) runDiagnosticLoop(unregisteredRef, diagnostics, toPosition);

diagnosticCollecction.set(document.uri, diagnostics);
}
Expand Down

0 comments on commit 627f8ae

Please sign in to comment.