From 1aa61c8aa65faf836bdf6e4ea9ec70c054682c84 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Tue, 18 Jun 2019 12:18:29 -0400 Subject: [PATCH 1/6] Add `pin`s in BNF to improve parsing performance --- .../texifyidea/parser/BibtexParser.java | 201 ++++++------------ .../texifyidea/parser/LatexParser.java | 191 ++++++----------- .../rubensten/texifyidea/psi/BibtexEntry.java | 2 +- gen/nl/rubensten/texifyidea/psi/BibtexId.java | 17 +- .../rubensten/texifyidea/psi/BibtexTag.java | 2 +- .../texifyidea/psi/LatexEnvironment.java | 2 +- .../texifyidea/psi/LatexInlineMath.java | 2 +- .../rubensten/texifyidea/psi/LatexTypes.java | 29 +-- .../psi/impl/BibtexBracedStringImpl.java | 2 +- .../psi/impl/BibtexCommentImpl.java | 2 +- .../psi/impl/BibtexContentImpl.java | 2 +- .../texifyidea/psi/impl/BibtexEndtryImpl.java | 2 +- .../psi/impl/BibtexEntryContentImpl.java | 2 +- .../texifyidea/psi/impl/BibtexEntryImpl.java | 6 +- .../texifyidea/psi/impl/BibtexKeyImpl.java | 2 +- .../psi/impl/BibtexNormalTextImpl.java | 2 +- .../psi/impl/BibtexPreambleImpl.java | 2 +- .../psi/impl/BibtexQuotedStringImpl.java | 2 +- .../texifyidea/psi/impl/BibtexStringImpl.java | 2 +- .../texifyidea/psi/impl/BibtexTagImpl.java | 6 +- .../texifyidea/psi/impl/BibtexTypeImpl.java | 2 +- .../psi/impl/LatexBeginCommandImpl.java | 2 +- .../texifyidea/psi/impl/LatexCommentImpl.java | 2 +- .../texifyidea/psi/impl/LatexContentImpl.java | 2 +- .../psi/impl/LatexDisplayMathImpl.java | 2 +- .../psi/impl/LatexEndCommandImpl.java | 2 +- .../psi/impl/LatexEnvironmentContentImpl.java | 2 +- .../psi/impl/LatexEnvironmentImpl.java | 6 +- .../texifyidea/psi/impl/LatexGroupImpl.java | 2 +- .../psi/impl/LatexInlineMathImpl.java | 6 +- .../psi/impl/LatexMathContentImpl.java | 2 +- .../psi/impl/LatexMathEnvironmentImpl.java | 2 +- .../psi/impl/LatexNoMathContentImpl.java | 2 +- .../psi/impl/LatexNormalTextImpl.java | 2 +- .../psi/impl/LatexOpenGroupImpl.java | 2 +- .../psi/impl/LatexOptionalParamImpl.java | 2 +- .../psi/impl/LatexParameterImpl.java | 2 +- .../psi/impl/LatexRequiredParamImpl.java | 2 +- .../rubensten/texifyidea/grammar/Bibtex.bnf | 14 +- src/nl/rubensten/texifyidea/grammar/Latex.bnf | 16 +- 40 files changed, 206 insertions(+), 346 deletions(-) diff --git a/gen/nl/rubensten/texifyidea/parser/BibtexParser.java b/gen/nl/rubensten/texifyidea/parser/BibtexParser.java index 70d0ea575..e1e63b157 100644 --- a/gen/nl/rubensten/texifyidea/parser/BibtexParser.java +++ b/gen/nl/rubensten/texifyidea/parser/BibtexParser.java @@ -6,6 +6,7 @@ import static nl.rubensten.texifyidea.psi.BibtexTypes.*; import static com.intellij.lang.parser.GeneratedParserUtilBase.*; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.IFileElementType; import com.intellij.lang.ASTNode; import com.intellij.psi.tree.TokenSet; import com.intellij.lang.PsiParser; @@ -23,53 +24,11 @@ public void parseLight(IElementType t, PsiBuilder b) { boolean r; b = adapt_builder_(t, b, this, null); Marker m = enter_section_(b, 0, _COLLAPSE_, null); - if (t == BRACED_STRING) { - r = braced_string(b, 0); - } - else if (t == COMMENT) { - r = comment(b, 0); - } - else if (t == CONTENT) { - r = content(b, 0); - } - else if (t == DEFINED_STRING) { - r = defined_string(b, 0); - } - else if (t == ENDTRY) { - r = endtry(b, 0); - } - else if (t == ENTRY) { - r = entry(b, 0); - } - else if (t == ENTRY_CONTENT) { - r = entry_content(b, 0); - } - else if (t == ID) { - r = id(b, 0); - } - else if (t == KEY) { - r = key(b, 0); - } - else if (t == NORMAL_TEXT) { - r = normal_text(b, 0); - } - else if (t == PREAMBLE) { - r = preamble(b, 0); - } - else if (t == QUOTED_STRING) { - r = quoted_string(b, 0); - } - else if (t == STRING) { - r = string(b, 0); - } - else if (t == TAG) { - r = tag(b, 0); - } - else if (t == TYPE) { - r = type(b, 0); + if (t instanceof IFileElementType) { + r = parse_root_(t, b, 0); } else { - r = parse_root_(t, b, 0); + r = false; } exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); } @@ -82,11 +41,10 @@ protected boolean parse_root_(IElementType t, PsiBuilder b, int l) { // (entry | comment)* static boolean bibtexFile(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "bibtexFile")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!bibtexFile_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "bibtexFile", c)) break; - c = current_position_(b); } return true; } @@ -95,10 +53,8 @@ static boolean bibtexFile(PsiBuilder b, int l) { private static boolean bibtexFile_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "bibtexFile_0")) return false; boolean r; - Marker m = enter_section_(b); r = entry(b, l + 1); if (!r) r = comment(b, l + 1); - exit_section_(b, m, null, r); return r; } @@ -107,13 +63,14 @@ private static boolean bibtexFile_0(PsiBuilder b, int l) { public static boolean braced_string(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "braced_string")) return false; if (!nextTokenIs(b, OPEN_BRACE)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, BRACED_STRING, null); r = consumeToken(b, OPEN_BRACE); - r = r && braced_string_1(b, l + 1); - r = r && consumeToken(b, CLOSE_BRACE); - exit_section_(b, m, BRACED_STRING, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, braced_string_1(b, l + 1)); + r = p && consumeToken(b, CLOSE_BRACE) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // normal_text+ @@ -122,11 +79,10 @@ private static boolean braced_string_1(PsiBuilder b, int l) { boolean r; Marker m = enter_section_(b); r = normal_text(b, l + 1); - int c = current_position_(b); while (r) { + int c = current_position_(b); if (!normal_text(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "braced_string_1", c)) break; - c = current_position_(b); } exit_section_(b, m, null, r); return r; @@ -175,11 +131,10 @@ private static boolean content_0_1(PsiBuilder b, int l) { boolean r; Marker m = enter_section_(b); r = content_0_1_0(b, l + 1); - int c = current_position_(b); while (r) { + int c = current_position_(b); if (!content_0_1_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "content_0_1", c)) break; - c = current_position_(b); } exit_section_(b, m, null, r); return r; @@ -231,11 +186,10 @@ private static boolean endtry_0(PsiBuilder b, int l) { // comment* private static boolean endtry_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "endtry_1")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "endtry_1", c)) break; - c = current_position_(b); } return true; } @@ -244,10 +198,8 @@ private static boolean endtry_1(PsiBuilder b, int l) { private static boolean endtry_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "endtry_2")) return false; boolean r; - Marker m = enter_section_(b); r = consumeToken(b, CLOSE_BRACE); if (!r) r = consumeToken(b, CLOSE_PARENTHESIS); - exit_section_(b, m, null, r); return r; } @@ -256,27 +208,26 @@ private static boolean endtry_2(PsiBuilder b, int l) { public static boolean entry(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "entry")) return false; if (!nextTokenIs(b, TYPE_TOKEN)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, ENTRY, null); r = type(b, l + 1); - r = r && entry_1(b, l + 1); - r = r && entry_2(b, l + 1); - r = r && entry_3(b, l + 1); - r = r && endtry(b, l + 1); - r = r && entry_5(b, l + 1); - r = r && entry_6(b, l + 1); - exit_section_(b, m, ENTRY, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, entry_1(b, l + 1)); + r = p && report_error_(b, entry_2(b, l + 1)) && r; + r = p && report_error_(b, entry_3(b, l + 1)) && r; + r = p && report_error_(b, endtry(b, l + 1)) && r; + r = p && report_error_(b, entry_5(b, l + 1)) && r; + r = p && entry_6(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // OPEN_BRACE | OPEN_PARENTHESIS private static boolean entry_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "entry_1")) return false; boolean r; - Marker m = enter_section_(b); r = consumeToken(b, OPEN_BRACE); if (!r) r = consumeToken(b, OPEN_PARENTHESIS); - exit_section_(b, m, null, r); return r; } @@ -312,11 +263,10 @@ private static boolean entry_2_0_0(PsiBuilder b, int l) { // comment* private static boolean entry_3(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "entry_3")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "entry_3", c)) break; - c = current_position_(b); } return true; } @@ -324,11 +274,10 @@ private static boolean entry_3(PsiBuilder b, int l) { // comment* private static boolean entry_5(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "entry_5")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "entry_5", c)) break; - c = current_position_(b); } return true; } @@ -345,23 +294,23 @@ private static boolean entry_6(PsiBuilder b, int l) { public static boolean entry_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "entry_content")) return false; if (!nextTokenIs(b, "", COMMENT_TOKEN, IDENTIFIER)) return false; - boolean r; + boolean r, p; Marker m = enter_section_(b, l, _NONE_, ENTRY_CONTENT, ""); r = tag(b, l + 1); - r = r && entry_content_1(b, l + 1); - r = r && entry_content_2(b, l + 1); - exit_section_(b, l, m, r, false, null); - return r; + p = r; // pin = 1 + r = r && report_error_(b, entry_content_1(b, l + 1)); + r = p && entry_content_2(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // (SEPARATOR tag)* private static boolean entry_content_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "entry_content_1")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!entry_content_1_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "entry_content_1", c)) break; - c = current_position_(b); } return true; } @@ -389,24 +338,24 @@ private static boolean entry_content_2(PsiBuilder b, int l) { public static boolean id(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "id")) return false; if (!nextTokenIs(b, "", COMMENT_TOKEN, IDENTIFIER)) return false; - boolean r; + boolean r, p; Marker m = enter_section_(b, l, _NONE_, ID, ""); r = id_0(b, l + 1); r = r && consumeToken(b, IDENTIFIER); - r = r && id_2(b, l + 1); - r = r && consumeToken(b, SEPARATOR); - exit_section_(b, l, m, r, false, null); - return r; + p = r; // pin = 2 + r = r && report_error_(b, id_2(b, l + 1)); + r = p && consumeToken(b, SEPARATOR) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // comment* private static boolean id_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "id_0")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "id_0", c)) break; - c = current_position_(b); } return true; } @@ -414,11 +363,10 @@ private static boolean id_0(PsiBuilder b, int l) { // comment* private static boolean id_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "id_2")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "id_2", c)) break; - c = current_position_(b); } return true; } @@ -443,31 +391,29 @@ public static boolean normal_text(PsiBuilder b, int l) { boolean r; Marker m = enter_section_(b); r = consumeToken(b, NORMAL_TEXT_WORD); - int c = current_position_(b); while (r) { + int c = current_position_(b); if (!consumeToken(b, NORMAL_TEXT_WORD)) break; if (!empty_element_parsed_guard_(b, "normal_text", c)) break; - c = current_position_(b); } exit_section_(b, m, NORMAL_TEXT, r); return r; } /* ********************************************************** */ - // (quoted_string (CONCATENATE quoted_string)+) | quoted_string | NUMBER | IDENTIFIER + // (quoted_string (CONCATENATE quoted_string)*) | NUMBER | IDENTIFIER public static boolean preamble(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "preamble")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, PREAMBLE, ""); r = preamble_0(b, l + 1); - if (!r) r = quoted_string(b, l + 1); if (!r) r = consumeToken(b, NUMBER); if (!r) r = consumeToken(b, IDENTIFIER); exit_section_(b, l, m, r, false, null); return r; } - // quoted_string (CONCATENATE quoted_string)+ + // quoted_string (CONCATENATE quoted_string)* private static boolean preamble_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "preamble_0")) return false; boolean r; @@ -478,20 +424,15 @@ private static boolean preamble_0(PsiBuilder b, int l) { return r; } - // (CONCATENATE quoted_string)+ + // (CONCATENATE quoted_string)* private static boolean preamble_0_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "preamble_0_1")) return false; - boolean r; - Marker m = enter_section_(b); - r = preamble_0_1_0(b, l + 1); - int c = current_position_(b); - while (r) { + while (true) { + int c = current_position_(b); if (!preamble_0_1_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "preamble_0_1", c)) break; - c = current_position_(b); } - exit_section_(b, m, null, r); - return r; + return true; } // CONCATENATE quoted_string @@ -510,13 +451,14 @@ private static boolean preamble_0_1_0(PsiBuilder b, int l) { public static boolean quoted_string(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "quoted_string")) return false; if (!nextTokenIs(b, QUOTES)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, QUOTED_STRING, null); r = consumeToken(b, QUOTES); - r = r && quoted_string_1(b, l + 1); - r = r && consumeToken(b, END_QUOTES); - exit_section_(b, m, QUOTED_STRING, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, quoted_string_1(b, l + 1)); + r = p && consumeToken(b, END_QUOTES) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // normal_text? @@ -544,27 +486,27 @@ public static boolean string(PsiBuilder b, int l) { public static boolean tag(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "tag")) return false; if (!nextTokenIs(b, "", COMMENT_TOKEN, IDENTIFIER)) return false; - boolean r; + boolean r, p; Marker m = enter_section_(b, l, _NONE_, TAG, ""); r = tag_0(b, l + 1); r = r && key(b, l + 1); - r = r && tag_2(b, l + 1); - r = r && consumeToken(b, ASSIGNMENT); - r = r && tag_4(b, l + 1); - r = r && content(b, l + 1); - r = r && tag_6(b, l + 1); - exit_section_(b, l, m, r, false, null); - return r; + p = r; // pin = 2 + r = r && report_error_(b, tag_2(b, l + 1)); + r = p && report_error_(b, consumeToken(b, ASSIGNMENT)) && r; + r = p && report_error_(b, tag_4(b, l + 1)) && r; + r = p && report_error_(b, content(b, l + 1)) && r; + r = p && tag_6(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // comment* private static boolean tag_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "tag_0")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "tag_0", c)) break; - c = current_position_(b); } return true; } @@ -572,11 +514,10 @@ private static boolean tag_0(PsiBuilder b, int l) { // comment* private static boolean tag_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "tag_2")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "tag_2", c)) break; - c = current_position_(b); } return true; } @@ -584,11 +525,10 @@ private static boolean tag_2(PsiBuilder b, int l) { // comment* private static boolean tag_4(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "tag_4")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "tag_4", c)) break; - c = current_position_(b); } return true; } @@ -596,11 +536,10 @@ private static boolean tag_4(PsiBuilder b, int l) { // comment* private static boolean tag_6(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "tag_6")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!comment(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "tag_6", c)) break; - c = current_position_(b); } return true; } diff --git a/gen/nl/rubensten/texifyidea/parser/LatexParser.java b/gen/nl/rubensten/texifyidea/parser/LatexParser.java index 3b2e4b0c7..953e523dc 100644 --- a/gen/nl/rubensten/texifyidea/parser/LatexParser.java +++ b/gen/nl/rubensten/texifyidea/parser/LatexParser.java @@ -6,6 +6,7 @@ import static nl.rubensten.texifyidea.psi.LatexTypes.*; import static com.intellij.lang.parser.GeneratedParserUtilBase.*; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.IFileElementType; import com.intellij.lang.ASTNode; import com.intellij.psi.tree.TokenSet; import com.intellij.lang.PsiParser; @@ -23,62 +24,11 @@ public void parseLight(IElementType t, PsiBuilder b) { boolean r; b = adapt_builder_(t, b, this, null); Marker m = enter_section_(b, 0, _COLLAPSE_, null); - if (t == BEGIN_COMMAND) { - r = begin_command(b, 0); - } - else if (t == COMMANDS) { - r = commands(b, 0); - } - else if (t == COMMENT) { - r = comment(b, 0); - } - else if (t == CONTENT) { - r = content(b, 0); - } - else if (t == DISPLAY_MATH) { - r = display_math(b, 0); - } - else if (t == END_COMMAND) { - r = end_command(b, 0); - } - else if (t == ENVIRONMENT) { - r = environment(b, 0); - } - else if (t == ENVIRONMENT_CONTENT) { - r = environment_content(b, 0); - } - else if (t == GROUP) { - r = group(b, 0); - } - else if (t == INLINE_MATH) { - r = inline_math(b, 0); - } - else if (t == MATH_CONTENT) { - r = math_content(b, 0); - } - else if (t == MATH_ENVIRONMENT) { - r = math_environment(b, 0); - } - else if (t == NO_MATH_CONTENT) { - r = no_math_content(b, 0); - } - else if (t == NORMAL_TEXT) { - r = normal_text(b, 0); - } - else if (t == OPEN_GROUP) { - r = open_group(b, 0); - } - else if (t == OPTIONAL_PARAM) { - r = optional_param(b, 0); - } - else if (t == PARAMETER) { - r = parameter(b, 0); - } - else if (t == REQUIRED_PARAM) { - r = required_param(b, 0); + if (t instanceof IFileElementType) { + r = parse_root_(t, b, 0); } else { - r = parse_root_(t, b, 0); + r = false; } exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); } @@ -92,13 +42,14 @@ protected boolean parse_root_(IElementType t, PsiBuilder b, int l) { public static boolean begin_command(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "begin_command")) return false; if (!nextTokenIs(b, BEGIN_TOKEN)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, BEGIN_COMMAND, null); r = consumeToken(b, BEGIN_TOKEN); - r = r && begin_command_1(b, l + 1); - r = r && begin_command_2(b, l + 1); - exit_section_(b, m, BEGIN_COMMAND, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, begin_command_1(b, l + 1)); + r = p && begin_command_2(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // STAR? @@ -111,11 +62,10 @@ private static boolean begin_command_1(PsiBuilder b, int l) { // parameter* private static boolean begin_command_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "begin_command_2")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!parameter(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "begin_command_2", c)) break; - c = current_position_(b); } return true; } @@ -125,13 +75,14 @@ private static boolean begin_command_2(PsiBuilder b, int l) { public static boolean commands(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "commands")) return false; if (!nextTokenIs(b, COMMAND_TOKEN)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, COMMANDS, null); r = consumeToken(b, COMMAND_TOKEN); - r = r && commands_1(b, l + 1); - r = r && commands_2(b, l + 1); - exit_section_(b, m, COMMANDS, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, commands_1(b, l + 1)); + r = p && commands_2(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // STAR? @@ -144,11 +95,10 @@ private static boolean commands_1(PsiBuilder b, int l) { // parameter* private static boolean commands_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "commands_2")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!parameter(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "commands_2", c)) break; - c = current_position_(b); } return true; } @@ -181,13 +131,14 @@ public static boolean content(PsiBuilder b, int l) { public static boolean display_math(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "display_math")) return false; if (!nextTokenIs(b, DISPLAY_MATH_START)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, DISPLAY_MATH, null); r = consumeToken(b, DISPLAY_MATH_START); - r = r && display_math_1(b, l + 1); - r = r && consumeToken(b, DISPLAY_MATH_END); - exit_section_(b, m, DISPLAY_MATH, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, display_math_1(b, l + 1)); + r = p && consumeToken(b, DISPLAY_MATH_END) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // math_content? @@ -202,13 +153,14 @@ private static boolean display_math_1(PsiBuilder b, int l) { public static boolean end_command(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "end_command")) return false; if (!nextTokenIs(b, END_TOKEN)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, END_COMMAND, null); r = consumeToken(b, END_TOKEN); - r = r && end_command_1(b, l + 1); - r = r && end_command_2(b, l + 1); - exit_section_(b, m, END_COMMAND, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, end_command_1(b, l + 1)); + r = p && end_command_2(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // STAR? @@ -221,11 +173,10 @@ private static boolean end_command_1(PsiBuilder b, int l) { // parameter* private static boolean end_command_2(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "end_command_2")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!parameter(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "end_command_2", c)) break; - c = current_position_(b); } return true; } @@ -235,13 +186,14 @@ private static boolean end_command_2(PsiBuilder b, int l) { public static boolean environment(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "environment")) return false; if (!nextTokenIs(b, BEGIN_TOKEN)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, ENVIRONMENT, null); r = begin_command(b, l + 1); - r = r && environment_1(b, l + 1); - r = r && end_command(b, l + 1); - exit_section_(b, m, ENVIRONMENT, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, environment_1(b, l + 1)); + r = p && end_command(b, l + 1) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // environment_content? @@ -258,11 +210,10 @@ public static boolean environment_content(PsiBuilder b, int l) { boolean r; Marker m = enter_section_(b, l, _NONE_, ENVIRONMENT_CONTENT, ""); r = content(b, l + 1); - int c = current_position_(b); while (r) { + int c = current_position_(b); if (!content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "environment_content", c)) break; - c = current_position_(b); } exit_section_(b, l, m, r, false, null); return r; @@ -273,23 +224,23 @@ public static boolean environment_content(PsiBuilder b, int l) { public static boolean group(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "group")) return false; if (!nextTokenIs(b, OPEN_BRACE)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, GROUP, null); r = consumeToken(b, OPEN_BRACE); - r = r && group_1(b, l + 1); - r = r && consumeToken(b, CLOSE_BRACE); - exit_section_(b, m, GROUP, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, group_1(b, l + 1)); + r = p && consumeToken(b, CLOSE_BRACE) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // content* private static boolean group_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "group_1")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "group_1", c)) break; - c = current_position_(b); } return true; } @@ -299,13 +250,14 @@ private static boolean group_1(PsiBuilder b, int l) { public static boolean inline_math(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "inline_math")) return false; if (!nextTokenIs(b, INLINE_MATH_START)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, INLINE_MATH, null); r = consumeToken(b, INLINE_MATH_START); - r = r && inline_math_1(b, l + 1); - r = r && consumeToken(b, INLINE_MATH_END); - exit_section_(b, m, INLINE_MATH, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, inline_math_1(b, l + 1)); + r = p && consumeToken(b, INLINE_MATH_END) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // math_content? @@ -319,11 +271,10 @@ private static boolean inline_math_1(PsiBuilder b, int l) { // content* static boolean latexFile(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "latexFile")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "latexFile", c)) break; - c = current_position_(b); } return true; } @@ -335,11 +286,10 @@ public static boolean math_content(PsiBuilder b, int l) { boolean r; Marker m = enter_section_(b, l, _NONE_, MATH_CONTENT, ""); r = no_math_content(b, l + 1); - int c = current_position_(b); while (r) { + int c = current_position_(b); if (!no_math_content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "math_content", c)) break; - c = current_position_(b); } exit_section_(b, l, m, r, false, null); return r; @@ -387,11 +337,10 @@ public static boolean normal_text(PsiBuilder b, int l) { boolean r; Marker m = enter_section_(b, l, _NONE_, NORMAL_TEXT, ""); r = normal_text_0(b, l + 1); - int c = current_position_(b); while (r) { + int c = current_position_(b); if (!normal_text_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "normal_text", c)) break; - c = current_position_(b); } exit_section_(b, l, m, r, false, null); return r; @@ -401,10 +350,8 @@ public static boolean normal_text(PsiBuilder b, int l) { private static boolean normal_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text_0")) return false; boolean r; - Marker m = enter_section_(b); r = consumeToken(b, NORMAL_TEXT_WORD); if (!r) r = consumeToken(b, STAR); - exit_section_(b, m, null, r); return r; } @@ -413,23 +360,23 @@ private static boolean normal_text_0(PsiBuilder b, int l) { public static boolean open_group(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "open_group")) return false; if (!nextTokenIs(b, OPEN_BRACKET)) return false; - boolean r; - Marker m = enter_section_(b); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, OPEN_GROUP, null); r = consumeToken(b, OPEN_BRACKET); - r = r && open_group_1(b, l + 1); - r = r && consumeToken(b, CLOSE_BRACKET); - exit_section_(b, m, OPEN_GROUP, r); - return r; + p = r; // pin = 1 + r = r && report_error_(b, open_group_1(b, l + 1)); + r = p && consumeToken(b, CLOSE_BRACKET) && r; + exit_section_(b, l, m, r, p, null); + return r || p; } // content* private static boolean open_group_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "open_group_1")) return false; - int c = current_position_(b); while (true) { + int c = current_position_(b); if (!content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "open_group_1", c)) break; - c = current_position_(b); } return true; } diff --git a/gen/nl/rubensten/texifyidea/psi/BibtexEntry.java b/gen/nl/rubensten/texifyidea/psi/BibtexEntry.java index 85902baba..a57b41222 100644 --- a/gen/nl/rubensten/texifyidea/psi/BibtexEntry.java +++ b/gen/nl/rubensten/texifyidea/psi/BibtexEntry.java @@ -10,7 +10,7 @@ public interface BibtexEntry extends PsiElement { @NotNull List getCommentList(); - @NotNull + @Nullable BibtexEndtry getEndtry(); @Nullable diff --git a/gen/nl/rubensten/texifyidea/psi/BibtexId.java b/gen/nl/rubensten/texifyidea/psi/BibtexId.java index 3ae78f7e6..9c822bda5 100644 --- a/gen/nl/rubensten/texifyidea/psi/BibtexId.java +++ b/gen/nl/rubensten/texifyidea/psi/BibtexId.java @@ -1,20 +1,13 @@ // This is a generated file. Not intended for manual editing. package nl.rubensten.texifyidea.psi; -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.StubBasedPsiElement; -import nl.rubensten.texifyidea.index.stub.BibtexIdStub; -import nl.rubensten.texifyidea.util.StringsKt; -import org.jetbrains.annotations.NotNull; - import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; -public interface BibtexId extends StubBasedPsiElement, PsiNamedElement { +public interface BibtexId extends PsiElement { - @NotNull - List getCommentList(); + @NotNull + List getCommentList(); - default String getName() { - return StringsKt.substringEnd(getText(), 1); - } } diff --git a/gen/nl/rubensten/texifyidea/psi/BibtexTag.java b/gen/nl/rubensten/texifyidea/psi/BibtexTag.java index ca67aa89b..798ef5e4d 100644 --- a/gen/nl/rubensten/texifyidea/psi/BibtexTag.java +++ b/gen/nl/rubensten/texifyidea/psi/BibtexTag.java @@ -10,7 +10,7 @@ public interface BibtexTag extends PsiElement { @NotNull List getCommentList(); - @NotNull + @Nullable BibtexContent getContent(); @NotNull diff --git a/gen/nl/rubensten/texifyidea/psi/LatexEnvironment.java b/gen/nl/rubensten/texifyidea/psi/LatexEnvironment.java index c3114074e..b3c227e55 100644 --- a/gen/nl/rubensten/texifyidea/psi/LatexEnvironment.java +++ b/gen/nl/rubensten/texifyidea/psi/LatexEnvironment.java @@ -10,7 +10,7 @@ public interface LatexEnvironment extends PsiElement { @NotNull LatexBeginCommand getBeginCommand(); - @NotNull + @Nullable LatexEndCommand getEndCommand(); @Nullable diff --git a/gen/nl/rubensten/texifyidea/psi/LatexInlineMath.java b/gen/nl/rubensten/texifyidea/psi/LatexInlineMath.java index dff54e1d9..fc3d19cc8 100644 --- a/gen/nl/rubensten/texifyidea/psi/LatexInlineMath.java +++ b/gen/nl/rubensten/texifyidea/psi/LatexInlineMath.java @@ -10,7 +10,7 @@ public interface LatexInlineMath extends PsiElement { @Nullable LatexMathContent getMathContent(); - @NotNull + @Nullable PsiElement getInlineMathEnd(); @NotNull diff --git a/gen/nl/rubensten/texifyidea/psi/LatexTypes.java b/gen/nl/rubensten/texifyidea/psi/LatexTypes.java index 4fa98c32b..ca6cc69d2 100644 --- a/gen/nl/rubensten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/rubensten/texifyidea/psi/LatexTypes.java @@ -1,34 +1,15 @@ // This is a generated file. Not intended for manual editing. package nl.rubensten.texifyidea.psi; -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.tree.IElementType; -import nl.rubensten.texifyidea.index.stub.LatexCommandsStubElementType; -import nl.rubensten.texifyidea.psi.impl.LatexBeginCommandImpl; -import nl.rubensten.texifyidea.psi.impl.LatexCommandsImpl; -import nl.rubensten.texifyidea.psi.impl.LatexCommentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexContentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexDisplayMathImpl; -import nl.rubensten.texifyidea.psi.impl.LatexEndCommandImpl; -import nl.rubensten.texifyidea.psi.impl.LatexEnvironmentContentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexEnvironmentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexGroupImpl; -import nl.rubensten.texifyidea.psi.impl.LatexInlineMathImpl; -import nl.rubensten.texifyidea.psi.impl.LatexMathContentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexMathEnvironmentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexNoMathContentImpl; -import nl.rubensten.texifyidea.psi.impl.LatexNormalTextImpl; -import nl.rubensten.texifyidea.psi.impl.LatexOpenGroupImpl; -import nl.rubensten.texifyidea.psi.impl.LatexOptionalParamImpl; -import nl.rubensten.texifyidea.psi.impl.LatexParameterImpl; -import nl.rubensten.texifyidea.psi.impl.LatexRequiredParamImpl; +import com.intellij.psi.PsiElement; +import com.intellij.lang.ASTNode; +import nl.rubensten.texifyidea.psi.impl.*; public interface LatexTypes { IElementType BEGIN_COMMAND = new LatexElementType("BEGIN_COMMAND"); - IStubElementType COMMANDS = new LatexCommandsStubElementType("COMMANDS"); + IElementType COMMANDS = new LatexElementType("COMMANDS"); IElementType COMMENT = new LatexElementType("COMMENT"); IElementType CONTENT = new LatexElementType("CONTENT"); IElementType DISPLAY_MATH = new LatexElementType("DISPLAY_MATH"); @@ -68,7 +49,7 @@ public interface LatexTypes { class Factory { public static PsiElement createElement(ASTNode node) { IElementType type = node.getElementType(); - if (type == BEGIN_COMMAND) { + if (type == BEGIN_COMMAND) { return new LatexBeginCommandImpl(node); } else if (type == COMMANDS) { diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexBracedStringImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexBracedStringImpl.java index e2e4f7a68..e8ff1e181 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexBracedStringImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexBracedStringImpl.java @@ -13,7 +13,7 @@ public class BibtexBracedStringImpl extends ASTWrapperPsiElement implements BibtexBracedString { - public BibtexBracedStringImpl(ASTNode node) { + public BibtexBracedStringImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexCommentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexCommentImpl.java index cfeee31bf..380aede35 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexCommentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexCommentImpl.java @@ -13,7 +13,7 @@ public class BibtexCommentImpl extends ASTWrapperPsiElement implements BibtexComment { - public BibtexCommentImpl(ASTNode node) { + public BibtexCommentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexContentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexContentImpl.java index f1fd02397..1fb82895e 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexContentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexContentImpl.java @@ -13,7 +13,7 @@ public class BibtexContentImpl extends ASTWrapperPsiElement implements BibtexContent { - public BibtexContentImpl(ASTNode node) { + public BibtexContentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexEndtryImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexEndtryImpl.java index 0d15f53d8..bfea8da18 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexEndtryImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexEndtryImpl.java @@ -13,7 +13,7 @@ public class BibtexEndtryImpl extends ASTWrapperPsiElement implements BibtexEndtry { - public BibtexEndtryImpl(ASTNode node) { + public BibtexEndtryImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryContentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryContentImpl.java index f66b0aa0a..9f2fb97b6 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryContentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryContentImpl.java @@ -13,7 +13,7 @@ public class BibtexEntryContentImpl extends ASTWrapperPsiElement implements BibtexEntryContent { - public BibtexEntryContentImpl(ASTNode node) { + public BibtexEntryContentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryImpl.java index 31cf20241..104cd080b 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexEntryImpl.java @@ -13,7 +13,7 @@ public class BibtexEntryImpl extends ASTWrapperPsiElement implements BibtexEntry { - public BibtexEntryImpl(ASTNode node) { + public BibtexEntryImpl(@NotNull ASTNode node) { super(node); } @@ -33,9 +33,9 @@ public List getCommentList() { } @Override - @NotNull + @Nullable public BibtexEndtry getEndtry() { - return findNotNullChildByClass(BibtexEndtry.class); + return findChildByClass(BibtexEndtry.class); } @Override diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexKeyImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexKeyImpl.java index 8d1747a08..3105d43d2 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexKeyImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexKeyImpl.java @@ -13,7 +13,7 @@ public class BibtexKeyImpl extends ASTWrapperPsiElement implements BibtexKey { - public BibtexKeyImpl(ASTNode node) { + public BibtexKeyImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexNormalTextImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexNormalTextImpl.java index 0133daced..63f48a26c 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexNormalTextImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexNormalTextImpl.java @@ -13,7 +13,7 @@ public class BibtexNormalTextImpl extends ASTWrapperPsiElement implements BibtexNormalText { - public BibtexNormalTextImpl(ASTNode node) { + public BibtexNormalTextImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexPreambleImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexPreambleImpl.java index 13b6bd669..a1f0973ab 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexPreambleImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexPreambleImpl.java @@ -13,7 +13,7 @@ public class BibtexPreambleImpl extends ASTWrapperPsiElement implements BibtexPreamble { - public BibtexPreambleImpl(ASTNode node) { + public BibtexPreambleImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexQuotedStringImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexQuotedStringImpl.java index a25e4f38d..d7f414124 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexQuotedStringImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexQuotedStringImpl.java @@ -13,7 +13,7 @@ public class BibtexQuotedStringImpl extends ASTWrapperPsiElement implements BibtexQuotedString { - public BibtexQuotedStringImpl(ASTNode node) { + public BibtexQuotedStringImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexStringImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexStringImpl.java index 4a9a5a70b..5947f2a50 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexStringImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexStringImpl.java @@ -13,7 +13,7 @@ public class BibtexStringImpl extends ASTWrapperPsiElement implements BibtexString { - public BibtexStringImpl(ASTNode node) { + public BibtexStringImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexTagImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexTagImpl.java index d2ff6d8e7..b9559d411 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexTagImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexTagImpl.java @@ -13,7 +13,7 @@ public class BibtexTagImpl extends ASTWrapperPsiElement implements BibtexTag { - public BibtexTagImpl(ASTNode node) { + public BibtexTagImpl(@NotNull ASTNode node) { super(node); } @@ -33,9 +33,9 @@ public List getCommentList() { } @Override - @NotNull + @Nullable public BibtexContent getContent() { - return findNotNullChildByClass(BibtexContent.class); + return findChildByClass(BibtexContent.class); } @Override diff --git a/gen/nl/rubensten/texifyidea/psi/impl/BibtexTypeImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/BibtexTypeImpl.java index 1725a883b..db43382f6 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/BibtexTypeImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/BibtexTypeImpl.java @@ -13,7 +13,7 @@ public class BibtexTypeImpl extends ASTWrapperPsiElement implements BibtexType { - public BibtexTypeImpl(ASTNode node) { + public BibtexTypeImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexBeginCommandImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexBeginCommandImpl.java index b09faa551..4caed8860 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexBeginCommandImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexBeginCommandImpl.java @@ -13,7 +13,7 @@ public class LatexBeginCommandImpl extends ASTWrapperPsiElement implements LatexBeginCommand { - public LatexBeginCommandImpl(ASTNode node) { + public LatexBeginCommandImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexCommentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexCommentImpl.java index 40d10f0c8..f012da2e1 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexCommentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexCommentImpl.java @@ -13,7 +13,7 @@ public class LatexCommentImpl extends ASTWrapperPsiElement implements LatexComment { - public LatexCommentImpl(ASTNode node) { + public LatexCommentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexContentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexContentImpl.java index 610c99151..53f823188 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexContentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexContentImpl.java @@ -13,7 +13,7 @@ public class LatexContentImpl extends ASTWrapperPsiElement implements LatexContent { - public LatexContentImpl(ASTNode node) { + public LatexContentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexDisplayMathImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexDisplayMathImpl.java index ed83942e8..685f4b274 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexDisplayMathImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexDisplayMathImpl.java @@ -13,7 +13,7 @@ public class LatexDisplayMathImpl extends ASTWrapperPsiElement implements LatexDisplayMath { - public LatexDisplayMathImpl(ASTNode node) { + public LatexDisplayMathImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexEndCommandImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexEndCommandImpl.java index fb2d8840c..3474e57f0 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexEndCommandImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexEndCommandImpl.java @@ -13,7 +13,7 @@ public class LatexEndCommandImpl extends ASTWrapperPsiElement implements LatexEndCommand { - public LatexEndCommandImpl(ASTNode node) { + public LatexEndCommandImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentContentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentContentImpl.java index d13f709d2..5166b6678 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentContentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentContentImpl.java @@ -13,7 +13,7 @@ public class LatexEnvironmentContentImpl extends ASTWrapperPsiElement implements LatexEnvironmentContent { - public LatexEnvironmentContentImpl(ASTNode node) { + public LatexEnvironmentContentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentImpl.java index 916387698..3f82252bc 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexEnvironmentImpl.java @@ -13,7 +13,7 @@ public class LatexEnvironmentImpl extends ASTWrapperPsiElement implements LatexEnvironment { - public LatexEnvironmentImpl(ASTNode node) { + public LatexEnvironmentImpl(@NotNull ASTNode node) { super(node); } @@ -33,9 +33,9 @@ public LatexBeginCommand getBeginCommand() { } @Override - @NotNull + @Nullable public LatexEndCommand getEndCommand() { - return findNotNullChildByClass(LatexEndCommand.class); + return findChildByClass(LatexEndCommand.class); } @Override diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexGroupImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexGroupImpl.java index e5799b029..8994786aa 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexGroupImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexGroupImpl.java @@ -13,7 +13,7 @@ public class LatexGroupImpl extends ASTWrapperPsiElement implements LatexGroup { - public LatexGroupImpl(ASTNode node) { + public LatexGroupImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexInlineMathImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexInlineMathImpl.java index 875f80a36..10e85f5f2 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexInlineMathImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexInlineMathImpl.java @@ -13,7 +13,7 @@ public class LatexInlineMathImpl extends ASTWrapperPsiElement implements LatexInlineMath { - public LatexInlineMathImpl(ASTNode node) { + public LatexInlineMathImpl(@NotNull ASTNode node) { super(node); } @@ -33,9 +33,9 @@ public LatexMathContent getMathContent() { } @Override - @NotNull + @Nullable public PsiElement getInlineMathEnd() { - return findNotNullChildByType(INLINE_MATH_END); + return findChildByType(INLINE_MATH_END); } @Override diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexMathContentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexMathContentImpl.java index f9f01afd2..e3f201b24 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexMathContentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexMathContentImpl.java @@ -13,7 +13,7 @@ public class LatexMathContentImpl extends ASTWrapperPsiElement implements LatexMathContent { - public LatexMathContentImpl(ASTNode node) { + public LatexMathContentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexMathEnvironmentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexMathEnvironmentImpl.java index 1f2496ae0..7ffbb105f 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexMathEnvironmentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexMathEnvironmentImpl.java @@ -13,7 +13,7 @@ public class LatexMathEnvironmentImpl extends ASTWrapperPsiElement implements LatexMathEnvironment { - public LatexMathEnvironmentImpl(ASTNode node) { + public LatexMathEnvironmentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexNoMathContentImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexNoMathContentImpl.java index 0a9b4e1f7..df2036dad 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexNoMathContentImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexNoMathContentImpl.java @@ -13,7 +13,7 @@ public class LatexNoMathContentImpl extends ASTWrapperPsiElement implements LatexNoMathContent { - public LatexNoMathContentImpl(ASTNode node) { + public LatexNoMathContentImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexNormalTextImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexNormalTextImpl.java index 44f26313e..e39f15c06 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexNormalTextImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexNormalTextImpl.java @@ -13,7 +13,7 @@ public class LatexNormalTextImpl extends ASTWrapperPsiElement implements LatexNormalText { - public LatexNormalTextImpl(ASTNode node) { + public LatexNormalTextImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexOpenGroupImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexOpenGroupImpl.java index 2c9a40bc1..5e192ff10 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexOpenGroupImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexOpenGroupImpl.java @@ -13,7 +13,7 @@ public class LatexOpenGroupImpl extends ASTWrapperPsiElement implements LatexOpenGroup { - public LatexOpenGroupImpl(ASTNode node) { + public LatexOpenGroupImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexOptionalParamImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexOptionalParamImpl.java index a7ea0f911..f667b69c9 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexOptionalParamImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexOptionalParamImpl.java @@ -13,7 +13,7 @@ public class LatexOptionalParamImpl extends ASTWrapperPsiElement implements LatexOptionalParam { - public LatexOptionalParamImpl(ASTNode node) { + public LatexOptionalParamImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexParameterImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexParameterImpl.java index e79b3202f..2e9bc944e 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexParameterImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexParameterImpl.java @@ -13,7 +13,7 @@ public class LatexParameterImpl extends ASTWrapperPsiElement implements LatexParameter { - public LatexParameterImpl(ASTNode node) { + public LatexParameterImpl(@NotNull ASTNode node) { super(node); } diff --git a/gen/nl/rubensten/texifyidea/psi/impl/LatexRequiredParamImpl.java b/gen/nl/rubensten/texifyidea/psi/impl/LatexRequiredParamImpl.java index 6cf67b17d..5cddb5f71 100644 --- a/gen/nl/rubensten/texifyidea/psi/impl/LatexRequiredParamImpl.java +++ b/gen/nl/rubensten/texifyidea/psi/impl/LatexRequiredParamImpl.java @@ -13,7 +13,7 @@ public class LatexRequiredParamImpl extends ASTWrapperPsiElement implements LatexRequiredParam { - public LatexRequiredParamImpl(ASTNode node) { + public LatexRequiredParamImpl(@NotNull ASTNode node) { super(node); } diff --git a/src/nl/rubensten/texifyidea/grammar/Bibtex.bnf b/src/nl/rubensten/texifyidea/grammar/Bibtex.bnf index e5e9a1f4d..cd7587752 100644 --- a/src/nl/rubensten/texifyidea/grammar/Bibtex.bnf +++ b/src/nl/rubensten/texifyidea/grammar/Bibtex.bnf @@ -15,19 +15,19 @@ bibtexFile ::= (entry | comment)* -entry ::= type (OPEN_BRACE | OPEN_PARENTHESIS) (id? entry_content | preamble) comment* endtry comment* SEPARATOR? +entry ::= type (OPEN_BRACE | OPEN_PARENTHESIS) (id? entry_content | preamble) comment* endtry comment* SEPARATOR? { pin=1 } -entry_content ::= tag (SEPARATOR tag)* SEPARATOR? +entry_content ::= tag (SEPARATOR tag)* SEPARATOR? { pin=1 } endtry ::= SEPARATOR? comment* (CLOSE_BRACE | CLOSE_PARENTHESIS) type ::= TYPE_TOKEN -preamble ::= (quoted_string (CONCATENATE quoted_string)+) | quoted_string | NUMBER | IDENTIFIER +preamble ::= (quoted_string (CONCATENATE quoted_string)*) | NUMBER | IDENTIFIER -id ::= comment* IDENTIFIER comment* SEPARATOR +id ::= comment* IDENTIFIER comment* SEPARATOR { pin=2 } -tag ::= comment* key comment* ASSIGNMENT comment* content comment* +tag ::= comment* key comment* ASSIGNMENT comment* content comment* { pin=2 } key ::= IDENTIFIER @@ -37,9 +37,9 @@ string ::= defined_string | quoted_string | braced_string defined_string ::= IDENTIFIER -quoted_string ::= QUOTES normal_text? END_QUOTES +quoted_string ::= QUOTES normal_text? END_QUOTES { pin=1 } -braced_string ::= OPEN_BRACE normal_text+ CLOSE_BRACE +braced_string ::= OPEN_BRACE normal_text+ CLOSE_BRACE { pin=1 } comment ::= COMMENT_TOKEN diff --git a/src/nl/rubensten/texifyidea/grammar/Latex.bnf b/src/nl/rubensten/texifyidea/grammar/Latex.bnf index 23592282e..e98d355f4 100644 --- a/src/nl/rubensten/texifyidea/grammar/Latex.bnf +++ b/src/nl/rubensten/texifyidea/grammar/Latex.bnf @@ -37,15 +37,15 @@ no_math_content ::= comment | environment | math_environment | commands | group normal_text ::= (NORMAL_TEXT_WORD | STAR)+ -environment ::= begin_command environment_content? end_command +environment ::= begin_command environment_content? end_command { pin=1 } environment_content ::= content+ -commands ::= COMMAND_TOKEN STAR? parameter* +commands ::= COMMAND_TOKEN STAR? parameter* { pin=1 } -begin_command ::= BEGIN_TOKEN STAR? parameter* +begin_command ::= BEGIN_TOKEN STAR? parameter* { pin=1 } -end_command ::= END_TOKEN STAR? parameter* +end_command ::= END_TOKEN STAR? parameter* { pin=1 } parameter ::= optional_param | required_param @@ -53,16 +53,16 @@ optional_param ::= open_group required_param ::= group -group ::= OPEN_BRACE content* CLOSE_BRACE +group ::= OPEN_BRACE content* CLOSE_BRACE { pin=1 } -open_group ::= OPEN_BRACKET content* CLOSE_BRACKET +open_group ::= OPEN_BRACKET content* CLOSE_BRACKET { pin=1 } comment ::= COMMENT_TOKEN math_environment ::= inline_math | display_math -inline_math ::= INLINE_MATH_START math_content? INLINE_MATH_END +inline_math ::= INLINE_MATH_START math_content? INLINE_MATH_END { pin=1 } -display_math ::= DISPLAY_MATH_START math_content? DISPLAY_MATH_END +display_math ::= DISPLAY_MATH_START math_content? DISPLAY_MATH_END { pin=1 } math_content ::= no_math_content+ From 1e678b2aa05eff10acc3ea1474911551b05fd80a Mon Sep 17 00:00:00 2001 From: ice1000 Date: Tue, 18 Jun 2019 13:19:14 -0400 Subject: [PATCH 2/6] Kotlin nullability fixes, revert some unintended changes --- gen/nl/rubensten/texifyidea/psi/BibtexId.java | 13 ++++++--- .../rubensten/texifyidea/psi/LatexTypes.java | 27 ++++++++++++++++--- .../completion/BibtexStringProvider.kt | 10 +++---- .../folding/LatexEnvironmentFoldingBuilder.kt | 5 ++-- .../texifyidea/highlighting/LatexAnnotator.kt | 2 +- .../latex/LatexAvoidEqnarrayInspection.kt | 4 +-- .../intentions/LatexInlineDisplayToggle.kt | 3 ++- .../bibtex/BibtexStructureViewEntryElement.kt | 2 +- .../bibtex/BibtexStructureViewTagElement.kt | 2 +- src/nl/rubensten/texifyidea/util/Bibtex.kt | 6 +++-- 10 files changed, 52 insertions(+), 22 deletions(-) diff --git a/gen/nl/rubensten/texifyidea/psi/BibtexId.java b/gen/nl/rubensten/texifyidea/psi/BibtexId.java index 9c822bda5..971c92c64 100644 --- a/gen/nl/rubensten/texifyidea/psi/BibtexId.java +++ b/gen/nl/rubensten/texifyidea/psi/BibtexId.java @@ -1,13 +1,20 @@ // This is a generated file. Not intended for manual editing. package nl.rubensten.texifyidea.psi; +import com.intellij.psi.PsiNamedElement; +import com.intellij.psi.StubBasedPsiElement; +import nl.rubensten.texifyidea.index.stub.BibtexIdStub; +import nl.rubensten.texifyidea.util.StringsKt; +import org.jetbrains.annotations.NotNull; + import java.util.List; -import org.jetbrains.annotations.*; -import com.intellij.psi.PsiElement; -public interface BibtexId extends PsiElement { +public interface BibtexId extends StubBasedPsiElement, PsiNamedElement { @NotNull List getCommentList(); + default String getName() { + return StringsKt.substringEnd(getText(), 1); + } } diff --git a/gen/nl/rubensten/texifyidea/psi/LatexTypes.java b/gen/nl/rubensten/texifyidea/psi/LatexTypes.java index ca6cc69d2..1641f53fc 100644 --- a/gen/nl/rubensten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/rubensten/texifyidea/psi/LatexTypes.java @@ -1,15 +1,34 @@ // This is a generated file. Not intended for manual editing. package nl.rubensten.texifyidea.psi; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.PsiElement; import com.intellij.lang.ASTNode; -import nl.rubensten.texifyidea.psi.impl.*; +import com.intellij.psi.PsiElement; +import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.tree.IElementType; +import nl.rubensten.texifyidea.index.stub.LatexCommandsStubElementType; +import nl.rubensten.texifyidea.psi.impl.LatexBeginCommandImpl; +import nl.rubensten.texifyidea.psi.impl.LatexCommandsImpl; +import nl.rubensten.texifyidea.psi.impl.LatexCommentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexContentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexDisplayMathImpl; +import nl.rubensten.texifyidea.psi.impl.LatexEndCommandImpl; +import nl.rubensten.texifyidea.psi.impl.LatexEnvironmentContentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexEnvironmentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexGroupImpl; +import nl.rubensten.texifyidea.psi.impl.LatexInlineMathImpl; +import nl.rubensten.texifyidea.psi.impl.LatexMathContentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexMathEnvironmentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexNoMathContentImpl; +import nl.rubensten.texifyidea.psi.impl.LatexNormalTextImpl; +import nl.rubensten.texifyidea.psi.impl.LatexOpenGroupImpl; +import nl.rubensten.texifyidea.psi.impl.LatexOptionalParamImpl; +import nl.rubensten.texifyidea.psi.impl.LatexParameterImpl; +import nl.rubensten.texifyidea.psi.impl.LatexRequiredParamImpl; public interface LatexTypes { IElementType BEGIN_COMMAND = new LatexElementType("BEGIN_COMMAND"); - IElementType COMMANDS = new LatexElementType("COMMANDS"); + IStubElementType COMMANDS = new LatexCommandsStubElementType("COMMANDS"); IElementType COMMENT = new LatexElementType("COMMENT"); IElementType CONTENT = new LatexElementType("CONTENT"); IElementType DISPLAY_MATH = new LatexElementType("DISPLAY_MATH"); diff --git a/src/nl/rubensten/texifyidea/completion/BibtexStringProvider.kt b/src/nl/rubensten/texifyidea/completion/BibtexStringProvider.kt index a0968a44c..7479f93f4 100644 --- a/src/nl/rubensten/texifyidea/completion/BibtexStringProvider.kt +++ b/src/nl/rubensten/texifyidea/completion/BibtexStringProvider.kt @@ -20,18 +20,18 @@ object BibtexStringProvider : CompletionProvider() { override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) { val psiFile = parameters.originalFile - val strings: List?> = psiFile.childrenOfType(BibtexEntry::class).asSequence() + val strings: List> = psiFile.childrenOfType(BibtexEntry::class).asSequence() .filter { it.tokenType() == "@string" } - .map { - val tag = it.firstChildOfType(BibtexTag::class) ?: return@map null + .mapNotNull { + val tag = it.firstChildOfType(BibtexTag::class) ?: return@mapNotNull null val key = tag.key - val content = tag.content + val content = tag.content ?: return@mapNotNull null Triple(key.text, content.text, it) } .toList() result.addAllElements(ContainerUtil.map2List(strings) { - LookupElementBuilder.create(StringDescription(it!!.third), it.first) + LookupElementBuilder.create(StringDescription(it.third), it.first) .withPresentableText(it.first) .bold() .withTypeText(it.second, true) diff --git a/src/nl/rubensten/texifyidea/folding/LatexEnvironmentFoldingBuilder.kt b/src/nl/rubensten/texifyidea/folding/LatexEnvironmentFoldingBuilder.kt index 4de9364a0..e7b2185d3 100644 --- a/src/nl/rubensten/texifyidea/folding/LatexEnvironmentFoldingBuilder.kt +++ b/src/nl/rubensten/texifyidea/folding/LatexEnvironmentFoldingBuilder.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import nl.rubensten.texifyidea.psi.LatexEnvironment import nl.rubensten.texifyidea.util.childrenOfType +import nl.rubensten.texifyidea.util.endOffset import java.util.* /** @@ -30,8 +31,8 @@ class LatexEnvironmentFoldingBuilder : FoldingBuilderEx() { for (environment in environments) { // Get content offsets. // Uses the commands instead of the actual contents as they may be empty. - val start = environment.beginCommand.textRange.endOffset - val end = environment.endCommand.textRange.startOffset + val start = environment.beginCommand.endOffset() + val end = environment.endCommand?.textOffset ?: environment.endOffset() if (end <= start) { continue diff --git a/src/nl/rubensten/texifyidea/highlighting/LatexAnnotator.kt b/src/nl/rubensten/texifyidea/highlighting/LatexAnnotator.kt index b93272f2a..011890b77 100644 --- a/src/nl/rubensten/texifyidea/highlighting/LatexAnnotator.kt +++ b/src/nl/rubensten/texifyidea/highlighting/LatexAnnotator.kt @@ -80,7 +80,7 @@ open class LatexAnnotator : Annotator { if (psiElement is LatexEnvironment) { val ann1 = annotationHolder.createInfoAnnotation(TextRange.from(psiElement.beginCommand.textOffset, 6), null) ann1.textAttributes = LatexSyntaxHighlighter.COMMAND_MATH_DISPLAY - val ann2 = annotationHolder.createInfoAnnotation(TextRange.from(psiElement.endCommand.textOffset, 4), null) + val ann2 = annotationHolder.createInfoAnnotation(TextRange.from(psiElement.endCommand?.textOffset ?: psiElement.endOffset(), 4), null) ann2.textAttributes = LatexSyntaxHighlighter.COMMAND_MATH_DISPLAY } } diff --git a/src/nl/rubensten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt b/src/nl/rubensten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt index 3139f5ffc..2f92a83a4 100644 --- a/src/nl/rubensten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt +++ b/src/nl/rubensten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt @@ -35,7 +35,7 @@ open class LatexAvoidEqnarrayInspection : TexifyInspectionBase() { } val star = name.substring("eqnarray".length) - descriptors.add(manager.createProblemDescriptor( + if (env.endCommand != null) descriptors.add(manager.createProblemDescriptor( env, TextRange(7, 7 + name.length), "Avoid using the 'eqnarray$star' environment", @@ -60,7 +60,7 @@ open class LatexAvoidEqnarrayInspection : TexifyInspectionBase() { val file = environment.containingFile val document = file.document() ?: return val begin = environment.beginCommand - val end = environment.endCommand + val end = environment.endCommand ?: return document.replaceString(end.textOffset, end.endOffset(), "\\end{align$star}") document.replaceString(begin.textOffset, begin.endOffset(), "\\begin{align$star}") diff --git a/src/nl/rubensten/texifyidea/intentions/LatexInlineDisplayToggle.kt b/src/nl/rubensten/texifyidea/intentions/LatexInlineDisplayToggle.kt index 4b9bf2439..d4a602786 100644 --- a/src/nl/rubensten/texifyidea/intentions/LatexInlineDisplayToggle.kt +++ b/src/nl/rubensten/texifyidea/intentions/LatexInlineDisplayToggle.kt @@ -41,7 +41,8 @@ open class LatexInlineDisplayToggle : TexifyIntentionBase("Toggle inline/display private fun applyForInlineMath(editor: Editor, inline: LatexInlineMath) { val document = editor.document val indent = document.lineIndentationByOffset(inline.textOffset) - val text = inline.text.trimRange(inline.inlineMathStart.textLength, inline.inlineMathEnd.textLength).trim() + val endLength = inline.inlineMathEnd?.textLength ?: 0 + val text = inline.text.trimRange(inline.inlineMathStart.textLength, endLength).trim() runWriteAction { val extra = if (document.getText(TextRange.from(inline.endOffset(), 1)) == " ") { diff --git a/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewEntryElement.kt b/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewEntryElement.kt index fa5976e8f..262fa696c 100644 --- a/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewEntryElement.kt +++ b/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewEntryElement.kt @@ -18,7 +18,7 @@ open class BibtexStructureViewEntryElement(val entry: BibtexEntry) : StructureVi val entryPresentation: ItemPresentation = object : ItemPresentation { override fun getLocationString() = when (entry.tokenName()?.toLowerCase()) { - "string" -> entry.tags().first().content.text + "string" -> entry.tags().first().content?.text.orEmpty() "preamble" -> "" else -> entry.tokenName() } diff --git a/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewTagElement.kt b/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewTagElement.kt index c6469f948..315ba6367 100644 --- a/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewTagElement.kt +++ b/src/nl/rubensten/texifyidea/structure/bibtex/BibtexStructureViewTagElement.kt @@ -17,7 +17,7 @@ open class BibtexStructureViewTagElement(val tag: BibtexTag) : StructureViewTree val tagPresentation: ItemPresentation = object : ItemPresentation { - override fun getLocationString() = tag.content.evaluate() + override fun getLocationString() = tag.content?.evaluate().orEmpty() override fun getPresentableText() = tag.keyName() diff --git a/src/nl/rubensten/texifyidea/util/Bibtex.kt b/src/nl/rubensten/texifyidea/util/Bibtex.kt index 8c8eb3a1f..cd18224bd 100644 --- a/src/nl/rubensten/texifyidea/util/Bibtex.kt +++ b/src/nl/rubensten/texifyidea/util/Bibtex.kt @@ -137,12 +137,14 @@ fun BibtexDefinedString.evaluate(): String { continue } + val content = tag.content ?: continue + // Prevent perpetual recursion. - if (key == tag.content.text) { + if (key == content.text) { continue } - return tag.content.evaluate() + return content.evaluate() } return "${'$'}$stringName${'$'}" From 1fc6eb31f1c63a478bced8894b8130af466493ea Mon Sep 17 00:00:00 2001 From: Hannah Schellekens Date: Tue, 2 Jul 2019 11:04:08 +0200 Subject: [PATCH 3/6] Added caching for referenced file sets. All usage was already delegated to the PsiFile.referencedFileSet extension method, so changing that method to use the ReferencedFileSetService was enough for it to take effect. --- .../psi/impl/LatexCommandsImpl.java | 8 ++ resources/META-INF/plugin.xml | 4 + .../texifyidea/action/NewLatexFileAction.java | 2 +- .../action/analysis/WordCountAction.kt | 2 + .../action/group/LatexAnalyzeMenuGroup.kt | 2 +- .../action/group/LatexEditMenuGroup.kt | 2 +- .../action/group/LatexToolsMenuGroup.kt | 2 +- .../texifyidea/completion/InsertBibtexTag.kt | 1 + .../completion/LatexCommandProvider.java | 2 + .../completion/LatexFileProvider.kt | 3 + .../handlers/FileNameInsertionHandler.kt | 2 + .../handlers/LatexNoMathInsertHandler.kt | 1 + .../editor/LatexSoftWrapEditorListener.kt | 4 +- .../gutter/LatexNavigationGutter.java | 2 +- .../texifyidea/highlighting/LatexAnnotator.kt | 1 + .../texifyidea/index/BibtexIdIndex.kt | 2 +- .../texifyidea/index/IndexUtilBase.kt | 6 +- .../inspections/TexifyRegexInspection.kt | 1 + .../BibtexDuplicateBibliographyInspection.kt | 2 +- ...texDuplicateBibliographystyleInspection.kt | 4 +- .../bibtex/BibtexDuplicateIdInspection.kt | 1 + ...ibtexMissingBibliographystyleInspection.kt | 6 +- .../latex/LatexAvoidEqnarrayInspection.kt | 1 + .../latex/LatexCiteBeforePeriodInspection.kt | 1 + .../latex/LatexCollapseCiteInspection.kt | 1 + .../LatexCommandAlreadyDefinedInspection.kt | 2 +- .../LatexDiscouragedUseOfDefInspection.kt | 2 +- .../LatexDuplicateDefinitionInspection.kt | 4 +- .../latex/LatexDuplicateLabelInspection.kt | 3 + .../latex/LatexEnDashInspection.kt | 2 +- .../LatexEncloseWithLeftRightInspection.kt | 1 + .../latex/LatexEquationReferenceInspection.kt | 2 +- .../LatexFigureNotReferencedInspection.kt | 1 + .../latex/LatexFileNotFoundInspection.kt | 4 +- .../latex/LatexGatherEquationsInspection.kt | 1 + .../latex/LatexInclusionLoopInspection.kt | 6 +- .../latex/LatexLabelConventionInspection.kt | 3 + .../latex/LatexLineBreakInspection.kt | 1 + ...texMissingDocumentEnvironmentInspection.kt | 2 +- .../latex/LatexMissingImportInspection.kt | 2 + .../latex/LatexMissingLabelInspection.kt | 3 + .../latex/LatexMultipleIncludesInspection.kt | 2 +- .../latex/LatexNestedIncludesInspection.kt | 3 + .../latex/LatexNoExtensionInspection.kt | 2 +- .../latex/LatexNonBreakingSpaceInspection.kt | 2 +- .../LatexNonMatchingEnvironmentInspection.kt | 1 + .../latex/LatexNonMatchingIfInspection.kt | 2 +- .../latex/LatexPrimitiveEquationInspection.kt | 2 +- .../LatexSpaceAfterAbbreviationInspection.kt | 2 +- .../latex/LatexTooLargeSectionInspection.kt | 3 + .../latex/LatexTrimWhitespaceInspection.kt | 2 + .../LatexUnresolvedReferenceInspection.kt | 2 +- .../intentions/LatexDisplayMathIntention.kt | 1 + .../intentions/LatexInlineDisplayToggle.kt | 1 + .../LatexLeftRightParenthesesIntention.kt | 2 + .../texifyidea/intentions/LatexMathToggle.kt | 1 + .../LatexMoveSectionToFileIntention.kt | 4 + .../LatexMoveSelectionToFileIntention.kt | 6 +- .../LatexUnpackUsepackageIntention.kt | 2 + .../texifyidea/lang/magic/MagicComments.kt | 1 + .../reference/LatexLabelReference.java | 2 +- .../texifyidea/run/LatexCommandLineState.kt | 5 +- .../run/evince/EvinceForwardSearch.kt | 4 +- .../run/sumatra/SumatraForwardSearch.kt | 4 + .../latex/LatexStructureViewElement.kt | 3 + src/nl/hannahsten/texifyidea/util/Packages.kt | 3 + src/nl/hannahsten/texifyidea/util/Projects.kt | 12 +++ src/nl/hannahsten/texifyidea/util/Psi.kt | 1 + .../hannahsten/texifyidea/util/PsiCommands.kt | 1 + .../texifyidea/util/{ => files}/FileSet.kt | 12 ++- .../texifyidea/util/{ => files}/Files.kt | 3 +- .../util/files/ReferencedFileSetCache.kt | 101 ++++++++++++++++++ .../util/files/ReferencedFileSetService.kt | 29 +++++ .../impl/ReferencedFileSetServiceImpl.kt | 18 ++++ 74 files changed, 296 insertions(+), 45 deletions(-) rename src/nl/hannahsten/texifyidea/util/{ => files}/FileSet.kt (87%) rename src/nl/hannahsten/texifyidea/util/{ => files}/Files.kt (99%) create mode 100644 src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt create mode 100644 src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetService.kt create mode 100644 src/nl/hannahsten/texifyidea/util/files/impl/ReferencedFileSetServiceImpl.kt diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java index 7671d77b3..03c2e2c56 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java @@ -18,6 +18,7 @@ import nl.hannahsten.texifyidea.reference.LatexLabelReference; import nl.hannahsten.texifyidea.util.Magic; import nl.hannahsten.texifyidea.util.PsiCommandsKt; +import nl.hannahsten.texifyidea.util.files.ReferencedFileSetService; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -94,4 +95,11 @@ public String getName() { public String toString() { return "LatexCommandsImpl(COMMANDS)[STUB]{" + getName() + "}"; } + + @Override + public void subtreeChanged() { + ReferencedFileSetService setService = ReferencedFileSetService.getInstance(getProject()); + setService.dropCaches(getContainingFile()); + super.subtreeChanged(); + } } \ No newline at end of file diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 1645ce5fc..cfac279d1 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -396,6 +396,10 @@ + + + diff --git a/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.java b/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.java index e96ea33e3..73196edad 100644 --- a/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.java +++ b/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.java @@ -13,7 +13,7 @@ import nl.hannahsten.texifyidea.TexifyIcons; import nl.hannahsten.texifyidea.file.*; import nl.hannahsten.texifyidea.templates.LatexTemplatesFactory; -import nl.hannahsten.texifyidea.util.FileUtil; +import nl.hannahsten.texifyidea.util.files.FileUtil; import nl.hannahsten.texifyidea.util.Magic; import nl.hannahsten.texifyidea.util.StringsKt; import org.jetbrains.annotations.NotNull; diff --git a/src/nl/hannahsten/texifyidea/action/analysis/WordCountAction.kt b/src/nl/hannahsten/texifyidea/action/analysis/WordCountAction.kt index b18021234..30e671b93 100644 --- a/src/nl/hannahsten/texifyidea/action/analysis/WordCountAction.kt +++ b/src/nl/hannahsten/texifyidea/action/analysis/WordCountAction.kt @@ -11,6 +11,8 @@ import com.intellij.psi.PsiWhiteSpace import nl.hannahsten.texifyidea.TexifyIcons import nl.hannahsten.texifyidea.psi.* import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.psiFile +import nl.hannahsten.texifyidea.util.files.referencedFileSet import java.util.regex.Pattern import javax.swing.JLabel import javax.swing.SwingConstants diff --git a/src/nl/hannahsten/texifyidea/action/group/LatexAnalyzeMenuGroup.kt b/src/nl/hannahsten/texifyidea/action/group/LatexAnalyzeMenuGroup.kt index 4ddcdbed4..a09fefa0e 100644 --- a/src/nl/hannahsten/texifyidea/action/group/LatexAnalyzeMenuGroup.kt +++ b/src/nl/hannahsten/texifyidea/action/group/LatexAnalyzeMenuGroup.kt @@ -3,7 +3,7 @@ package nl.hannahsten.texifyidea.action.group import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.DefaultActionGroup -import nl.hannahsten.texifyidea.util.isLatexFile +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/action/group/LatexEditMenuGroup.kt b/src/nl/hannahsten/texifyidea/action/group/LatexEditMenuGroup.kt index bececdba3..522d279b6 100644 --- a/src/nl/hannahsten/texifyidea/action/group/LatexEditMenuGroup.kt +++ b/src/nl/hannahsten/texifyidea/action/group/LatexEditMenuGroup.kt @@ -3,7 +3,7 @@ package nl.hannahsten.texifyidea.action.group import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.DefaultActionGroup -import nl.hannahsten.texifyidea.util.isLatexFile +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/action/group/LatexToolsMenuGroup.kt b/src/nl/hannahsten/texifyidea/action/group/LatexToolsMenuGroup.kt index 608c7c2b0..9494d79cc 100644 --- a/src/nl/hannahsten/texifyidea/action/group/LatexToolsMenuGroup.kt +++ b/src/nl/hannahsten/texifyidea/action/group/LatexToolsMenuGroup.kt @@ -3,7 +3,7 @@ package nl.hannahsten.texifyidea.action.group import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.DefaultActionGroup -import nl.hannahsten.texifyidea.util.isLatexFile +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/completion/InsertBibtexTag.kt b/src/nl/hannahsten/texifyidea/completion/InsertBibtexTag.kt index 93c1889ec..59d9b2f61 100644 --- a/src/nl/hannahsten/texifyidea/completion/InsertBibtexTag.kt +++ b/src/nl/hannahsten/texifyidea/completion/InsertBibtexTag.kt @@ -15,6 +15,7 @@ import nl.hannahsten.texifyidea.editor.ShiftTracker import nl.hannahsten.texifyidea.file.BibtexFileType import nl.hannahsten.texifyidea.psi.* import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.java b/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.java index 10012cab5..d261c7580 100644 --- a/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.java +++ b/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.java @@ -23,6 +23,8 @@ import nl.hannahsten.texifyidea.lang.*; import nl.hannahsten.texifyidea.psi.LatexCommands; import nl.hannahsten.texifyidea.util.*; +import nl.hannahsten.texifyidea.util.files.FileSetKt; +import nl.hannahsten.texifyidea.util.files.FilesKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/nl/hannahsten/texifyidea/completion/LatexFileProvider.kt b/src/nl/hannahsten/texifyidea/completion/LatexFileProvider.kt index d2ef060d5..9110a29fa 100644 --- a/src/nl/hannahsten/texifyidea/completion/LatexFileProvider.kt +++ b/src/nl/hannahsten/texifyidea/completion/LatexFileProvider.kt @@ -15,6 +15,9 @@ import nl.hannahsten.texifyidea.completion.handlers.CompositeHandler import nl.hannahsten.texifyidea.completion.handlers.FileNameInsertionHandler import nl.hannahsten.texifyidea.completion.handlers.LatexReferenceInsertHandler import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFileSet +import nl.hannahsten.texifyidea.util.files.findRootFile +import nl.hannahsten.texifyidea.util.files.isLatexFile import java.util.* import java.util.regex.Pattern diff --git a/src/nl/hannahsten/texifyidea/completion/handlers/FileNameInsertionHandler.kt b/src/nl/hannahsten/texifyidea/completion/handlers/FileNameInsertionHandler.kt index 9529ea452..857680abe 100644 --- a/src/nl/hannahsten/texifyidea/completion/handlers/FileNameInsertionHandler.kt +++ b/src/nl/hannahsten/texifyidea/completion/handlers/FileNameInsertionHandler.kt @@ -6,6 +6,8 @@ import com.intellij.codeInsight.lookup.LookupElement import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexRequiredParam import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.removeFileExtension /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/completion/handlers/LatexNoMathInsertHandler.kt b/src/nl/hannahsten/texifyidea/completion/handlers/LatexNoMathInsertHandler.kt index 499a4459a..b723563f3 100644 --- a/src/nl/hannahsten/texifyidea/completion/handlers/LatexNoMathInsertHandler.kt +++ b/src/nl/hannahsten/texifyidea/completion/handlers/LatexNoMathInsertHandler.kt @@ -11,6 +11,7 @@ import com.intellij.codeInsight.template.impl.TemplateState import nl.hannahsten.texifyidea.lang.Environment import nl.hannahsten.texifyidea.lang.LatexCommand import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.definitionsAndRedefinitionsInFileSet /** * @author Hannah Schellekens, Sten Wessel diff --git a/src/nl/hannahsten/texifyidea/editor/LatexSoftWrapEditorListener.kt b/src/nl/hannahsten/texifyidea/editor/LatexSoftWrapEditorListener.kt index fa8dd97ab..abc5008df 100644 --- a/src/nl/hannahsten/texifyidea/editor/LatexSoftWrapEditorListener.kt +++ b/src/nl/hannahsten/texifyidea/editor/LatexSoftWrapEditorListener.kt @@ -3,8 +3,8 @@ package nl.hannahsten.texifyidea.editor import com.intellij.openapi.editor.event.EditorFactoryEvent import com.intellij.openapi.editor.event.EditorFactoryListener import nl.hannahsten.texifyidea.settings.TexifySettings -import nl.hannahsten.texifyidea.util.isLatexFile -import nl.hannahsten.texifyidea.util.psiFile +import nl.hannahsten.texifyidea.util.files.isLatexFile +import nl.hannahsten.texifyidea.util.files.psiFile /** * Enables automatic soft wrap when a LaTeX file is opened. diff --git a/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.java b/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.java index 691fc224b..5c836b722 100644 --- a/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.java +++ b/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.java @@ -14,8 +14,8 @@ import nl.hannahsten.texifyidea.lang.RequiredFileArgument; import nl.hannahsten.texifyidea.psi.LatexCommands; import nl.hannahsten.texifyidea.psi.LatexRequiredParam; -import nl.hannahsten.texifyidea.util.FilesKt; import nl.hannahsten.texifyidea.util.PsiCommandsKt; +import nl.hannahsten.texifyidea.util.files.FilesKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/nl/hannahsten/texifyidea/highlighting/LatexAnnotator.kt b/src/nl/hannahsten/texifyidea/highlighting/LatexAnnotator.kt index 7bd7d8e00..d0fa1fe22 100644 --- a/src/nl/hannahsten/texifyidea/highlighting/LatexAnnotator.kt +++ b/src/nl/hannahsten/texifyidea/highlighting/LatexAnnotator.kt @@ -10,6 +10,7 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.lang.Environment import nl.hannahsten.texifyidea.psi.* import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.definitionsAndRedefinitionsInFileSet /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/index/BibtexIdIndex.kt b/src/nl/hannahsten/texifyidea/index/BibtexIdIndex.kt index e0c79dab7..b40667106 100644 --- a/src/nl/hannahsten/texifyidea/index/BibtexIdIndex.kt +++ b/src/nl/hannahsten/texifyidea/index/BibtexIdIndex.kt @@ -9,7 +9,7 @@ import com.intellij.psi.stubs.StringStubIndexExtension import com.intellij.psi.stubs.StubIndex import com.intellij.util.ArrayUtil import nl.hannahsten.texifyidea.psi.BibtexId -import nl.hannahsten.texifyidea.util.referencedFileSet +import nl.hannahsten.texifyidea.util.files.referencedFileSet /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt b/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt index d10bd6c56..ee044d228 100644 --- a/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt +++ b/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt @@ -6,9 +6,9 @@ import com.intellij.psi.PsiFile import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StubIndex import com.intellij.psi.stubs.StubIndexKey -import nl.hannahsten.texifyidea.util.documentClassFile -import nl.hannahsten.texifyidea.util.findRootFile -import nl.hannahsten.texifyidea.util.referencedFileSet +import nl.hannahsten.texifyidea.util.files.documentClassFile +import nl.hannahsten.texifyidea.util.files.findRootFile +import nl.hannahsten.texifyidea.util.files.referencedFileSet /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/inspections/TexifyRegexInspection.kt b/src/nl/hannahsten/texifyidea/inspections/TexifyRegexInspection.kt index faa1c53ab..2a1671368 100644 --- a/src/nl/hannahsten/texifyidea/inspections/TexifyRegexInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/TexifyRegexInspection.kt @@ -10,6 +10,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.regex.Matcher import java.util.regex.Pattern diff --git a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographyInspection.kt b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographyInspection.kt index ff791c5b6..9a0b42b35 100644 --- a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographyInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographyInspection.kt @@ -11,7 +11,7 @@ import nl.hannahsten.texifyidea.index.LatexIncludesIndex import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.LatexCommands -import nl.hannahsten.texifyidea.util.commandsInFileSet +import nl.hannahsten.texifyidea.util.files.commandsInFileSet import nl.hannahsten.texifyidea.util.requiredParameter /** diff --git a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographystyleInspection.kt b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographystyleInspection.kt index ba5cf4cc6..0f8c37098 100644 --- a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographystyleInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateBibliographystyleInspection.kt @@ -10,8 +10,8 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.LatexCommands -import nl.hannahsten.texifyidea.util.commandsInFile -import nl.hannahsten.texifyidea.util.commandsInFileSet +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.commandsInFileSet import nl.hannahsten.texifyidea.util.findAtLeast /** diff --git a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateIdInspection.kt b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateIdInspection.kt index 06e911975..076ab3eb6 100644 --- a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateIdInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexDuplicateIdInspection.kt @@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.BibtexId import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFileSet /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexMissingBibliographystyleInspection.kt b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexMissingBibliographystyleInspection.kt index c43115ec2..5608bf2a7 100644 --- a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexMissingBibliographystyleInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexMissingBibliographystyleInspection.kt @@ -10,7 +10,11 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.LatexCommands -import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.endOffset +import nl.hannahsten.texifyidea.util.files.commandsInFileSet +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.openedEditor +import nl.hannahsten.texifyidea.util.lineIndentationByOffset /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt index f66aab9f2..3f1546406 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt @@ -13,6 +13,7 @@ import nl.hannahsten.texifyidea.lang.Package.Companion.AMSMATH import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexEnvironment import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspection.kt index 10c2ec364..39e4ee778 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspection.kt @@ -4,6 +4,7 @@ import com.intellij.codeInspection.ProblemDescriptor import nl.hannahsten.texifyidea.inspections.TexifyRegexInspection import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.regex.Pattern /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspection.kt index a014e984b..5fea1eb01 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspection.kt @@ -14,6 +14,7 @@ import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexContent import nl.hannahsten.texifyidea.psi.LatexNormalText import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.* import kotlin.collections.ArrayList diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspection.kt index 04787bb6f..74c132e78 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspection.kt @@ -11,7 +11,7 @@ import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.forcedFirstRequiredParameterAsCommand import nl.hannahsten.texifyidea.util.isKnown import nl.hannahsten.texifyidea.util.replaceString diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspection.kt index 5a4f0fdac..792aa3568 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspection.kt @@ -14,7 +14,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexPsiUtil -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspection.kt index ba218eec4..ca47d24e6 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspection.kt @@ -8,8 +8,8 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.util.definedCommandName -import nl.hannahsten.texifyidea.util.definitions -import nl.hannahsten.texifyidea.util.definitionsInFileSet +import nl.hannahsten.texifyidea.util.files.definitions +import nl.hannahsten.texifyidea.util.files.definitionsInFileSet import nl.hannahsten.texifyidea.util.isCommandDefinition /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspection.kt index 496804736..6362361d6 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspection.kt @@ -9,6 +9,9 @@ import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.bibtexIdsInFileSet +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.commandsInFileSet import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEnDashInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEnDashInspection.kt index 0f4726ec7..a81456d57 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEnDashInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEnDashInspection.kt @@ -4,7 +4,7 @@ import com.intellij.codeInspection.ProblemDescriptor import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.inspections.TexifyRegexInspection import nl.hannahsten.texifyidea.util.Magic -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.length import nl.hannahsten.texifyidea.util.toTextRange import java.util.regex.Pattern diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspection.kt index 8768eaa1e..d2e899651 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspection.kt @@ -16,6 +16,7 @@ import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexDisplayMath import nl.hannahsten.texifyidea.psi.LatexInlineMath import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspection.kt index d1b238a73..f90d41ed9 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspection.kt @@ -4,7 +4,7 @@ import com.intellij.codeInspection.ProblemDescriptor import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.inspections.TexifyRegexInspection import nl.hannahsten.texifyidea.lang.Package -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.findLabels import nl.hannahsten.texifyidea.util.findOuterMathEnvironment import nl.hannahsten.texifyidea.util.insertUsepackage diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexFigureNotReferencedInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexFigureNotReferencedInspection.kt index 3f06a5547..1989c59e7 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexFigureNotReferencedInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexFigureNotReferencedInspection.kt @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFile import java.util.* open class LatexFigureNotReferencedInspection : TexifyInspectionBase() { diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspection.kt index ed802fc6f..69c8f1245 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspection.kt @@ -15,8 +15,8 @@ import nl.hannahsten.texifyidea.lang.RequiredArgument import nl.hannahsten.texifyidea.lang.RequiredFileArgument import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexNormalText -import nl.hannahsten.texifyidea.util.findFile -import nl.hannahsten.texifyidea.util.findRootFile +import nl.hannahsten.texifyidea.util.files.findFile +import nl.hannahsten.texifyidea.util.files.findRootFile import nl.hannahsten.texifyidea.util.firstChildOfType import java.util.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspection.kt index 0dfcd3975..589fa30fd 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspection.kt @@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.Package.Companion.AMSMATH import nl.hannahsten.texifyidea.psi.LatexContent import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexInclusionLoopInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexInclusionLoopInspection.kt index 4a4556fc5..fa9413942 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexInclusionLoopInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexInclusionLoopInspection.kt @@ -9,9 +9,9 @@ import nl.hannahsten.texifyidea.algorithm.BFS import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase -import nl.hannahsten.texifyidea.util.findInclusions -import nl.hannahsten.texifyidea.util.findRelativeFile -import nl.hannahsten.texifyidea.util.findRootFile +import nl.hannahsten.texifyidea.util.files.findInclusions +import nl.hannahsten.texifyidea.util.files.findRelativeFile +import nl.hannahsten.texifyidea.util.files.findRootFile import nl.hannahsten.texifyidea.util.requiredParameter /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt index 1eb877281..d87787128 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt @@ -11,6 +11,9 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.* import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.commandsInFileSet +import nl.hannahsten.texifyidea.util.files.document import java.util.* import kotlin.Comparator import kotlin.collections.ArrayList diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt index 0b02de83a..e6106ec91 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt @@ -12,6 +12,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.LatexComment import nl.hannahsten.texifyidea.psi.LatexNormalText import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import kotlin.math.min /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspection.kt index c7f42a6c6..2e6afda89 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspection.kt @@ -13,7 +13,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexBeginCommand import nl.hannahsten.texifyidea.util.childrenOfType -import nl.hannahsten.texifyidea.util.referencedFileSet +import nl.hannahsten.texifyidea.util.files.referencedFileSet import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt index ee0f49bef..b7bc094f4 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt @@ -20,6 +20,8 @@ import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexEnvironment import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.definitionsAndRedefinitionsInFileSet import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index 14503baf4..91b4a30b9 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -11,6 +11,9 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.openedEditor import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspection.kt index d7837e521..a8527b7cf 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspection.kt @@ -10,7 +10,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexRequiredParam import nl.hannahsten.texifyidea.util.PackageUtils -import nl.hannahsten.texifyidea.util.commandsInFile +import nl.hannahsten.texifyidea.util.files.commandsInFile import nl.hannahsten.texifyidea.util.firstChildOfType import nl.hannahsten.texifyidea.util.requiredParameter import java.util.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNestedIncludesInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNestedIncludesInspection.kt index 91ff6e3b7..d237632d6 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNestedIncludesInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNestedIncludesInspection.kt @@ -14,6 +14,9 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.findRelativeFile +import nl.hannahsten.texifyidea.util.files.findRootFile import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt index 20c7cc99c..1fe90b2bb 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt @@ -13,7 +13,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.Magic -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.replaceString import nl.hannahsten.texifyidea.util.requiredParameter import java.util.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt index 8528b1a55..b526bf26c 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt @@ -16,7 +16,7 @@ import nl.hannahsten.texifyidea.psi.LatexContent import nl.hannahsten.texifyidea.psi.LatexNormalText import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.childrenOfType -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.parentOfType import java.util.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspection.kt index 7844954d4..5ce53bea7 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspection.kt @@ -12,6 +12,7 @@ import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexBeginCommand import nl.hannahsten.texifyidea.psi.LatexEndCommand import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt index 906e0bdc7..b2ca0cbe5 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt @@ -8,7 +8,7 @@ import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.Magic -import nl.hannahsten.texifyidea.util.commandsInFile +import nl.hannahsten.texifyidea.util.files.commandsInFile import nl.hannahsten.texifyidea.util.matches import java.util.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveEquationInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveEquationInspection.kt index a18d129d4..7aadb6096 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveEquationInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveEquationInspection.kt @@ -4,7 +4,7 @@ import com.intellij.codeInspection.ProblemDescriptor import com.intellij.codeInspection.ProblemHighlightType import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.inspections.TexifyRegexInspection -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.toTextRange import java.util.regex.Matcher import java.util.regex.Pattern diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt index 9a005b9c6..ffb451008 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt @@ -14,7 +14,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.psi.LatexNormalText import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.childrenOfType -import nl.hannahsten.texifyidea.util.document +import nl.hannahsten.texifyidea.util.files.document import nl.hannahsten.texifyidea.util.inMathContext /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspection.kt index e41020b46..c4731b0f5 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspection.kt @@ -19,6 +19,9 @@ import nl.hannahsten.texifyidea.psi.LatexEndCommand import nl.hannahsten.texifyidea.psi.LatexPsiUtil import nl.hannahsten.texifyidea.ui.CreateFileDialog import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.createFile +import nl.hannahsten.texifyidea.util.files.findRootFile import org.intellij.lang.annotations.Language import java.io.File import java.util.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhitespaceInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhitespaceInspection.kt index 8008ce7a6..f9d13705a 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhitespaceInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhitespaceInspection.kt @@ -13,6 +13,8 @@ import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexRequiredParam import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.commandsInFile +import nl.hannahsten.texifyidea.util.files.document import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnresolvedReferenceInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnresolvedReferenceInspection.kt index 8cf143359..3b2a5c9e2 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnresolvedReferenceInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnresolvedReferenceInspection.kt @@ -9,7 +9,7 @@ import nl.hannahsten.texifyidea.insight.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.util.Magic -import nl.hannahsten.texifyidea.util.commandsInFile +import nl.hannahsten.texifyidea.util.files.commandsInFile import nl.hannahsten.texifyidea.util.findLabelsInFileSet import nl.hannahsten.texifyidea.util.hasStar import java.util.* diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexDisplayMathIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexDisplayMathIntention.kt index f187a6d72..6faa7779e 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexDisplayMathIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexDisplayMathIntention.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.psi.LatexBeginCommand import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexInlineDisplayToggle.kt b/src/nl/hannahsten/texifyidea/intentions/LatexInlineDisplayToggle.kt index 5ead4239f..194292e9a 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexInlineDisplayToggle.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexInlineDisplayToggle.kt @@ -8,6 +8,7 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.psi.LatexDisplayMath import nl.hannahsten.texifyidea.psi.LatexInlineMath import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexLeftRightParenthesesIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexLeftRightParenthesesIntention.kt index e087cada1..4f51fab65 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexLeftRightParenthesesIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexLeftRightParenthesesIntention.kt @@ -9,6 +9,8 @@ import com.intellij.psi.PsiComment import com.intellij.psi.PsiFile import com.intellij.psi.PsiWhiteSpace import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexMathToggle.kt b/src/nl/hannahsten/texifyidea/intentions/LatexMathToggle.kt index 469ac42a7..6c7da9e9c 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexMathToggle.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexMathToggle.kt @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.psi.LatexBeginCommand import nl.hannahsten.texifyidea.psi.LatexDisplayMath import nl.hannahsten.texifyidea.psi.LatexInlineMath import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens, Abby Berkers diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexMoveSectionToFileIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexMoveSectionToFileIntention.kt index 6acd2b40b..d4a3261aa 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexMoveSectionToFileIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexMoveSectionToFileIntention.kt @@ -9,6 +9,10 @@ import nl.hannahsten.texifyidea.inspections.latex.LatexTooLargeSectionInspection import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.ui.CreateFileDialog import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.createFile +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.findRootFile +import nl.hannahsten.texifyidea.util.files.isLatexFile import java.io.File /** diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexMoveSelectionToFileIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexMoveSelectionToFileIntention.kt index f5037d9cb..d7662e85e 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexMoveSelectionToFileIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexMoveSelectionToFileIntention.kt @@ -6,9 +6,9 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.ui.CreateFileDialog -import nl.hannahsten.texifyidea.util.createFile -import nl.hannahsten.texifyidea.util.findRootFile -import nl.hannahsten.texifyidea.util.isLatexFile +import nl.hannahsten.texifyidea.util.files.createFile +import nl.hannahsten.texifyidea.util.files.findRootFile +import nl.hannahsten.texifyidea.util.files.isLatexFile import nl.hannahsten.texifyidea.util.removeIndents import org.intellij.lang.annotations.Language import java.io.File diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexUnpackUsepackageIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexUnpackUsepackageIntention.kt index 41b08b9c7..d000b56e5 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexUnpackUsepackageIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexUnpackUsepackageIntention.kt @@ -7,6 +7,8 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexRequiredParam import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.isLatexFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/lang/magic/MagicComments.kt b/src/nl/hannahsten/texifyidea/lang/magic/MagicComments.kt index 159607c3c..e3398d643 100644 --- a/src/nl/hannahsten/texifyidea/lang/magic/MagicComments.kt +++ b/src/nl/hannahsten/texifyidea/lang/magic/MagicComments.kt @@ -7,6 +7,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.psi.* import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.java b/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.java index 590391c15..7ce37519d 100644 --- a/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.java +++ b/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.java @@ -10,10 +10,10 @@ import nl.hannahsten.texifyidea.psi.BibtexId; import nl.hannahsten.texifyidea.psi.LatexCommands; import nl.hannahsten.texifyidea.psi.LatexRequiredParam; -import nl.hannahsten.texifyidea.util.FileSetKt; import nl.hannahsten.texifyidea.util.LabelsKt; import nl.hannahsten.texifyidea.util.Magic; import nl.hannahsten.texifyidea.util.StringsKt; +import nl.hannahsten.texifyidea.util.files.FileSetKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/nl/hannahsten/texifyidea/run/LatexCommandLineState.kt b/src/nl/hannahsten/texifyidea/run/LatexCommandLineState.kt index 8c4fcd271..1662acb53 100644 --- a/src/nl/hannahsten/texifyidea/run/LatexCommandLineState.kt +++ b/src/nl/hannahsten/texifyidea/run/LatexCommandLineState.kt @@ -16,7 +16,10 @@ import nl.hannahsten.texifyidea.run.evince.EvinceForwardSearch import nl.hannahsten.texifyidea.run.evince.isEvinceAvailable import nl.hannahsten.texifyidea.run.sumatra.SumatraForwardSearch import nl.hannahsten.texifyidea.run.sumatra.isSumatraAvailable -import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.FileUtil +import nl.hannahsten.texifyidea.util.files.createExcludedDir +import nl.hannahsten.texifyidea.util.files.psiFile +import nl.hannahsten.texifyidea.util.files.referencedFileSet import java.io.File /** diff --git a/src/nl/hannahsten/texifyidea/run/evince/EvinceForwardSearch.kt b/src/nl/hannahsten/texifyidea/run/evince/EvinceForwardSearch.kt index 19263f6eb..646fe2aa2 100644 --- a/src/nl/hannahsten/texifyidea/run/evince/EvinceForwardSearch.kt +++ b/src/nl/hannahsten/texifyidea/run/evince/EvinceForwardSearch.kt @@ -4,8 +4,8 @@ import com.intellij.execution.process.ProcessHandler import com.intellij.execution.runners.ExecutionEnvironment import nl.hannahsten.texifyidea.run.LatexRunConfiguration import nl.hannahsten.texifyidea.util.caretOffset -import nl.hannahsten.texifyidea.util.openedEditor -import nl.hannahsten.texifyidea.util.psiFile +import nl.hannahsten.texifyidea.util.files.openedEditor +import nl.hannahsten.texifyidea.util.files.psiFile /** * Provides forward search for Evince. diff --git a/src/nl/hannahsten/texifyidea/run/sumatra/SumatraForwardSearch.kt b/src/nl/hannahsten/texifyidea/run/sumatra/SumatraForwardSearch.kt index e8e9900ba..af2b97c67 100644 --- a/src/nl/hannahsten/texifyidea/run/sumatra/SumatraForwardSearch.kt +++ b/src/nl/hannahsten/texifyidea/run/sumatra/SumatraForwardSearch.kt @@ -6,6 +6,10 @@ import nl.hannahsten.texifyidea.TeXception import nl.hannahsten.texifyidea.psi.LatexEnvironment import nl.hannahsten.texifyidea.run.LatexRunConfiguration import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.isRoot +import nl.hannahsten.texifyidea.util.files.openedEditor +import nl.hannahsten.texifyidea.util.files.psiFile import org.jetbrains.concurrency.runAsync /** diff --git a/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt b/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt index 63d946ac8..c6238beda 100644 --- a/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt +++ b/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt @@ -21,6 +21,9 @@ import nl.hannahsten.texifyidea.psi.LatexTypes import nl.hannahsten.texifyidea.structure.bibtex.BibtexStructureViewElement import nl.hannahsten.texifyidea.structure.latex.SectionNumbering.DocumentClass import nl.hannahsten.texifyidea.util.* +import nl.hannahsten.texifyidea.util.files.documentClassFile +import nl.hannahsten.texifyidea.util.files.findFile +import nl.hannahsten.texifyidea.util.files.findRootFile import java.util.* /** diff --git a/src/nl/hannahsten/texifyidea/util/Packages.kt b/src/nl/hannahsten/texifyidea/util/Packages.kt index 5a283b936..f9f0c844e 100644 --- a/src/nl/hannahsten/texifyidea/util/Packages.kt +++ b/src/nl/hannahsten/texifyidea/util/Packages.kt @@ -6,6 +6,9 @@ import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.lang.Package import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.util.files.document +import nl.hannahsten.texifyidea.util.files.isClassFile +import nl.hannahsten.texifyidea.util.files.isStyleFile /** * @author Hannah Schellekens diff --git a/src/nl/hannahsten/texifyidea/util/Projects.kt b/src/nl/hannahsten/texifyidea/util/Projects.kt index 8ad966d0b..be223ca91 100644 --- a/src/nl/hannahsten/texifyidea/util/Projects.kt +++ b/src/nl/hannahsten/texifyidea/util/Projects.kt @@ -1,9 +1,13 @@ package nl.hannahsten.texifyidea.util +import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ProjectRootManager +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.search.FileTypeIndex import com.intellij.psi.search.GlobalSearchScope import nl.hannahsten.texifyidea.index.LatexDefinitionIndex +import nl.hannahsten.texifyidea.util.files.allChildFiles /** * Get a project [GlobalSearchScope] for this project. @@ -33,4 +37,12 @@ fun Project.findAvailableDocumentClasses(): Set { .filter { it.isNotEmpty() } .mapNotNull { it.firstOrNull() } .toSet() +} + +/** + * Get all the virtual files that are in the project of a given file type. + */ +fun Project.allFiles(type: FileType): Collection { + val scope = GlobalSearchScope.projectScope(this) + return FileTypeIndex.getFiles(type, scope) } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/util/Psi.kt b/src/nl/hannahsten/texifyidea/util/Psi.kt index 836517dbf..6b0aa8fdc 100644 --- a/src/nl/hannahsten/texifyidea/util/Psi.kt +++ b/src/nl/hannahsten/texifyidea/util/Psi.kt @@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.lang.DefaultEnvironment import nl.hannahsten.texifyidea.lang.Environment import nl.hannahsten.texifyidea.lang.magic.TextBasedMagicCommentParser import nl.hannahsten.texifyidea.psi.* +import nl.hannahsten.texifyidea.util.files.commandsInFileSet import kotlin.reflect.KClass //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/nl/hannahsten/texifyidea/util/PsiCommands.kt b/src/nl/hannahsten/texifyidea/util/PsiCommands.kt index f12450528..a0cec9a63 100644 --- a/src/nl/hannahsten/texifyidea/util/PsiCommands.kt +++ b/src/nl/hannahsten/texifyidea/util/PsiCommands.kt @@ -6,6 +6,7 @@ import com.intellij.psi.util.PsiTreeUtil import nl.hannahsten.texifyidea.lang.LatexMathCommand import nl.hannahsten.texifyidea.lang.LatexRegularCommand import nl.hannahsten.texifyidea.psi.* +import nl.hannahsten.texifyidea.util.files.document /** * Checks whether the given LaTeX commands is a definition or not. diff --git a/src/nl/hannahsten/texifyidea/util/FileSet.kt b/src/nl/hannahsten/texifyidea/util/files/FileSet.kt similarity index 87% rename from src/nl/hannahsten/texifyidea/util/FileSet.kt rename to src/nl/hannahsten/texifyidea/util/files/FileSet.kt index f3e8b01bf..2bb2141d9 100644 --- a/src/nl/hannahsten/texifyidea/util/FileSet.kt +++ b/src/nl/hannahsten/texifyidea/util/files/FileSet.kt @@ -1,4 +1,4 @@ -package nl.hannahsten.texifyidea.util +package nl.hannahsten.texifyidea.util.files import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.index.BibtexIdIndex @@ -6,12 +6,16 @@ import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.index.LatexDefinitionIndex import nl.hannahsten.texifyidea.index.LatexIncludesIndex import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.util.isDefinition /** * Finds all the files in the project that are somehow related using includes. - *

+ * * When A includes B and B includes C then A, B & C will all return a set containing A, B & C. * + * Be careful when using this function directly over something like [ReferencedFileSetService] where the result + * values are cached. + * * @param baseFile * The file to find the reference set of. * @return All the files that are cross referenced between each other. @@ -57,7 +61,9 @@ fun findReferencedFileSet(baseFile: PsiFile): Set { * * @return All the files that are cross referenced between each other. */ -fun PsiFile.referencedFileSet(): Set = findReferencedFileSet(this) +fun PsiFile.referencedFileSet(): Set { + return ReferencedFileSetService.getInstance(project).referencedFileSetOf(this) +} /** * @see [BibtexIdIndex.getIndexedIdsInFileSet] diff --git a/src/nl/hannahsten/texifyidea/util/Files.kt b/src/nl/hannahsten/texifyidea/util/files/Files.kt similarity index 99% rename from src/nl/hannahsten/texifyidea/util/Files.kt rename to src/nl/hannahsten/texifyidea/util/files/Files.kt index 5ab4f33af..835010599 100644 --- a/src/nl/hannahsten/texifyidea/util/Files.kt +++ b/src/nl/hannahsten/texifyidea/util/files/Files.kt @@ -1,4 +1,4 @@ -package nl.hannahsten.texifyidea.util +package nl.hannahsten.texifyidea.util.files import com.intellij.openapi.editor.Document import com.intellij.openapi.fileEditor.FileEditorManager @@ -23,6 +23,7 @@ import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.index.LatexDefinitionIndex import nl.hannahsten.texifyidea.lang.Package import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.util.* import java.io.File import java.nio.charset.StandardCharsets import java.util.* diff --git a/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt new file mode 100644 index 000000000..ff54d044b --- /dev/null +++ b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt @@ -0,0 +1,101 @@ +package nl.hannahsten.texifyidea.util.files + +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.ModificationTracker +import com.intellij.psi.PsiFile +import com.intellij.psi.util.CachedValue +import com.intellij.psi.util.CachedValueProvider +import com.intellij.psi.util.CachedValuesManager +import com.intellij.psi.util.PsiModificationTracker + +/** + * Caches the values for [findReferencedFileSet] calls. + * + * @author Hannah Schellekens + */ +class ReferencedFileSetCache(val project: Project) { + + private val valueManager = CachedValuesManager.getManager(project) + + /** + * Traks the modification counts for each base psi file. + */ + private val modificationTracker = HashMap() + + /** + * The dependencies for the file set cache of the key file. + * + * @see CachedValueProvider.Result.getDependencyItems + */ + private val dependencies = HashMap>() + + /** + * A cached file set value for each base file. + * + * The base file is the file from which the file set request came from. + * Meaning that a base file `A` is mapped to the file set with `A` as search root, `B` is mapped to the file set + * with `B` as search root etc. + * It could be that multiple values are equal. + */ + private val fileSetCache = HashMap>>() + + /** + * Creates a new cached value for the file set of base file `psiFile`. + * This will register the cache to the [CachedValuesManager] and store the cached value. + */ + fun buildCacheFor(psiFile: PsiFile): CachedValue> { + val psiFileCache = valueManager.createCachedValue { + CachedValueProvider.Result.create(findReferencedFileSet(psiFile), dependenciesFor(psiFile)) + } + fileSetCache[psiFile] = psiFileCache + return psiFileCache + } + + /** + * Get the file set of base file `file`. + * When the cache is outdated, this will first update the cache. + */ + fun fileSetFor(file: PsiFile): Set { + val cache = fileSetCache[file] ?: buildCacheFor(file) + return cache.value ?: emptySet() + } + + /** + * Clears the cache for base file `file`. + */ + fun dropCaches(file: PsiFile) { + modificationTrackerFor(file).myModificationCount++ + } + + /** + * Also stores the dependencies if they didn't exist yet. + * + * @see dependencies + */ + private fun dependenciesFor(psiFile: PsiFile): Array { + return dependencies.getOrPut(psiFile) { + arrayOf(PsiModificationTracker.MODIFICATION_COUNT, modificationTrackerFor(psiFile)) + } + } + + /** + * Also stores the created modification tracker if it didn't exist yet. + * + * @see modificationTracker + */ + private fun modificationTrackerFor(psiFile: PsiFile): MyModificationTracker { + return modificationTracker.getOrPut(psiFile) { MyModificationTracker() } + } + + /** + * Modification tracked used to invalidate the caches. + * + * @author Hannah Schellekens + */ + private class MyModificationTracker : ModificationTracker { + + var myModificationCount: Long = 0 + + override fun getModificationCount(): Long = myModificationCount + } +} \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetService.kt b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetService.kt new file mode 100644 index 000000000..732679dc3 --- /dev/null +++ b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetService.kt @@ -0,0 +1,29 @@ +package nl.hannahsten.texifyidea.util.files + +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiFile + +/** + * @author Hannah Schellekens + */ +interface ReferencedFileSetService { + + companion object { + + @JvmStatic + fun getInstance(project: Project): ReferencedFileSetService { + return ServiceManager.getService(project, ReferencedFileSetService::class.java) + } + } + + /** + * [findReferencedFileSet], but then with cached values. + */ + fun referencedFileSetOf(psiFile: PsiFile): Set + + /** + * Invalidates the caches for the given file. + */ + fun dropCaches(psiFile: PsiFile) +} \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/util/files/impl/ReferencedFileSetServiceImpl.kt b/src/nl/hannahsten/texifyidea/util/files/impl/ReferencedFileSetServiceImpl.kt new file mode 100644 index 000000000..01bb4319f --- /dev/null +++ b/src/nl/hannahsten/texifyidea/util/files/impl/ReferencedFileSetServiceImpl.kt @@ -0,0 +1,18 @@ +package nl.hannahsten.texifyidea.util.files.impl + +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiFile +import nl.hannahsten.texifyidea.util.files.ReferencedFileSetCache +import nl.hannahsten.texifyidea.util.files.ReferencedFileSetService + +/** + * @author Hannah Schellekens + */ +class ReferencedFileSetServiceImpl(project: Project) : ReferencedFileSetService { + + private val cache = ReferencedFileSetCache(project) + + override fun referencedFileSetOf(psiFile: PsiFile) = cache.fileSetFor(psiFile) + + override fun dropCaches(psiFile: PsiFile) = cache.dropCaches(psiFile) +} \ No newline at end of file From 7a5d01b4c32e13ce5027d4140c582b8a2ef7ed25 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 2 Jul 2019 17:25:14 +0200 Subject: [PATCH 4/6] Typo --- .../hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt index ff54d044b..667f7400a 100644 --- a/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt +++ b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt @@ -18,7 +18,7 @@ class ReferencedFileSetCache(val project: Project) { private val valueManager = CachedValuesManager.getManager(project) /** - * Traks the modification counts for each base psi file. + * Tracks the modification counts for each base psi file. */ private val modificationTracker = HashMap() From 34cb28f55fd316a13b8d62b500d201d5cc09dc70 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Wed, 3 Jul 2019 06:22:33 -0700 Subject: [PATCH 5/6] Address comment: fix code style (and use better `TextRange` API) --- .../latex/LatexAvoidEqnarrayInspection.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt index d0633ffc0..2f75ad54a 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspection.kt @@ -39,14 +39,16 @@ open class LatexAvoidEqnarrayInspection : TexifyInspectionBase() { } val star = name.substring("eqnarray".length) - if (env.endCommand != null) descriptors.add(manager.createProblemDescriptor( - env, - TextRange(7, 7 + name.length), - "Avoid using the 'eqnarray$star' environment", - ProblemHighlightType.GENERIC_ERROR_OR_WARNING, - isOntheFly, - ChangeEnvironmentFix(star) - )) + if (env.endCommand != null) { + descriptors.add(manager.createProblemDescriptor( + env, + TextRange.from(7, name.length), + "Avoid using the 'eqnarray$star' environment", + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, + isOntheFly, + ChangeEnvironmentFix(star) + )) + } } return descriptors From 341e3416d449c8d2a1c12973e3e5ff597094517f Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 5 Nov 2019 20:42:26 +0100 Subject: [PATCH 6/6] Try to trigger a report for both Travis builds instead of only one --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ff89e0205..35ad7c9be 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,6 @@ when you do not recognize the file. * Ctrl+K Commit and push changes. * Ctrl+T Pull changes. - Any suggestions for improvements of the installation instructions, however small? Please let us know at [gitter](https://gitter.im/TeXiFy-IDEA)! ## Equation preview and TikZ Preview