return null;//new TMLTextHover();
}
@Override
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
IQuickAssistAssistant assistant = new QuickAssistAssistant();
assistant.setQuickAssistProcessor(new IQuickAssistProcessor() {
public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
return false;
}
public boolean canFix(Annotation annotation) {
boolean canFix = false;
if (annotation instanceof MarkerAnnotation) {
MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
try {
if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_TML_REFERENCES)) {
String refType = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_REFERENCE_TYPE, "");
canFix = refType.equals(ReferenceValidator.REFERENCE_TYPE_TML) || refType.equals(ReferenceValidator.REFERENCE_TYPE_SCRIPT);
} else if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_TML_LABEL)) {
return true;
} else if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_INVALID_CHARACTER)) {
return InvalidCharacterCompletionProposal.canCorrect(markerAnnotation);
}
} catch (CoreException e) {;
}
}
return canFix;
}
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
MarkerAnnotation markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_TML_REFERENCES, invocationContext.getOffset(), invocationContext.getSourceViewer());
if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {
String refType = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_REFERENCE_TYPE, "");
boolean isPortletReference = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_IS_PORTLET_REFERENCE, false);
if (refType.equals(ReferenceValidator.REFERENCE_TYPE_TML)) {
proposals.add(new CreateTMLFileReferenceCompletionProposal(markerAnnotation));
if (isPortletReference) {
// check if we can handle this missing portlet reference with our wizzard
String ref = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_MISSING_REFERENCE_PATH, null);
if (ref != null && ref.endsWith("/portlet.tml")) {
String[] parts = ref.split("/");
if (parts.length > 1) {
String portletNameToCreate = parts[parts.length - 2];
proposals.add(new CreateTMLPortletReferenceCompletionProposal(markerAnnotation, portletNameToCreate));
}
}
}
} else if (refType.equals(ReferenceValidator.REFERENCE_TYPE_SCRIPT)) {
proposals.add(new CreateScriptFileReferenceCompletionProposal(markerAnnotation));
}
}
markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_TML_LABEL, invocationContext.getOffset(), invocationContext.getSourceViewer());
if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {
proposals.add(new CreateTMLLabelCompletionProposal(markerAnnotation));
}
markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_INVALID_CHARACTER, invocationContext.getOffset(), invocationContext.getSourceViewer());
if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {
InvalidCharacterCompletionProposal proposal = new InvalidCharacterCompletionProposal(markerAnnotation);
proposals.add(proposal);
}
return proposals.toArray(new ICompletionProposal[0]);
}
public String getErrorMessage() {
return null;
}
});
assistant.install(sourceViewer);
return assistant;
}