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


Java JavaContentAssistInvocationContext.getCompilationUnit方法代码示例

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


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

示例1: 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

示例2: ImportCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public ImportCompletionProposal(
    CompletionProposal proposal,
    JavaContentAssistInvocationContext context,
    int parentProposalKind) {
  super(context);
  fProposal = proposal;
  fParentProposalKind = parentProposalKind;
  fCompilationUnit = context.getCompilationUnit();
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:ImportCompletionProposal.java

示例3: FillArgumentNamesCompletionProposalCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public FillArgumentNamesCompletionProposalCollector(JavaContentAssistInvocationContext context) {
  super(context.getCompilationUnit(), true);
  setInvocationContext(context);
  //		IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
  fIsGuessArguments =
      true; // preferenceStore.getBoolean(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS);
  //		if (preferenceStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)) {
  setRequireExtendedContext(true);
  //		}
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:FillArgumentNamesCompletionProposalCollector.java

示例4: createCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
/**
 * Creates the collector used to get proposals from core.
 *
 * @param context the context
 * @return the collector
 */
protected CompletionProposalCollector createCollector(JavaContentAssistInvocationContext context) {
	if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES))
		return new FillArgumentNamesCompletionProposalCollector(context);
	else
		return new CompletionProposalCollector(context.getCompilationUnit(), true);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:JavaCompletionProposalComputer.java

示例5: FillArgumentNamesCompletionProposalCollector

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public FillArgumentNamesCompletionProposalCollector(JavaContentAssistInvocationContext context) {
	super(context.getCompilationUnit(), true);
	setInvocationContext(context);
	IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
	fIsGuessArguments= preferenceStore.getBoolean(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS);
	if (preferenceStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)) {
		setRequireExtendedContext(true);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:FillArgumentNamesCompletionProposalCollector.java

示例6: 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

示例7: computeCompletionEngine

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

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

	if (isJFaceOnClasspath(javaProject)) {
		final CompletionContext coreContext = context.getCoreContext();
		if (coreContext != null) {
			final int tokenLocation = coreContext.getTokenLocation();
			if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
				return jFaceMembersTemplateEngine;
			}
			if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
				return jFaceStatementsTemplateEngine;
			}
		}
		return jFaceTemplateEngine;
	}

	return null;
}
 
开发者ID:vogellacompany,项目名称:saneclipse,代码行数:29,代码来源:JFaceCompletionProposalComputer.java

示例8: computeCompletionProposals

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(
    ContentAssistInvocationContext context, IProgressMonitor monitor) {
  if (!(context instanceof JavaContentAssistInvocationContext)) return Collections.emptyList();

  JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
  ICompilationUnit unit = javaContext.getCompilationUnit();
  if (unit == null) return Collections.emptyList();

  fEngine = computeCompletionEngine(javaContext);
  if (fEngine == null) return Collections.emptyList();

  fEngine.reset();
  fEngine.complete(javaContext.getViewer(), javaContext.getInvocationOffset(), unit);

  TemplateProposal[] templateProposals = fEngine.getResults();
  List<ICompletionProposal> result =
      new ArrayList<ICompletionProposal>(Arrays.asList(templateProposals));

  IJavaCompletionProposal[] keyWordResults = javaContext.getKeywordProposals();
  if (keyWordResults.length == 0) return result;

  /* Update relevance of template proposals that match with a keyword
   * give those templates slightly more relevance than the keyword to
   * sort them first.
   */
  for (int k = 0; k < templateProposals.length; k++) {
    TemplateProposal curr = templateProposals[k];
    String name = curr.getTemplate().getPattern();
    for (int i = 0; i < keyWordResults.length; i++) {
      String keyword = keyWordResults[i].getDisplayString();
      if (name.startsWith(keyword)) {
        String content = curr.getTemplate().getPattern();
        if (content.startsWith(keyword)) {
          curr.setRelevance(keyWordResults[i].getRelevance() + 1);
          break;
        }
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:42,代码来源:AbstractTemplateCompletionProposalComputer.java

示例9: LazyPackageCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public LazyPackageCompletionProposal(
    CompletionProposal proposal, JavaContentAssistInvocationContext context) {
  super(proposal, context);
  fCompilationUnit = context.getCompilationUnit();
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:LazyPackageCompletionProposal.java

示例10: LazyJavaTypeCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public LazyJavaTypeCompletionProposal(
    CompletionProposal proposal, JavaContentAssistInvocationContext context) {
  super(proposal, context);
  fCompilationUnit = context.getCompilationUnit();
  fQualifiedName = null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:LazyJavaTypeCompletionProposal.java

示例11: computeCompletionProposals

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
	if (!(context instanceof JavaContentAssistInvocationContext))
		return Collections.emptyList();

	JavaContentAssistInvocationContext javaContext= (JavaContentAssistInvocationContext) context;
	ICompilationUnit unit= javaContext.getCompilationUnit();
	if (unit == null)
		return Collections.emptyList();

	fEngine= computeCompletionEngine(javaContext);
	if (fEngine == null)
		return Collections.emptyList();

	fEngine.reset();
	fEngine.complete(javaContext.getViewer(), javaContext.getInvocationOffset(), unit);

	TemplateProposal[] templateProposals= fEngine.getResults();
	List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(Arrays.asList(templateProposals));

	IJavaCompletionProposal[] keyWordResults= javaContext.getKeywordProposals();
	if (keyWordResults.length == 0)
		return result;

	/* Update relevance of template proposals that match with a keyword
	 * give those templates slightly more relevance than the keyword to
	 * sort them first.
	 */
	for (int k= 0; k < templateProposals.length; k++) {
		TemplateProposal curr= templateProposals[k];
		String name= curr.getTemplate().getPattern();
		for (int i= 0; i < keyWordResults.length; i++) {
			String keyword= keyWordResults[i].getDisplayString();
			if (name.startsWith(keyword)) {
				String content= curr.getTemplate().getPattern();
				if (content.startsWith(keyword)) {
					curr.setRelevance(keyWordResults[i].getRelevance() + 1);
					break;
				}
			}
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:AbstractTemplateCompletionProposalComputer.java

示例12: LazyPackageCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public LazyPackageCompletionProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context) {
	super(proposal, context);
	fCompilationUnit= context.getCompilationUnit();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:LazyPackageCompletionProposal.java

示例13: LazyJavaTypeCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public LazyJavaTypeCompletionProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context) {
	super(proposal, context);
	fCompilationUnit= context.getCompilationUnit();
	fQualifiedName= null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:LazyJavaTypeCompletionProposal.java

示例14: ImportCompletionProposal

import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; //导入方法依赖的package包/类
public ImportCompletionProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context, int parentProposalKind) {
	super(context);
	fProposal= proposal;
	fParentProposalKind= parentProposalKind;
	fCompilationUnit= context.getCompilationUnit();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:ImportCompletionProposal.java

示例15: 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;

	CompletionContext coreContext = context.getCoreContext();
	if (coreContext != null) {
		int tokenLocation= coreContext.getTokenLocation();
		int tokenStart= coreContext.getTokenStart();
		int tokenKind= coreContext.getTokenKind();
		
		/*
		// XXX print out tokenlocation stuff (debugging)
		System.out.println("All Tokens: " + CompletionContext.TL_CONSTRUCTOR_START + " " + CompletionContext.TL_MEMBER_START + " " + CompletionContext.TL_STATEMENT_START);
		System.out.println("Token Start: " + coreContext.getTokenStart());
		System.out.println("Token End: " + coreContext.getTokenEnd());
		System.out.println("Token Kind: " + coreContext.getTokenKind());
		System.out.println("Token Location: " + coreContext.getTokenLocation());
		System.out.println("Enclosing Element: " + coreContext.getEnclosingElement());
		System.out.println("Offset: " + coreContext.getOffset());
		System.out.println("Token Array: " + Arrays.toString(coreContext.getToken()));
		System.out.println("Kind Tokens: " + CompletionContext.TOKEN_KIND_NAME + ", " + CompletionContext.TOKEN_KIND_STRING_LITERAL + ", " + CompletionContext.TOKEN_KIND_UNKNOWN);
		*/
		if (context.getViewer().getSelectedRange().y > 0) { // If there is an active selection we do not want to contribute to the CA
			return null;
		}
		
		if ((tokenLocation == 0 && tokenStart > -1)
				|| ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0 && tokenKind == CompletionContext.TOKEN_KIND_NAME && tokenStart > -1)
				|| (tokenLocation == 0 && isAfterDot(context.getDocument(), context.getInvocationOffset()))) {
			
			analyzeCoreContext(context, coreContext);

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


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