From f66a5f3c2bb908be1e625c6f3c0ebb3a4bb107c9 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Wed, 22 Jan 2025 10:13:29 +0100 Subject: [PATCH] removed code that is not used anymore --- .../beans/DependsOnCompletionProcessor.java | 206 ------------------ 1 file changed, 206 deletions(-) diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/DependsOnCompletionProcessor.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/DependsOnCompletionProcessor.java index aeed3a8276..977cc3e92b 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/DependsOnCompletionProcessor.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/DependsOnCompletionProcessor.java @@ -37,212 +37,6 @@ public DependsOnCompletionProcessor(SpringMetamodelIndex springIndex) { this.springIndex = springIndex; } -// @Override -// public void provideCompletions(ASTNode node, Annotation annotation, ITypeBinding type, int offset, TextDocument doc, Collection completions) { -// -// Optional optionalProject = projectFinder.find(doc.getId()); -// if (!optionalProject.isPresent()) { -// return; -// } -// -// IJavaProject project = optionalProject.get(); -// -// try { -// -// // case: @DependsOn(<*>) -// if (node == annotation && doc.get(offset - 1, 2).endsWith("()")) { -// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName()); -// -// for (Bean bean : beans) { -// -// DocumentEdits edits = new DocumentEdits(doc, false); -// edits.replace(offset, offset, "\"" + bean.getName() + "\""); -// -// DependsOnCompletionProposal proposal = new DependsOnCompletionProposal(edits, bean.getName(), bean.getName(), null); -// -// completions.add(proposal); -// } -// } -// // case: @DependsOn(prefix<*>) -// else if (node instanceof SimpleName && node.getParent() instanceof Annotation) { -// computeProposalsForSimpleName(project, node, completions, offset, doc); -// } -// // case: @DependsOn(value=<*>) -// else if (node instanceof SimpleName && node.getParent() instanceof MemberValuePair -// && "value".equals(((MemberValuePair)node.getParent()).getName().toString())) { -// computeProposalsForSimpleName(project, node, completions, offset, doc); -// } -// // case: @DependsOn("prefix<*>") -// else if (node instanceof StringLiteral && node.getParent() instanceof Annotation) { -// if (node.toString().startsWith("\"") && node.toString().endsWith("\"")) { -// computeProposalsForStringLiteral(project, node, completions, offset, doc); -// } -// } -// else if (node instanceof StringLiteral && node.getParent() instanceof ArrayInitializer) { -// if (node.toString().startsWith("\"") && node.toString().endsWith("\"")) { -// computeProposalsForInsideArrayInitializer(project, node, completions, offset, doc); -// } -// } -// // case: @DependsOn(value="prefix<*>") -// else if (node instanceof StringLiteral && node.getParent() instanceof MemberValuePair -// && "value".equals(((MemberValuePair)node.getParent()).getName().toString())) { -// if (node.toString().startsWith("\"") && node.toString().endsWith("\"")) { -// computeProposalsForStringLiteral(project, node, completions, offset, doc); -// } -// } -// // case: @DependsOn({<*>}) -// else if (node instanceof ArrayInitializer && node.getParent() instanceof Annotation) { -// computeProposalsForArrayInitializr(project, (ArrayInitializer) node, completions, offset, doc); -// } -// } -// catch (Exception e) { -// e.printStackTrace(); -// } -// } -// -// private void computeProposalsForSimpleName(IJavaProject project, ASTNode node, Collection completions, int offset, IDocument doc) { -// String prefix = identifyPropertyPrefix(node.toString(), offset - node.getStartPosition()); -// -// int startOffset = node.getStartPosition(); -// int endOffset = node.getStartPosition() + node.getLength(); -// -// String proposalPrefix = "\""; -// String proposalPostfix = "\""; -// -// Set mentionedBeans = alreadyMentionedBeans(node); -// -// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName()); -// List matchingBeans = Arrays.stream(beans) -// .filter(bean -> bean.getName().toLowerCase().startsWith(prefix.toLowerCase())) -// .filter(bean -> !mentionedBeans.contains(bean.getName())) -// .collect(Collectors.toList()); -// -// for (Bean bean : matchingBeans) { -// -// DocumentEdits edits = new DocumentEdits(doc, false); -// edits.replace(startOffset, endOffset, proposalPrefix + bean.getName() + proposalPostfix); -// -// DependsOnCompletionProposal proposal = new DependsOnCompletionProposal(edits, bean.getName(), bean.getName(), null); -// -// completions.add(proposal); -// } -// } -// -// private void computeProposalsForStringLiteral(IJavaProject project, ASTNode node, Collection completions, int offset, IDocument doc) throws BadLocationException { -// int length = offset - (node.getStartPosition() + 1); -// -// String prefix = identifyPropertyPrefix(doc.get(node.getStartPosition() + 1, length), length); -// int startOffset = offset - prefix.length(); -// int endOffset = offset; -// -// Set mentionedBeans = alreadyMentionedBeans(node); -// -// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName()); -// -// final String filterPrefix = prefix; -// List matchingBeans = Arrays.stream(beans) -// .filter(bean -> bean.getName().toLowerCase().startsWith(filterPrefix.toLowerCase())) -// .filter(bean -> !mentionedBeans.contains(bean.getName())) -// .collect(Collectors.toList()); -// -// for (Bean bean : matchingBeans) { -// -// DocumentEdits edits = new DocumentEdits(doc, false); -// edits.replace(startOffset, endOffset, bean.getName()); -// -// DependsOnCompletionProposal proposal = new DependsOnCompletionProposal(edits, bean.getName(), bean.getName(), null); -// -// completions.add(proposal); -// } -// } -// -// private void computeProposalsForArrayInitializr(IJavaProject project, ArrayInitializer node, Collection completions, int offset, IDocument doc) { -// Set mentionedBeans = alreadyMentionedBeans(node); -// -// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName()); -// List filteredBeans = Arrays.stream(beans) -// .filter(bean -> !mentionedBeans.contains(bean.getName())) -// .collect(Collectors.toList()); -// -// for (Bean bean : filteredBeans) { -// -// DocumentEdits edits = new DocumentEdits(doc, false); -// edits.replace(offset, offset, "\"" + bean.getName() + "\""); -// -// DependsOnCompletionProposal proposal = new DependsOnCompletionProposal(edits, bean.getName(), bean.getName(), null); -// -// completions.add(proposal); -// } -// } -// -// private void computeProposalsForInsideArrayInitializer(IJavaProject project, ASTNode node, Collection completions, int offset, TextDocument doc) throws BadLocationException { -// int length = offset - (node.getStartPosition() + 1); -// if (length >= 0) { -// computeProposalsForStringLiteral(project, node, completions, offset, doc); -// } -// else { -// Set mentionedBeans = alreadyMentionedBeans(node); -// -// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName()); -// List filteredBeans = Arrays.stream(beans) -// .filter(bean -> !mentionedBeans.contains(bean.getName())) -// .collect(Collectors.toList()); -// -// for (Bean bean : filteredBeans) { -// -// DocumentEdits edits = new DocumentEdits(doc, false); -// edits.replace(offset, offset, "\"" + bean.getName() + "\","); -// -// DependsOnCompletionProposal proposal = new DependsOnCompletionProposal(edits, bean.getName(), bean.getName(), null); -// -// completions.add(proposal); -// } -// } -// } -// -// private String identifyPropertyPrefix(String nodeContent, int offset) { -// String result = nodeContent.substring(0, offset); -// -// int i = offset - 1; -// while (i >= 0) { -// char c = nodeContent.charAt(i); -// if (c == '}' || c == '{' || c == '$' || c == '#') { -// result = result.substring(i + 1, offset); -// break; -// } -// i--; -// } -// -// return result; -// } -// -// private Set alreadyMentionedBeans(ASTNode node) { -// Set result = new HashSet<>(); -// -// ArrayInitializer arrayNode = null; -// while (node != null && arrayNode == null && !(node instanceof Annotation)) { -// if (node instanceof ArrayInitializer) { -// arrayNode = (ArrayInitializer) node; -// } -// else { -// node = node.getParent(); -// } -// } -// -// if (arrayNode != null) { -// List expressions = arrayNode.expressions(); -// for (Object expression : expressions) { -// if (expression instanceof StringLiteral) { -// StringLiteral stringExr = (StringLiteral) expression; -// String value = stringExr.getLiteralValue(); -// result.add(value); -// } -// } -// } -// -// return result; -// } - @Override public List getCompletionCandidates(IJavaProject project, ASTNode node) { Collection beanNameFromCodeElement = getBeanNameFromSourceCodePosition(node);