@Test public void should_propose_keyword_only_once_from_resource_file_included_twice() throws Exception { IFile origFile = addFile("orig.txt", "*Settings\nResource " + LINKED_FILENAME + "\nResource " + LINKED_FILENAME + "\n"); IFile linkedFile = addFile(LINKED_FILENAME, "*Keywords\n" + LINKED_KEYWORD + "\n"); when(resourceManager.getRelativeFile(origFile, LINKED_FILENAME)).thenReturn(linkedFile); RobotCompletionProposalSet proposalSet = new KeywordCallAttemptVisitor(origFile).visitAttempt("", new Region(0, 0)); assertEquals("Got wrong amount of proposals: " + proposalSet.getProposals(), 2, proposalSet.getProposals().size()); verifyProposal(proposalSet, 0, LINKED_PREFIX + LINKED_KEYWORD, LINKED_KEYWORD); verifyProposal(proposalSet, 1, BUILTIN_PREFIX + BUILTIN_KEYWORD, BUILTIN_KEYWORD); assertFalse("Should be false always for keyword call attempts", proposalSet.isPriorityProposal()); }
@Override public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { assert attempt.equals(attempt.toLowerCase()); RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); CompletionMatchVisitor visitor = new KeywordCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion); DefinitionFinder.acceptMatches(file, visitor); return ourProposalSet; }
KeywordCallAttemptVisitor implements AttemptVisitor { @Override public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { assert attempt.equals(attempt.toLowerCase()); RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); CompletionMatchVisitor visitor = new KeywordCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion); DefinitionFinder.acceptMatches(file, visitor); return ourProposalSet; } }
KeywordCallAttemptVisitor implements AttemptVisitor { @Override public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { assert attempt.equals(attempt.toLowerCase()); RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); CompletionMatchVisitor visitor = new KeywordCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion); DefinitionFinder.acceptMatches(file, visitor); return ourProposalSet; } KeywordCallAttemptVisitor(IFile file); }
KeywordCallAttemptVisitor implements AttemptVisitor { @Override public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { assert attempt.equals(attempt.toLowerCase()); RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); CompletionMatchVisitor visitor = new KeywordCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion); DefinitionFinder.acceptMatches(file, visitor); return ourProposalSet; } KeywordCallAttemptVisitor(IFile file); @Override RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion); }
KeywordCallAttemptVisitor implements AttemptVisitor { @Override public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { assert attempt.equals(attempt.toLowerCase()); RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); CompletionMatchVisitor visitor = new KeywordCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion); DefinitionFinder.acceptMatches(file, visitor); return ourProposalSet; } KeywordCallAttemptVisitor(IFile file); @Override RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion);  }