use of org.eclipse.jface.text.quickassist.IQuickFixableAnnotation in project liferay-ide by liferay.
the class JSPQuickAssistProcessor method computeQuickAssistProposals.
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext context) {
ICompletionProposal[] retval = null;
List<ICompletionProposal> proposals = new ArrayList<>();
ISourceViewer sourceViewer = context.getSourceViewer();
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
Iterator<Annotation> annotations = annotationModel.getAnnotationIterator();
while (annotations.hasNext()) {
Annotation annotation = annotations.next();
Position position = annotationModel.getPosition(annotation);
try {
IMarker marker = _createTempMarker(annotation);
int lineNum = sourceViewer.getDocument().getLineOfOffset(position.getOffset()) + 1;
int currentLineNum = sourceViewer.getDocument().getLineOfOffset(context.getOffset()) + 1;
if ((marker != null) && (currentLineNum == lineNum)) {
if (marker.getAttribute(LiferayBaseValidator.MARKER_QUERY_ID, null) != null) {
ICompletionProposal[] resolutions = _createFromMarkerResolutions(marker);
if (ListUtil.isNotEmpty(resolutions)) {
Collections.addAll(proposals, resolutions);
if (annotation instanceof IQuickFixableAnnotation) {
IQuickFixableAnnotation quick = (IQuickFixableAnnotation) annotation;
quick.setQuickFixable(true);
}
}
}
}
} catch (BadLocationException ble) {
LiferayXMLSearchUI.logError("Error finding quick assists", ble);
}
}
if (ListUtil.isNotEmpty(proposals)) {
retval = proposals.toArray(new ICompletionProposal[0]);
}
return retval;
}
use of org.eclipse.jface.text.quickassist.IQuickFixableAnnotation in project liferay-ide by liferay.
the class AbstractQuickAssistProcessorFromMarkerResolution method computeQuickAssistProposals.
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext context) {
ICompletionProposal[] retval = null;
List<ICompletionProposal> proposals = new ArrayList<>();
ISourceViewer sourceViewer = context.getSourceViewer();
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
Iterator<Annotation> annotations = annotationModel.getAnnotationIterator();
while (annotations.hasNext()) {
Annotation annotation = annotations.next();
Position position = annotationModel.getPosition(annotation);
try {
IMarker marker = getMarkerFromAnnotation(annotation);
int lineNum = sourceViewer.getDocument().getLineOfOffset(position.getOffset()) + 1;
int currentLineNum = sourceViewer.getDocument().getLineOfOffset(context.getOffset()) + 1;
if ((marker != null) && (currentLineNum == lineNum)) {
ICompletionProposal[] resolutions = createFromMarkerResolutions(marker);
if (ListUtil.isNotEmpty(resolutions)) {
Collections.addAll(proposals, resolutions);
if (annotation instanceof IQuickFixableAnnotation) {
IQuickFixableAnnotation quick = (IQuickFixableAnnotation) annotation;
quick.setQuickFixable(true);
}
}
}
} catch (BadLocationException ble) {
LiferayXMLSearchUI.logError("Error finding quick assists", ble);
}
}
if (ListUtil.isNotEmpty(proposals)) {
retval = proposals.toArray(new ICompletionProposal[0]);
}
return retval;
}
Aggregations