本文整理汇总了Java中org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext类的典型用法代码示例。如果您正苦于以下问题:Java IQuickAssistInvocationContext类的具体用法?Java IQuickAssistInvocationContext怎么用?Java IQuickAssistInvocationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IQuickAssistInvocationContext类属于org.eclipse.jface.text.quickassist包,在下文中一共展示了IQuickAssistInvocationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例2: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例3: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例4: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例5: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例6: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例7: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的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;
}
示例8: getProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) {
List<Word> sugg = fError.getSuggestions();
int length = fError.getInvalidWord().length();
ICompletionProposal[] props = new ICompletionProposal[sugg.size() + 2];
for (int i=0; i < sugg.size(); i++) {
String suggestion = sugg.get(i).toString();
String s = MessageFormat.format(CHANGE_TO,
new Object[] { suggestion });
props[i] = new CompletionProposal(suggestion,
fOffset, length, suggestion.length(), fCorrectionImage, s, null, null);
}
props[props.length - 2] = new IgnoreProposal(ignore, fError.getInvalidWord(), context.getSourceViewer());
props[props.length - 1] = new AddToDictProposal(fError, fLang, context.getSourceViewer());
return props;
}
示例9: addProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
private void addProposals(final SubMenuManager quickFixMenu) {
IAnnotationModel sourceModel = sourceViewer.getAnnotationModel();
Iterator annotationIterator = sourceModel.getAnnotationIterator();
while (annotationIterator.hasNext()) {
Annotation annotation = (Annotation) annotationIterator.next();
boolean isDeleted = annotation.isMarkedDeleted();
boolean isIncluded = includes(sourceModel.getPosition(annotation),
getTextWidget().getCaretOffset());
boolean isFixable = sourceViewer.getQuickAssistAssistant().canFix(
annotation);
if (!isDeleted && isIncluded && isFixable) {
IQuickAssistProcessor processor = sourceViewer
.getQuickAssistAssistant()
.getQuickAssistProcessor();
IQuickAssistInvocationContext context = sourceViewer
.getQuickAssistInvocationContext();
ICompletionProposal[] proposals = processor
.computeQuickAssistProposals(context);
for (ICompletionProposal proposal : proposals)
quickFixMenu.add(createQuickFixAction(proposal));
}
}
}
示例10: getHoverInfoInternal
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
@Override
protected Object getHoverInfoInternal(ITextViewer textViewer, final int lineNumber, final int offset) {
AnnotationInfo result = recentAnnotationInfo;
if (result != null)
return result;
List<Annotation> annotations = getAnnotations(lineNumber, offset);
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation.getText() != null) {
Position position = getAnnotationModel().getPosition(annotation);
final IQuickAssistInvocationContext invocationContext = new QuickAssistInvocationContext(sourceViewer, position.getOffset(), position.getLength(), true);
CompletionProposalRunnable runnable = new CompletionProposalRunnable(invocationContext);
// Note: the resolutions have to be retrieved from the UI thread, otherwise
// workbench.getActiveWorkbenchWindow() will return null in LanguageSpecificURIEditorOpener and
// cause an exception
Display.getDefault().syncExec(runnable);
result = new AnnotationInfo (annotation, position, sourceViewer, runnable.proposals);
recentAnnotationInfo = result;
return result;
}
}
}
return null;
}
示例11: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
ISourceViewer sourceViewer = invocationContext.getSourceViewer();
if (sourceViewer == null)
return new ICompletionProposal[0];
final IDocument document = sourceViewer.getDocument();
if (!(document instanceof IXtextDocument))
return new ICompletionProposal[0];
final IXtextDocument xtextDocument = (IXtextDocument) document;
final IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
List<ICompletionProposal> result = Lists.newArrayList();
try {
Set<Annotation> applicableAnnotations = getApplicableAnnotations(xtextDocument, annotationModel, invocationContext.getOffset());
result = createQuickfixes(invocationContext, applicableAnnotations);
selectAndRevealQuickfix(invocationContext, applicableAnnotations, result);
} catch (BadLocationException e) {
errorMessage = e.getMessage();
}
sortQuickfixes(result);
return result.toArray(new ICompletionProposal[result.size()]);
}
示例12: createQuickfixes
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
/**
* @since 2.3
*/
protected List<ICompletionProposal> createQuickfixes(IQuickAssistInvocationContext invocationContext, Set<Annotation> applicableAnnotations) {
List<ICompletionProposal> result = Lists.newArrayList();
ISourceViewer sourceViewer = invocationContext.getSourceViewer();
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
IXtextDocument xtextDocument = XtextDocumentUtil.get(sourceViewer);
for(Annotation annotation : applicableAnnotations) {
if (annotation instanceof SpellingAnnotation) {
SpellingProblem spellingProblem = ((SpellingAnnotation) annotation).getSpellingProblem();
result.addAll(asList(spellingProblem.getProposals()));
} else {
final Issue issue = issueUtil.getIssueFromAnnotation(annotation);
if (issue != null) {
Iterable<IssueResolution> resolutions = getResolutions(issue, xtextDocument);
if (resolutions.iterator().hasNext()) {
Position pos = annotationModel.getPosition(annotation);
for (IssueResolution resolution : resolutions) {
result.add(create(pos, resolution));
}
}
}
}
}
return result;
}
示例13: selectAndRevealQuickfix
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
/**
* @since 2.3
*/
protected void selectAndRevealQuickfix(IQuickAssistInvocationContext invocationContext, Set<Annotation> applicableAnnotations, List<ICompletionProposal> completionProposals) {
if (completionProposals.isEmpty()) {
return;
}
if (invocationContext instanceof QuickAssistInvocationContext && !((QuickAssistInvocationContext) invocationContext).isSuppressSelection()) {
ISourceViewer sourceViewer = invocationContext.getSourceViewer();
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
Iterator<Annotation> iterator = applicableAnnotations.iterator();
while(iterator.hasNext()){
Position pos = annotationModel.getPosition(iterator.next());
if (pos != null) {
sourceViewer.setSelectedRange(pos.getOffset(), pos.getLength());
sourceViewer.revealRange(pos.getOffset(), pos.getLength());
break;
}
}
}
}
示例14: computeQuickAssistProposals
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
List<IMarker> markers;
try {
markers = getMarkersFor(invocationContext.getSourceViewer(), invocationContext.getOffset());
} catch (BadLocationException e) {
errorMessage = e.getMessage();
return new ICompletionProposal[0];
}
List<ICompletionProposal> result = Lists.newArrayList();
for (IMarker marker : markers) {
for (IMarkerResolution markerResolution : quickFixer.getResolutions(marker)) {
result.add(new MarkerResolutionProposal(marker, markerResolution, invocationContext.getSourceViewer()));
}
}
return result.toArray(new ICompletionProposal[0]);
}
示例15: WordCorrectionProposal
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; //导入依赖的package包/类
/**
* Creates a new word correction proposal.
*
* @param word the corrected word
* @param arguments the problem arguments associated with the spelling problem
* @param offset the offset in the document where to apply the proposal
* @param length the lenght in the document to apply the proposal
* @param context the invocation context for this proposal
* @param relevance the relevance of this proposal
*/
public WordCorrectionProposal(final String word, final String[] arguments, final int offset, final int length, final IQuickAssistInvocationContext context, final int relevance) {
fWord= Character.isUpperCase(arguments[0].charAt(0)) ? Character.toUpperCase(word.charAt(0)) + word.substring(1) : word;
fOffset= offset;
fLength= length;
fContext= context;
fRelevance= relevance;
final StringBuffer buffer= new StringBuffer(80);
buffer.append("...<br>"); //$NON-NLS-1$
buffer.append(getHtmlRepresentation(arguments[1]));
buffer.append("<b>"); //$NON-NLS-1$
buffer.append(getHtmlRepresentation(fWord));
buffer.append("</b>"); //$NON-NLS-1$
buffer.append(getHtmlRepresentation(arguments[2]));
buffer.append("<br>..."); //$NON-NLS-1$
fLine= buffer.toString();
}