/* * (non-Javadoc) * @see org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector# * getMessageArgs * (org.eclipse.pde.api.tools.internal.provisional.builder.IReference) */ @Override protected String[] getMessageArgs(IReference reference) throws CoreException { IApiMember member = reference.getMember(); String eeValue = ProfileModifiers.getName(this.referenceEEs.get(reference).intValue()); String simpleTypeName = Signatures.getSimpleTypeName(reference.getReferencedTypeName()); if (simpleTypeName.indexOf('$') != -1) { simpleTypeName = simpleTypeName.replace('$', '.'); } switch (reference.getReferenceType()) { case IReference.T_TYPE_REFERENCE: { return new String[] { getDisplay(member, false), simpleTypeName, eeValue, }; } case IReference.T_FIELD_REFERENCE: { return new String[] { getDisplay(member, false), simpleTypeName, reference.getReferencedMemberName(), eeValue, }; } case IReference.T_METHOD_REFERENCE: { String referenceMemberName = reference.getReferencedMemberName(); if (Util.isConstructor(referenceMemberName)) { return new String[] { getDisplay(member, false), Signature.toString( reference.getReferencedSignature(), simpleTypeName, null, false, false), eeValue, }; } else { return new String[] { getDisplay(member, false), simpleTypeName, Signature.toString( reference.getReferencedSignature(), referenceMemberName, null, false, false), eeValue, }; } } default: break; } return null; }
/* * (non-Javadoc) * @see org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector# * getProblemFlags * (org.eclipse.pde.api.tools.internal.provisional.builder.IReference) */ @Override protected int getProblemFlags(IReference reference) { switch (reference.getReferenceType()) { case IReference.T_TYPE_REFERENCE: { return IApiProblem.NO_FLAGS; } case IReference.T_METHOD_REFERENCE: { if (Util.isConstructor(reference.getReferencedMemberName())) { return IApiProblem.CONSTRUCTOR_METHOD; } return IApiProblem.METHOD; } case IReference.T_FIELD_REFERENCE: { return IApiProblem.FIELD; } default: { return IApiProblem.NO_FLAGS; } } }
/* * (non-Javadoc) * @see org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector# * getSourceRange(org.eclipse.jdt.core.IType, * org.eclipse.jface.text.IDocument, * org.eclipse.pde.api.tools.internal.provisional.builder.IReference) */ @Override protected Position getSourceRange(IType type, IDocument document, IReference reference) throws CoreException, BadLocationException { switch (reference.getReferenceType()) { case IReference.T_TYPE_REFERENCE: { int linenumber = reference.getLineNumber(); if (linenumber > 0) { // line number starts at 0 for the linenumber--; } if (linenumber > 0) { int offset = document.getLineOffset(linenumber); String line = document.get(offset, document.getLineLength(linenumber)); String qname = reference.getReferencedTypeName().replace('$', '.'); int first = line.indexOf(qname); if (first < 0) { qname = Signatures.getSimpleTypeName(reference.getReferencedTypeName()); qname = qname.replace('$', '.'); first = line.indexOf(qname); } Position pos = null; if (first > -1) { pos = new Position(offset + first, qname.length()); } else { // optimistically select the whole line since we can't // find the correct variable name and we can't just // select // the first occurrence pos = new Position(offset, line.length()); } return pos; } else { IApiMember apiMember = reference.getMember(); switch (apiMember.getType()) { case IApiElement.FIELD: { IApiField field = (IApiField) reference.getMember(); return getSourceRangeForField(type, reference, field); } case IApiElement.METHOD: { // reference in a method declaration IApiMethod method = (IApiMethod) reference.getMember(); return getSourceRangeForMethod(type, reference, method); } default: break; } // reference in a type declaration ISourceRange range = type.getNameRange(); Position pos = null; if (range != null) { pos = new Position(range.getOffset(), range.getLength()); } if (pos == null) { return defaultSourcePosition(type, reference); } return pos; } } case IReference.T_FIELD_REFERENCE: { int linenumber = reference.getLineNumber(); if (linenumber > 0) { return getFieldNameRange( reference.getReferencedTypeName(), reference.getReferencedMemberName(), document, reference); } // reference in a field declaration IApiField field = (IApiField) reference.getMember(); return getSourceRangeForField(type, reference, field); } case IReference.T_METHOD_REFERENCE: { if (reference.getLineNumber() >= 0) { String referenceMemberName = reference.getReferencedMemberName(); String methodName = null; boolean isConstructor = Util.isConstructor(referenceMemberName); if (isConstructor) { methodName = Signatures.getSimpleTypeName(reference.getReferencedTypeName().replace('$', '.')); } else { methodName = referenceMemberName; } Position pos = getMethodNameRange(isConstructor, methodName, document, reference); if (pos == null) { return defaultSourcePosition(type, reference); } return pos; } // reference in a method declaration IApiMethod method = (IApiMethod) reference.getMember(); return getSourceRangeForMethod(type, reference, method); } default: return null; } }