Skip to content

Commit

Permalink
removed code that is not used anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlippert committed Jan 22, 2025
1 parent 2d86e09 commit f66a5f3
Showing 1 changed file with 0 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICompletionProposal> completions) {
//
// Optional<IJavaProject> 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<ICompletionProposal> 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<String> mentionedBeans = alreadyMentionedBeans(node);
//
// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName());
// List<Bean> 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<ICompletionProposal> 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<String> mentionedBeans = alreadyMentionedBeans(node);
//
// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName());
//
// final String filterPrefix = prefix;
// List<Bean> 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<ICompletionProposal> completions, int offset, IDocument doc) {
// Set<String> mentionedBeans = alreadyMentionedBeans(node);
//
// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName());
// List<Bean> 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<ICompletionProposal> completions, int offset, TextDocument doc) throws BadLocationException {
// int length = offset - (node.getStartPosition() + 1);
// if (length >= 0) {
// computeProposalsForStringLiteral(project, node, completions, offset, doc);
// }
// else {
// Set<String> mentionedBeans = alreadyMentionedBeans(node);
//
// Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName());
// List<Bean> 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<String> alreadyMentionedBeans(ASTNode node) {
// Set<String> 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<AnnotationAttributeProposal> getCompletionCandidates(IJavaProject project, ASTNode node) {
Collection<String> beanNameFromCodeElement = getBeanNameFromSourceCodePosition(node);
Expand Down

0 comments on commit f66a5f3

Please sign in to comment.