本文整理汇总了Java中org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext.getInvocationOffset方法的典型用法代码示例。如果您正苦于以下问题:Java JavaContentAssistInvocationContext.getInvocationOffset方法的具体用法?Java JavaContentAssistInvocationContext.getInvocationOffset怎么用?Java JavaContentAssistInvocationContext.getInvocationOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext
的用法示例。
在下文中一共展示了JavaContentAssistInvocationContext.getInvocationOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addChangeSrcToExistingResourceProposals
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
private void addChangeSrcToExistingResourceProposals(JavaContentAssistInvocationContext javaContext, ArrayList<ICompletionProposal> proposals, HtmlTagAttr srcAttr) throws CoreException {
String src = srcAttr.value.getValue();
// add proposals for resource links
{
int prefixStart = src.lastIndexOf('/') + 1;
int prefixEnd = javaContext.getInvocationOffset() - srcAttr.value.start;
if (prefixEnd >= 0 && prefixStart < prefixEnd && prefixEnd <= src.length()) {
String prefix = src.substring(prefixStart, prefixEnd);
for (String path : collectResourcePaths(javaContext, prefix)) {
// skip if no change would result
if (src.equals(path)) {
continue;
}
proposals.add(new ReplacementProposal("Change link to " + path, path, srcAttr.value.start, srcAttr.value.length()));
}
}
}
}
示例2: computeContextInformation
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
if (context instanceof JavaContentAssistInvocationContext) {
JavaContentAssistInvocationContext javaContext= (JavaContentAssistInvocationContext) context;
ICompilationUnit cu= javaContext.getCompilationUnit();
int offset= javaContext.getInvocationOffset();
ArrayList<IContextInformation> result= new ArrayList<IContextInformation>();
IJavadocCompletionProcessor[] processors= getContributedProcessors();
String error= null;
for (int i= 0; i < processors.length; i++) {
IJavadocCompletionProcessor curr= processors[i];
IContextInformation[] contextInfos= curr.computeContextInformation(cu, offset);
if (contextInfos != null) {
for (int k= 0; k < contextInfos.length; k++) {
result.add(contextInfos[k]);
}
} else if (error == null) {
error= curr.getErrorMessage();
}
}
fErrorMessage= error;
return result;
}
return Collections.emptyList();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:LegacyJavadocCompletionProposalComputer.java
示例3: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
private void computeCompletionProposals(JavaContentAssistInvocationContext javaContext, IDocument document, ArrayList<ICompletionProposal> proposals) throws CoreException {
String content = document.get();
int offset = javaContext.getInvocationOffset();
// try to get the javadoc of the element at the offset
IJavaElement elementAt = javaContext.getCompilationUnit().getElementAt(offset);
if (elementAt instanceof IMember) {
ISourceRange range = ((IMember) elementAt).getJavadocRange();
if (range != null) {
// parse javadoc
JavaDocCommentNode comment = new JavaDocParser(content, range.getOffset(), range.getOffset() + range.getLength()).comment();
boolean inStartTag = false;
// search the html tags
for (JavaDocNodeBase child : comment.children) {
if (child instanceof HtmlTagStartNode) {
HtmlTagStartNode tag = (HtmlTagStartNode) child;
if (tag.start <= offset && offset < tag.end) {
// no prefix proposals within start tags
inStartTag = true;
if ("img".equals(tag.tagName.getValue())) {
HtmlTagAttr srcAttr = tag.getAttr("src");
if (srcAttr != null) {
addTransformBetweenAbsoluteAndRelativeLinkProposals(javaContext, proposals, srcAttr);
if (srcAttr.value.start <= offset && offset <= srcAttr.value.end) {
addChangeSrcToExistingResourceProposals(javaContext, proposals, srcAttr);
}
}
}
break;
}
}
}
if (!inStartTag) {
int lastSpaceIndex = content.lastIndexOf(' ', offset - 1) + 1;
// skip the leading /**
int javadocContentStartOffset = range.getOffset() + 3;
lastSpaceIndex = Math.max(lastSpaceIndex, javadocContentStartOffset);
if (lastSpaceIndex < offset) {
String prefix = content.substring(lastSpaceIndex, offset);
addLinkToExistingResourceProposals(javaContext, proposals, prefix, lastSpaceIndex, offset - lastSpaceIndex);
addCreateNewImageProposal(javaContext, proposals, prefix, lastSpaceIndex, offset - lastSpaceIndex);
}
}
}
}
}
示例4: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(
ContentAssistInvocationContext context, IProgressMonitor monitor)
{
if (context instanceof JavaContentAssistInvocationContext)
{
JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext)context;
ICompilationUnit unit = javaContext.getCompilationUnit();
try
{
if (unit == null || !unit.isStructureKnown())
return Collections.emptyList();
IType primaryType = unit.findPrimaryType();
if (primaryType == null || !primaryType.isInterface())
return Collections.emptyList();
int offset = javaContext.getInvocationOffset();
IJavaElement element = unit.getElementAt(offset);
if (element == null || !(element instanceof IMethod))
return Collections.emptyList();
IAnnotation annotation = JavaMapperUtil.getAnnotationAt((IAnnotatable)element, offset);
if (annotation == null)
return Collections.emptyList();
final IJavaProject project = javaContext.getProject();
final IMethod method = (IMethod)element;
final String mapperFqn = method.getDeclaringType().getFullyQualifiedName();
if (isInlineStatementAnnotation(annotation))
{
return proposeStatementText(project, unit, offset, annotation, method);
}
else
{
String elementName = annotation.getElementName();
if ("ResultMap".equals(elementName))
{
return proposeResultMap(project, mapperFqn, offset, annotation);
}
else if ("Results".equals(elementName))
{
return proposeResults(project, mapperFqn, offset, annotation, method);
}
else if ("ConstructorArgs".equals(elementName))
{
return proposeConstructorArgs(project, mapperFqn, offset, annotation, method);
}
else if ("Options".equals(elementName) || "SelectKey".equals(elementName))
{
return proposeKeyProperty(project, mapperFqn, offset, annotation, method);
}
}
}
catch (JavaModelException e)
{
Activator.log(Status.ERROR, "Something went wrong.", e);
}
}
return Collections.emptyList();
}