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


Java TextInvocationContext类代码示例

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


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

示例1: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:DwprofileQuickAssistProcessor.java

示例2: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HyexpressionQuickAssistProcessor.java

示例3: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HyvalidityformulaQuickAssistProcessor.java

示例4: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HydatavalueQuickAssistProcessor.java

示例5: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HymappingQuickAssistProcessor.java

示例6: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HyconstraintsQuickAssistProcessor.java

示例7: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HymanifestQuickAssistProcessor.java

示例8: getCorrections

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
public IJavaCompletionProposal[] getCorrections(IInvocationContext invocationContext, IProblemLocation[] locations) throws CoreException {

		final int threshold= PreferenceConstants.getPreferenceStore().getInt(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);

		int size= 0;
		List<RankedWordProposal> proposals= null;
		String[] arguments= null;

		IProblemLocation location= null;
		RankedWordProposal proposal= null;
		IJavaCompletionProposal[] result= null;

		boolean fixed= false;
		boolean match= false;
		boolean sentence= false;

		final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
		final ISpellChecker checker= engine.getSpellChecker();

		if (checker != null) {

			for (int index= 0; index < locations.length; index++) {
				location= locations[index];
				
				ISourceViewer sourceViewer= null;
				if (invocationContext instanceof IQuickAssistInvocationContext)
					sourceViewer= ((IQuickAssistInvocationContext)invocationContext).getSourceViewer();
				IQuickAssistInvocationContext context= new TextInvocationContext(sourceViewer, location.getOffset(), location.getLength());
				
				if (location.getProblemId() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) {

					arguments= location.getProblemArguments();
					if (arguments != null && arguments.length > 4) {

						sentence= Boolean.valueOf(arguments[3]).booleanValue();
						match= Boolean.valueOf(arguments[4]).booleanValue();
						fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX || arguments[0].charAt(0) == IJavaDocTagConstants.JAVADOC_TAG_PREFIX;

						if ((sentence && match) && !fixed)
							result= new IJavaCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
						else {

							proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
							size= proposals.size();

							if (threshold > 0 && size > threshold) {

								Collections.sort(proposals);
								proposals= proposals.subList(size - threshold - 1, size - 1);
								size= proposals.size();
							}

							boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
							result= new IJavaCompletionProposal[size + (extendable ? 3 : 2)];

							for (index= 0; index < size; index++) {

								proposal= proposals.get(index);
								result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
							}

							if (extendable)
								result[index++]= new AddWordProposal(arguments[0], context);

							result[index++]= new WordIgnoreProposal(arguments[0], context);
							result[index++]= new DisableSpellCheckingProposal(context);
						}
						break;
					}
				}
			}
		}
		return result;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:75,代码来源:WordQuickFixProcessor.java

示例9: computeQuickAssistProposals

import org.eclipse.jface.text.source.TextInvocationContext; //导入依赖的package包/类
/** See: SpellingCorrectionProcessor (before was, XtextQuickAssistProcessor) */
	@Override
	public ICompletionProposal[] computeQuickAssistProposals(
			IQuickAssistInvocationContext invocationContext) {

		ISourceViewer viewer= invocationContext.getSourceViewer();
		int documentOffset= invocationContext.getOffset();

		int length= viewer != null ? viewer.getSelectedRange().y : -1;
		TextInvocationContext context= new TextInvocationContext(viewer, documentOffset, length);
		
		IAnnotationModel model = viewer.getAnnotationModel();
		if (model == null)
			return new ICompletionProposal[0]; 
		
		// From computeProposals
		int offset= context.getOffset();
		ArrayList<IMarker> annotationMarkers = new ArrayList<IMarker>();
		Iterator iter= model.getAnnotationIterator();
		while (iter.hasNext()) {
			Annotation annotation = (Annotation)iter.next();
			if (canFix(annotation)) {
				Position pos= model.getPosition(annotation);
				if (isAtPosition(offset, pos)) {
					collectMarkers(annotation, annotationMarkers);
				}
			}
		}

		List<ICompletionProposal> allProposals = new ArrayList<ICompletionProposal>();
		LinkedList<List<ICompletionProposal>> sortedProposals = new LinkedList<List<ICompletionProposal>>();
		
		for (IMarker iMarker : annotationMarkers) {
			ICompletionProposal[] qfixes = getQuickfixes(iMarker);
			
//			if ( qfixes.length > 0 && annotationMarkers.size() > 1 ) {
//				// There are quick fixes for several kinds of errors
//				allProposals.add(new ProposalCategory(iMarker));
//			}
			List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(qfixes.length);

			if ( qfixes.length > 0 ) {
				proposals.add(new ProposalCategory(iMarker));
			}
			
			for (ICompletionProposal iCompletionProposal : qfixes) {
				proposals.add(iCompletionProposal);
			}
			
			sortedProposals.add(proposals);
		}
		sortedProposals.sort((l1, l2) -> -1 * Integer.compare(l1.size(), l2.size()));

		allProposals = sortedProposals.stream().flatMap(l -> l.stream()).collect(Collectors.toList());
		
		if ( allProposals.isEmpty() ) {
			// If there are no errors, then try the quick assist
			return computeQuickAssist(invocationContext, invocationContext.getOffset());
		} else {		
			return (ICompletionProposal[]) allProposals.toArray(new ICompletionProposal[allProposals.size()]);
		}
	}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:63,代码来源:AnalysisQuickfixProcessor.java


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