private StringBuffer buildShortMessage(int maxSize) { StringBuffer retval = new StringBuffer(Messages.ParseException_encountered); Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval.append(" "); //$NON-NLS-1$ if (tok.kind == 0) { retval.append(tokenImage[0]); break; } retval.append(add_escapes(tok.image)); tok = tok.next; } //since the task/problem view already shows the line number, don't duplicate them in the description //retval // .append(DmpMessages.getString("ParseException.atline")).append(currentToken.next.beginLine).append(DmpMessages.getString("ParseException.atcolumn")).append(currentToken.next.beginColumn); //$NON-NLS-1$ //$NON-NLS-2$ retval.append(Messages.ParseException_period + eol); return retval; }
/** * This method has the standard behavior when this object has been created using the standard constructors. * Otherwise, it uses "currentToken" and "expectedTokenSequences" to generate a parse error message and returns it. * If this object has been created due to a parse error, and you do not catch it (it gets thrown from the parser), * then this method is called during the printing of the final stack trace, and hence the correct error message gets * displayed. * @see #getShortMessage() */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } int maxSize = getExpectedTokenSequencesMaxSize(); StringBuffer expected = buildExpectedTokenMessage(); StringBuffer retval = buildShortMessage(maxSize); if (expectedTokenSequences.length == 1) { retval.append(Messages.ParseException_expecting).append(eol).append(" "); } else { retval.append(Messages.ParseException_expection_oneof).append(eol).append(" "); } retval.append(expected); return retval.toString(); }
/** * This method has the standard behavior when this object has been created using the standard constructors. * Otherwise, it uses "currentToken" to generate a parse error message and returns it. * If this object has been created due to a parse error, and you do not catch it (it gets thrown from the parser), * then this method is called during the printing of the final stack trace, and hence the correct error message gets * displayed. * @see #getMessage() */ public String getShortMessage() { if (!specialConstructor) { return super.getMessage(); } int maxSize = getExpectedTokenSequencesMaxSize(); StringBuffer retval = buildShortMessage(maxSize); return retval.toString(); }
/** * create markers according to the parse exceptions * * @param exceptions Collections of ParseException * @throws CoreException */ private void updateErrorAnnotation(ArrayList exceptions) { try { for (Iterator iter = exceptions.iterator(); iter.hasNext();) { //create markers according to the parse exceptions ParseException ex = (ParseException) iter.next(); HashMap attrs = new HashMap(); attrs.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); String storageName = "";//$NON-NLS-1$ if (!(_input instanceof IFileEditorInput)) { storageName = _input.getName() + ": ";//$NON-NLS-1$ } attrs.put(IMarker.MESSAGE, storageName + ex.getMessage()); attrs.put(ISQLEditorMarker.SHORT_MESSAGE, storageName + ex.getShortMessage()); updateAnnotation(ex, EditorConstants.SYNTAX_MARKER_TYPE, attrs); } } catch (CoreException e) { SQLEditorPlugin.getDefault().log(SQLEditorResources.SQLUpdater_error_annotation, e); } }
/** * create portable task markers according to the parse exceptions * * @param exceptions Collections of ParseException * @throws CoreException */ private void updatePortableAnnotation(ArrayList exceptions) { try { for (Iterator iter = exceptions.iterator(); iter.hasNext();) { //create markers according to the parse exceptions ParseException ex = (ParseException) iter.next(); HashMap attrs = new HashMap(); attrs.put(IMarker.USER_EDITABLE, Boolean.FALSE); String storageName = "";//$NON-NLS-1$ if (!(_input instanceof IFileEditorInput)) { storageName = _input.getName() + ": ";//$NON-NLS-1$ } attrs.put(IMarker.MESSAGE, storageName + NLS.bind(SQLEditorResources.SQLUpdater_nonportable, (new String[]{_portableTarget})) + ex.getMessage()); updateAnnotation(ex, EditorConstants.PORTABILITY_MARKER_TYPE, attrs); } } catch (CoreException e) { SQLEditorPlugin.getDefault().log(SQLEditorResources.SQLUpdater_error_annotation, e); } }