@@ -0,0 +1,2205 @@
+package com.cedricziel.idea.typo3.util;%0A%0Aimport com.intellij.codeInsight.completion.CompletionResultSet;%0Aimport com.intellij.codeInsight.lookup.LookupElement;%0Aimport com.intellij.openapi.fileEditor.impl.LoadTextUtil;%0Aimport com.intellij.openapi.project.Project;%0Aimport com.intellij.psi.PsiFile;%0Aimport com.intellij.psi.search.FilenameIndex;%0Aimport com.intellij.psi.search.GlobalSearchScope;%0Aimport org.jetbrains.annotations.NotNull;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0Apublic class TableUtil %7B%0A%0A    public static final String EXT_TABLES_SQL_FILENAME = %22ext_tables.sql%22;%0A%0A    public static Set%3CString%3E getAvailableTableNames(@NotNull Project project) %7B%0A        PsiFile%5B%5D extSqlFiles = FilenameIndex.getFilesByName(project, EXT_TABLES_SQL_FILENAME, GlobalSearchScope.allScope(project));%0A%0A        Set%3CString%3E tableNames = new HashSet%3C%3E();%0A%0A        for (PsiFile psiFile : extSqlFiles) %7B%0A%0A            if (psiFile != null) %7B%0A%0A                CharSequence charSequence = LoadTextUtil.loadText(psiFile.getVirtualFile());%0A%0A                final Matcher matcher = Pattern%0A                        .compile(%22create%5C%5Cs+table%5C%5Cs+(if%5C%5Cs+not%5C%5Cs+exists%5C%5Cs+)?(%5Ba-zA-Z_0-9%5D+)%22, Pattern.CASE_INSENSITIVE)%0A                        .matcher(charSequence);%0A%0A                try %7B%0A                    while (matcher.find()) %7B%0A                        if (matcher.groupCount() %3C 2) %7B%0A                            return tableNames;%0A                        %7D%0A%0A                        tableNames.add(matcher.group(2));%0A                    %7D%0A                %7D catch (IllegalStateException e) %7B%0A                    // no matches%0A                %7D%0A            %7D%0A        %7D%0A%0A        return tableNames;%0A    %7D%0A%0A    public static void completeAvailableTableNames(@NotNull Project project, @NotNull CompletionResultSet completionResultSet) %7B%0A        for (String name : TableUtil.getAvailableTableNames(project)) %7B%0A            completionResultSet.addElement(new LookupElement() %7B%0A                @NotNull%0A                @Override%0A                public String getLookupString() %7B%0A%0A                    return name;%0A                %7D%0A            %7D);%0A        %7D%0A    %7D%0A%7D%0A

Refactor table-related extraction logic to TableUtil