@Test public void editorFile1_include_subfolder1_results_in_1_file() throws Exception { String text = "include::subfolder1/"; int index = text.length(); Set<AsciidocReferenceProposalData> result = toTest.calculate(editorFile1, text, index); assertNotNull(result); assertEquals(1, result.size()); Iterator<AsciidocReferenceProposalData> it = result.iterator(); assertEquals("include::subfolder1/otherfile4.adoc[]",it.next().getProposedCode()); }
public Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace) { String referenceText = calculator.resolveReferenceTextOrNull(fullSource, indexForCtrlSpace); if (referenceText==null) { return Collections.emptySet(); } Path path = Paths.get(referenceText.substring(getPrefix().length())); File parent = baseParentDirResolver.getBaseParentDir(editorFile); if (parent==null) { return Collections.emptySet(); } Path parentPath = path.getParent(); if (parentPath!=null && !parentPath.toString().isEmpty()) { File newParent = parent.toPath().resolve(parentPath).toFile(); if (!newParent.exists()) { return Collections.emptySet(); } parent = newParent; path = parentPath.relativize(path); } Path separatedParentPath = parent.toPath(); String search = null; if (path.toString().length() > 0) { File newParent = separatedParentPath.resolve(path).toFile(); if (newParent.exists()) { parent = newParent; }else { search = path.toString(); } } final String toSearch = search; File[] files = fetchFiles(editorFile, parent, toSearch); if (files==null) { return Collections.emptySet(); } return buildProposals(editorFile, files); }
AsciidocReferenceProposalCalculator { public Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace) { String referenceText = calculator.resolveReferenceTextOrNull(fullSource, indexForCtrlSpace); if (referenceText==null) { return Collections.emptySet(); } Path path = Paths.get(referenceText.substring(getPrefix().length())); File parent = baseParentDirResolver.getBaseParentDir(editorFile); if (parent==null) { return Collections.emptySet(); } Path parentPath = path.getParent(); if (parentPath!=null && !parentPath.toString().isEmpty()) { File newParent = parent.toPath().resolve(parentPath).toFile(); if (!newParent.exists()) { return Collections.emptySet(); } parent = newParent; path = parentPath.relativize(path); } Path separatedParentPath = parent.toPath(); String search = null; if (path.toString().length() > 0) { File newParent = separatedParentPath.resolve(path).toFile(); if (newParent.exists()) { parent = newParent; }else { search = path.toString(); } } final String toSearch = search; File[] files = fetchFiles(editorFile, parent, toSearch); if (files==null) { return Collections.emptySet(); } return buildProposals(editorFile, files); } }
AsciidocReferenceProposalCalculator { public Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace) { String referenceText = calculator.resolveReferenceTextOrNull(fullSource, indexForCtrlSpace); if (referenceText==null) { return Collections.emptySet(); } Path path = Paths.get(referenceText.substring(getPrefix().length())); File parent = baseParentDirResolver.getBaseParentDir(editorFile); if (parent==null) { return Collections.emptySet(); } Path parentPath = path.getParent(); if (parentPath!=null && !parentPath.toString().isEmpty()) { File newParent = parent.toPath().resolve(parentPath).toFile(); if (!newParent.exists()) { return Collections.emptySet(); } parent = newParent; path = parentPath.relativize(path); } Path separatedParentPath = parent.toPath(); String search = null; if (path.toString().length() > 0) { File newParent = separatedParentPath.resolve(path).toFile(); if (newParent.exists()) { parent = newParent; }else { search = path.toString(); } } final String toSearch = search; File[] files = fetchFiles(editorFile, parent, toSearch); if (files==null) { return Collections.emptySet(); } return buildProposals(editorFile, files); } AsciidocReferenceProposalCalculator(String prefix, BaseParentDirResolver baseParentDirResolver, CodeAssistFileFilter fileFilter); }
AsciidocReferenceProposalCalculator { public Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace) { String referenceText = calculator.resolveReferenceTextOrNull(fullSource, indexForCtrlSpace); if (referenceText==null) { return Collections.emptySet(); } Path path = Paths.get(referenceText.substring(getPrefix().length())); File parent = baseParentDirResolver.getBaseParentDir(editorFile); if (parent==null) { return Collections.emptySet(); } Path parentPath = path.getParent(); if (parentPath!=null && !parentPath.toString().isEmpty()) { File newParent = parent.toPath().resolve(parentPath).toFile(); if (!newParent.exists()) { return Collections.emptySet(); } parent = newParent; path = parentPath.relativize(path); } Path separatedParentPath = parent.toPath(); String search = null; if (path.toString().length() > 0) { File newParent = separatedParentPath.resolve(path).toFile(); if (newParent.exists()) { parent = newParent; }else { search = path.toString(); } } final String toSearch = search; File[] files = fetchFiles(editorFile, parent, toSearch); if (files==null) { return Collections.emptySet(); } return buildProposals(editorFile, files); } AsciidocReferenceProposalCalculator(String prefix, BaseParentDirResolver baseParentDirResolver, CodeAssistFileFilter fileFilter); Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace); }
AsciidocReferenceProposalCalculator { public Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace) { String referenceText = calculator.resolveReferenceTextOrNull(fullSource, indexForCtrlSpace); if (referenceText==null) { return Collections.emptySet(); } Path path = Paths.get(referenceText.substring(getPrefix().length())); File parent = baseParentDirResolver.getBaseParentDir(editorFile); if (parent==null) { return Collections.emptySet(); } Path parentPath = path.getParent(); if (parentPath!=null && !parentPath.toString().isEmpty()) { File newParent = parent.toPath().resolve(parentPath).toFile(); if (!newParent.exists()) { return Collections.emptySet(); } parent = newParent; path = parentPath.relativize(path); } Path separatedParentPath = parent.toPath(); String search = null; if (path.toString().length() > 0) { File newParent = separatedParentPath.resolve(path).toFile(); if (newParent.exists()) { parent = newParent; }else { search = path.toString(); } } final String toSearch = search; File[] files = fetchFiles(editorFile, parent, toSearch); if (files==null) { return Collections.emptySet(); } return buildProposals(editorFile, files); } AsciidocReferenceProposalCalculator(String prefix, BaseParentDirResolver baseParentDirResolver, CodeAssistFileFilter fileFilter); Set<AsciidocReferenceProposalData> calculate(File editorFile, String fullSource, int indexForCtrlSpace);  }