当前位置: 首页>>代码示例>>Java>>正文


Java JavaContentAssistInvocationContext类代码示例

本文整理汇总了Java中org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext的典型用法代码示例。如果您正苦于以下问题:Java JavaContentAssistInvocationContext类的具体用法?Java JavaContentAssistInvocationContext怎么用?Java JavaContentAssistInvocationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaContentAssistInvocationContext类属于org.eclipse.jdt.ui.text.java包,在下文中一共展示了JavaContentAssistInvocationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createContext

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
   protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset) 
{
         	ICompilationUnit compilationUnit = ((SourceViewer) viewer).getCompilatioUnit();
           if (compilationUnit != null) {
          
               CompletionProposalCollector completionProposalCollector = new CompletionProposalCollector(compilationUnit);
               JavaContentAssistInvocationContext invocContext = new JavaContentAssistInvocationContext(viewer, offset,
               		new NullEditorPart());
               
               completionProposalCollector.setInvocationContext(invocContext);
               return invocContext;
           } else {
               return null;
           }
       
   }
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:18,代码来源:HydrographJavaCompletionProcessor.java

示例2: computeProposals

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
private static List<ICompletionProposal> computeProposals(
    ICompilationUnit compilationUnit, int offset) throws JavaModelException {
  IBuffer buffer = compilationUnit.getBuffer();
  IDocument document;
  if (buffer instanceof org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter) {
    document = ((org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter) buffer).getDocument();
  } else {
    document = new DocumentAdapter(buffer);
  }
  TextViewer viewer = new TextViewer(document, new Point(offset, 0));
  JavaContentAssistInvocationContext context =
      new JavaContentAssistInvocationContext(viewer, offset, compilationUnit);

  List<ICompletionProposal> proposals = new ArrayList<>();
  proposals.addAll(
      new JavaAllCompletionProposalComputer().computeCompletionProposals(context, null));
  //        proposals.addAll(new
  // TemplateCompletionProposalComputer().computeCompletionProposals(context, null));

  Collections.sort(proposals, new RelevanceSorter());
  return proposals;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:CompletionJavadocTest.java

示例3: JavaCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
/**
 * Creates a new completion proposal. All fields are initialized based on the provided
 * information.
 *
 * @param replacementString the actual string to be inserted into the document
 * @param replacementOffset the offset of the text to be replaced
 * @param replacementLength the length of the text to be replaced
 * @param image the image to display for this proposal
 * @param displayString the string to be displayed for the proposal If set to <code>null</code>,
 *     the replacement string will be taken as display string.
 * @param relevance the relevance
 * @param inJavadoc <code>true</code> for a javadoc proposal
 * @param invocationContext the invocation context of this completion proposal or <code>null
 *     </code> not available
 */
public JavaCompletionProposal(
    String replacementString,
    int replacementOffset,
    int replacementLength,
    Image image,
    StyledString displayString,
    int relevance,
    boolean inJavadoc,
    JavaContentAssistInvocationContext invocationContext) {
  super(invocationContext);
  Assert.isNotNull(replacementString);
  Assert.isTrue(replacementOffset >= 0);
  Assert.isTrue(replacementLength >= 0);

  setReplacementString(replacementString);
  setReplacementOffset(replacementOffset);
  setReplacementLength(replacementLength);
  setImage(image);
  setStyledDisplayString(
      displayString == null ? new StyledString(replacementString) : displayString);
  setRelevance(relevance);
  setCursorPosition(replacementString.length());
  setInJavadoc(inJavadoc);
  setSortString(displayString == null ? replacementString : displayString.getString());
}
 
开发者ID:eclipse,项目名称:che,代码行数:41,代码来源:JavaCompletionProposal.java

示例4: createCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected CompletionProposalCollector createCollector(
    JavaContentAssistInvocationContext context) {
  CompletionProposalCollector collector = super.createCollector(context);
  collector.setIgnored(CompletionProposal.ANNOTATION_ATTRIBUTE_REF, false);
  collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, false);
  collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, false);
  collector.setIgnored(CompletionProposal.FIELD_REF, false);
  collector.setIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, false);
  collector.setIgnored(CompletionProposal.KEYWORD, false);
  collector.setIgnored(CompletionProposal.LABEL_REF, false);
  collector.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, false);
  collector.setIgnored(CompletionProposal.METHOD_DECLARATION, false);
  collector.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, false);
  collector.setIgnored(CompletionProposal.METHOD_REF, false);
  collector.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, false);
  collector.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, false);
  collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
  collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
  collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
  return collector;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JavaNoTypeCompletionProposalComputer.java

示例5: createCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected CompletionProposalCollector createCollector(
    JavaContentAssistInvocationContext context) {
  CompletionProposalCollector collector = super.createCollector(context);
  collector.setIgnored(CompletionProposal.ANNOTATION_ATTRIBUTE_REF, false);
  collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, false);
  collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, false);
  collector.setIgnored(CompletionProposal.FIELD_REF, false);
  collector.setIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, false);
  collector.setIgnored(CompletionProposal.KEYWORD, false);
  collector.setIgnored(CompletionProposal.LABEL_REF, false);
  collector.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, false);
  collector.setIgnored(CompletionProposal.METHOD_DECLARATION, false);
  collector.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, false);
  collector.setIgnored(CompletionProposal.METHOD_REF, false);
  collector.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, false);
  collector.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, false);
  collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
  collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
  collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
  collector.setIgnored(CompletionProposal.TYPE_REF, false);
  return collector;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:JavaAllCompletionProposalComputer.java

示例6: addContextInformations

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
private List<IContextInformation> addContextInformations(
    JavaContentAssistInvocationContext context, int offset) {
  List<ICompletionProposal> proposals = internalComputeCompletionProposals(offset, context);
  List<IContextInformation> result = new ArrayList<IContextInformation>(proposals.size());
  List<IContextInformation> anonymousResult =
      new ArrayList<IContextInformation>(proposals.size());

  for (Iterator<ICompletionProposal> it = proposals.iterator(); it.hasNext(); ) {
    ICompletionProposal proposal = it.next();
    IContextInformation contextInformation = proposal.getContextInformation();
    if (contextInformation != null) {
      ContextInformationWrapper wrapper = new ContextInformationWrapper(contextInformation);
      wrapper.setContextInformationPosition(offset);
      if (proposal instanceof AnonymousTypeCompletionProposal) anonymousResult.add(wrapper);
      else result.add(wrapper);
    }
  }

  if (result.size() == 0) return anonymousResult;
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JavaCompletionProposalComputer.java

示例7: createTypeProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
private IJavaCompletionProposal createTypeProposal(
    int relevance, String fullyQualifiedType, JavaContentAssistInvocationContext context)
    throws JavaModelException {
  IType type = context.getCompilationUnit().getJavaProject().findType(fullyQualifiedType);
  if (type == null) return null;

  CompletionProposal proposal =
      CompletionProposal.create(CompletionProposal.TYPE_REF, context.getInvocationOffset());
  proposal.setCompletion(fullyQualifiedType.toCharArray());
  proposal.setDeclarationSignature(type.getPackageFragment().getElementName().toCharArray());
  proposal.setFlags(type.getFlags());
  proposal.setRelevance(relevance);
  proposal.setReplaceRange(context.getInvocationOffset(), context.getInvocationOffset());
  proposal.setSignature(Signature.createTypeSignature(fullyQualifiedType, true).toCharArray());

  if (shouldProposeGenerics(context.getProject()))
    return new LazyGenericTypeProposal(proposal, context);
  else return new LazyJavaTypeCompletionProposal(proposal, context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:JavaTypeCompletionProposalComputer.java

示例8: JavaTypeCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
public JavaTypeCompletionProposal(
    String replacementString,
    ICompilationUnit cu,
    int replacementOffset,
    int replacementLength,
    Image image,
    StyledString displayString,
    int relevance,
    String fullyQualifiedTypeName,
    JavaContentAssistInvocationContext invocationContext) {
  super(
      replacementString,
      replacementOffset,
      replacementLength,
      image,
      displayString,
      relevance,
      false,
      invocationContext);
  fCompilationUnit = cu;
  fFullyQualifiedTypeName = fullyQualifiedTypeName;
  fUnqualifiedTypeName =
      fullyQualifiedTypeName != null ? Signature.getSimpleName(fullyQualifiedTypeName) : null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:JavaTypeCompletionProposal.java

示例9: createCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected CompletionProposalCollector createCollector(
    JavaContentAssistInvocationContext context) {
  CompletionProposalCollector collector = super.createCollector(context);
  collector.setIgnored(CompletionProposal.JAVADOC_TYPE_REF, false);
  collector.setIgnored(CompletionProposal.JAVADOC_FIELD_REF, false);
  collector.setIgnored(CompletionProposal.JAVADOC_METHOD_REF, false);
  collector.setIgnored(CompletionProposal.JAVADOC_PARAM_REF, false);
  collector.setIgnored(CompletionProposal.JAVADOC_VALUE_REF, false);
  collector.setIgnored(CompletionProposal.JAVADOC_BLOCK_TAG, false);
  collector.setIgnored(CompletionProposal.JAVADOC_INLINE_TAG, false);
  collector.setIgnored(CompletionProposal.TYPE_REF, false);
  collector.setIgnored(CompletionProposal.FIELD_REF, false);
  collector.setIgnored(CompletionProposal.METHOD_REF, false);
  return collector;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:JavadocCompletionProposalComputer.java

示例10: computeCompletionProposals

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
	ArrayList<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
	System.out.println(context);
	if (context instanceof JavaContentAssistInvocationContext) {
		JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
		try {
			if (UmletPluginUtils.hasUmletNature(javaContext.getProject())) {
				IDocument document = context.getDocument();
				if (document != null) {
					computeCompletionProposals(javaContext, document, proposals);
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	return proposals;
}
 
开发者ID:umlet,项目名称:umlet,代码行数:20,代码来源:ImgRefProposalComputer.java

示例11: 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()));
			}
		}
	}
}
 
开发者ID:umlet,项目名称:umlet,代码行数:19,代码来源:ImgRefProposalComputer.java

示例12: JavaCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
/**
 * Creates a new completion proposal. All fields are initialized based on the provided
 * information.
 *
 * @param replacementString the actual string to be inserted into the document
 * @param replacementOffset the offset of the text to be replaced
 * @param replacementLength the length of the text to be replaced
 * @param image the image to display for this proposal
 * @param displayString the string to be displayed for the proposal If set to <code>null</code>,
 *        the replacement string will be taken as display string.
 * @param relevance the relevance
 * @param inJavadoc <code>true</code> for a javadoc proposal
 * @param invocationContext the invocation context of this completion proposal or <code>null</code> not available
 */
public JavaCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, StyledString displayString, int relevance, boolean inJavadoc, JavaContentAssistInvocationContext invocationContext) {
	super(invocationContext);
	Assert.isNotNull(replacementString);
	Assert.isTrue(replacementOffset >= 0);
	Assert.isTrue(replacementLength >= 0);

	setReplacementString(replacementString);
	setReplacementOffset(replacementOffset);
	setReplacementLength(replacementLength);
	setImage(image);
	setStyledDisplayString(displayString == null ? new StyledString(replacementString) : displayString);
	setRelevance(relevance);
	setCursorPosition(replacementString.length());
	setInJavadoc(inJavadoc);
	setSortString(displayString == null ? replacementString : displayString.getString());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:JavaCompletionProposal.java

示例13: computeCompletionEngine

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
	ICompilationUnit unit= context.getCompilationUnit();
	if (unit == null)
		return null;

	IJavaProject javaProject= unit.getJavaProject();
	if (javaProject == null)
		return null;

	if (isSWTOnClasspath(javaProject)) {
		CompletionContext coreContext= context.getCoreContext();
		if (coreContext != null) {
			int tokenLocation= coreContext.getTokenLocation();
			if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
				return fSWTMembersTemplateEngine;
			}
			if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
				return fSWTStatementsTemplateEngine;
			}
		}
		return fSWTTemplateEngine;
	}

	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:SWTTemplateCompletionProposalComputer.java

示例14: createCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected CompletionProposalCollector createCollector(JavaContentAssistInvocationContext context) {
	CompletionProposalCollector collector= super.createCollector(context);
	collector.setIgnored(CompletionProposal.ANNOTATION_ATTRIBUTE_REF, false);
	collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, false);
	collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, false);
	collector.setIgnored(CompletionProposal.FIELD_REF, false);
	collector.setIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, false);
	collector.setIgnored(CompletionProposal.KEYWORD, false);
	collector.setIgnored(CompletionProposal.LABEL_REF, false);
	collector.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, false);
	collector.setIgnored(CompletionProposal.METHOD_DECLARATION, false);
	collector.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, false);
	collector.setIgnored(CompletionProposal.METHOD_REF, false);
	collector.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, false);
	collector.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, false);
	collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
	collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
	collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
	return collector;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:JavaNoTypeCompletionProposalComputer.java

示例15: createCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected CompletionProposalCollector createCollector(JavaContentAssistInvocationContext context) {
	CompletionProposalCollector collector= super.createCollector(context);
	collector.setIgnored(CompletionProposal.ANNOTATION_ATTRIBUTE_REF, false);
	collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, false);
	collector.setIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, false);
	collector.setIgnored(CompletionProposal.FIELD_REF, false);
	collector.setIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, false);
	collector.setIgnored(CompletionProposal.KEYWORD, false);
	collector.setIgnored(CompletionProposal.LABEL_REF, false);
	collector.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, false);
	collector.setIgnored(CompletionProposal.METHOD_DECLARATION, false);
	collector.setIgnored(CompletionProposal.METHOD_NAME_REFERENCE, false);
	collector.setIgnored(CompletionProposal.METHOD_REF, false);
	collector.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, false);
	collector.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, false);
	collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
	collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
	collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
	collector.setIgnored(CompletionProposal.TYPE_REF, false);
	return collector;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaAllCompletionProposalComputer.java


注:本文中的org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。