mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[JavaDoc] ContentAssist for typeProposals after @link & @see
This commit is contained in:
parent
d2583d4a6b
commit
f2c37bfc41
3 changed files with 32 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<ReplaceRegion> computeTypeRefRegions(INode commentNode);
|
||||
|
||||
public List<ReplaceRegion> computeParameterTypeRefRegions(INode commentNode);
|
||||
|
|
|
@ -28,8 +28,8 @@ public class MultiLineJavaDocTypeReferenceProvider implements IJavaDocTypeRefere
|
|||
public List<ReplaceRegion> computeTypeRefRegions(INode node) {
|
||||
List<ReplaceRegion> regions = Lists.newArrayList();
|
||||
Iterable<ILeafNode> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue