diff --git a/plugins/org.eclipse.xtext.junit4/src/org/eclipse/xtext/junit4/ui/ContentAssistProcessorTestBuilder.java b/plugins/org.eclipse.xtext.junit4/src/org/eclipse/xtext/junit4/ui/ContentAssistProcessorTestBuilder.java index f8f8d1d6e..d2650dfbe 100755 --- a/plugins/org.eclipse.xtext.junit4/src/org/eclipse/xtext/junit4/ui/ContentAssistProcessorTestBuilder.java +++ b/plugins/org.eclipse.xtext.junit4/src/org/eclipse/xtext/junit4/ui/ContentAssistProcessorTestBuilder.java @@ -122,6 +122,19 @@ public class ContentAssistProcessorTestBuilder implements Cloneable { return ret; } + public ContentAssistProcessorTestBuilder applyProposal(int position) throws Exception { + ICompletionProposal proposal = computeCompletionProposals(getModel(), position)[0]; + final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(model)); + IXtextDocument document = getDocument(xtextResource, model); + proposal.apply(document); + ContentAssistProcessorTestBuilder reset = reset(); + return reset.append(document.get()); + } + + public void expectContent(String exprectation){ + Assert.assertEquals(exprectation, getModel()); + } + public ContentAssistProcessorTestBuilder assertCount(int completionProposalCount) throws Exception { return assertCountAtCursorPosition(completionProposalCount, this.cursorPosition); } diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/IJavaDocTypeReferenceProvider.java b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/IJavaDocTypeReferenceProvider.java index e65988cdd..b6d5a5ba1 100644 --- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/IJavaDocTypeReferenceProvider.java +++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/IJavaDocTypeReferenceProvider.java @@ -22,7 +22,15 @@ import com.google.inject.ImplementedBy; */ @ImplementedBy(MultiLineJavaDocTypeReferenceProvider.class) public interface IJavaDocTypeReferenceProvider { - + + public static final String SEE_TAG = "@see"; + + public static final String SEE_TAG_WITH_SUFFIX = SEE_TAG + " "; + + public static final String LINK_TAG = "@link"; + + public static final String LINK_TAG_WITH_SUFFIX = LINK_TAG + " "; + public List computeTypeRefRegions(INode commentNode); public List computeParameterTypeRefRegions(INode commentNode); diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/impl/MultiLineJavaDocTypeReferenceProvider.java b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/impl/MultiLineJavaDocTypeReferenceProvider.java index d024f1506..3c2c4c686 100644 --- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/impl/MultiLineJavaDocTypeReferenceProvider.java +++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/documentation/impl/MultiLineJavaDocTypeReferenceProvider.java @@ -28,8 +28,8 @@ public class MultiLineJavaDocTypeReferenceProvider implements IJavaDocTypeRefere public List computeTypeRefRegions(INode node) { List regions = Lists.newArrayList(); Iterable leafNodes = node.getLeafNodes(); - computeRegions(regions, leafNodes, "@link ", "#", " ", "}"); - computeRegions(regions, leafNodes, "@see ", "#" , " ", lineDelimiter); + computeRegions(regions, leafNodes, LINK_TAG_WITH_SUFFIX, "#", " ", "}"); + computeRegions(regions, leafNodes, SEE_TAG_WITH_SUFFIX, "#" , " ", lineDelimiter); return regions; } @@ -55,8 +55,15 @@ public class MultiLineJavaDocTypeReferenceProvider implements IJavaDocTypeRefere String text = leafNode.getText(); int offset = leafNode.getOffset(); int position = text.indexOf(toSearch); + int textLength = text.length(); while (position != -1) { int beginIndex = position + toSearch.length(); + // Skip leading whitespaces + if(Character.isWhitespace(text.charAt(beginIndex))){ + while(beginIndex < textLength && Character.isWhitespace(text.charAt(beginIndex))){ + beginIndex ++; + } + } int endLink = -1; if(end != null && endLink == -1) endLink = text.indexOf(end, beginIndex); @@ -77,7 +84,7 @@ public class MultiLineJavaDocTypeReferenceProvider implements IJavaDocTypeRefere break; } else { String simpleName = text.substring(beginIndex, endLink).replaceAll(" ", ""); - if(simpleName.length() > 0 && simpleName.matches("[0-9a-zA-Z\\.]*")){ + if(simpleName.length() > 0 && simpleName.matches("[0-9a-zA-Z\\.\\$_]*")){ ReplaceRegion region = new ReplaceRegion(offset + beginIndex, simpleName.length(), simpleName); regions.add(region); }