@Override public String getMessage() { if (DeltaProcessor.isCompatible(this)) { return Messages.getCompatibleLocalizedMessage(this); } int id = ApiProblemFactory.getProblemMessageId(IApiProblem.CATEGORY_COMPATIBILITY, this.elementType, this.kind, this.flags); return ApiProblemFactory.getLocalizedMessage(id, (this.datas != null ? this.datas : null)); }
/** * Convenience method to get the message id from a problem id * * @param problemid * @return the message id to use for the given problem id */ public static int getProblemMessageId(int problemid) { return getProblemMessageId(getProblemCategory(problemid), getProblemElementKind(problemid), getProblemKind(problemid), getProblemFlags(problemid)); }
/** * Creates a new fatal {@link IApiProblem} * * @param resourcepath the path to the resource this problem was found in * @param messageargs listing of arguments to pass in to the localized * message. The arguments are passed into the string in the order * they appear in the array. * @param kind the kind * @return a new {@link IApiProblem} for API usage */ public static IApiProblem newFatalProblem(String resourcepath, String[] messageargs, int kind) { int id = createProblemId(IApiProblem.CATEGORY_FATAL_PROBLEM, IElementDescriptor.RESOURCE, kind, IApiProblem.NO_FLAGS); return newApiProblem(resourcepath, null, messageargs, null, null, -1, -1, -1, id); }
public static boolean hasExplainProblemResolution(IMarker marker) { int id = ApiProblemFactory.getProblemId(marker); if (id > -1) { if( id == ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_COMPATIBILITY, IDelta.CLASS_ELEMENT_TYPE, IDelta.ADDED, IDelta.FIELD) || id == ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_COMPATIBILITY, IDelta.INTERFACE_ELEMENT_TYPE, IDelta.ADDED, IDelta.FIELD) || id == ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_COMPATIBILITY, IDelta.INTERFACE_ELEMENT_TYPE, IDelta.ADDED, IDelta.DEFAULT_METHOD)) { return true; } } return false; } }
public static int getAPIToolPreferenceTab(int id) { int category = ApiProblemFactory.getProblemCategory(id); int tab = -1; if (category == IApiProblem.CATEGORY_USAGE) { tab = 0; int problemKind = ApiProblemFactory.getProblemKind(id); switch (problemKind) { case IApiProblem.UNUSED_PROBLEM_FILTERS: return 3; default: break; } } if (category == IApiProblem.CATEGORY_COMPATIBILITY) { tab = 1; } if (category == IApiProblem.CATEGORY_SINCETAGS || category == IApiProblem.CATEGORY_VERSION) { tab = 2; } if (category == IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION) { tab = 3; } if (category == IApiProblem.CATEGORY_API_USE_SCAN_PROBLEM) { tab = 4; } return tab; }
public static String getComponentResolutionKey(int id) { int problemKind = ApiProblemFactory.getProblemKind(id); switch (problemKind) { case IApiProblem.API_COMPONENT_RESOLUTION: return IApiProblemTypes.REPORT_RESOLUTION_ERRORS_API_COMPONENT; case IApiProblem.UNUSED_PROBLEM_FILTERS: return IApiProblemTypes.UNUSED_PROBLEM_FILTERS; default: break; } return null; }
int id = ApiProblemFactory.getProblemId(marker); if(id > -1 && ApiProblemFactory.getProblemKind(id) == IApiProblem.MISSING_EE_DESCRIPTIONS) { return new IMarkerResolution[] {installEEResolution, eeResolution};
problem = ApiProblemFactory.newApiProblem(resource.getProjectRelativePath().toPortableString(), typeNameFromMarker, getMessageArgumentsFromMarker(marker), marker.getAttribute(IMarker.CHAR_END, -1), marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_PROBLEM_ID, 0)); filters.add(ApiProblemFactory.newProblemFilter(component.getSymbolicName(), problem, comment)); Util.touchCorrespondingResource(project, resource, typeNameFromMarker);
newfilters.add(ApiProblemFactory.newApiProblem(path, typeName, messageargs, null, null, -1, -1, -1, id));
if(fCategory == null) { int problemid = fBackingMarker.getAttribute(IApiMarkerConstants.MARKER_ATTR_PROBLEM_ID, -1); int category = ApiProblemFactory.getProblemCategory(problemid); switch(category) { case IApiProblem.CATEGORY_COMPATIBILITY: {
public static String getUsagePrefererenceKey(int id) { int problemKind = ApiProblemFactory.getProblemKind(id); int problemFlag = ApiProblemFactory.getProblemFlags(id);
@Override public String getMessage() { if (fMessage == null) { fMessage = ApiProblemFactory.getLocalizedMessage(this); } return fMessage; }
/** * Creates a problem id from the composite members of a problem id. * * @param category * @param element * @param kind * @param flags * @return a new problem id */ public static int createProblemId(int category, int element, int kind, int flags) { return category | element << IApiProblem.OFFSET_ELEMENT | kind << IApiProblem.OFFSET_KINDS | flags << IApiProblem.OFFSET_FLAGS | getProblemMessageId(category, element, kind, flags); }
int problemId = ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_API_USE_SCAN_PROBLEM, elementType, kind, flag); String problemKey = referenceTypeName + problemId; IApiProblem similarProblem = problems.get(problemKey); IApiProblem problem = ApiProblemFactory.newApiUseScanProblem(resource, primaryTypeName, msgArgs, new String[] { IApiMarkerConstants.API_USESCAN_TYPE }, new String[] { primaryTypeName }, lineNumber, charStart, charEnd, elementType, kind, flag); problems.put(problemKey, problem); return problem;
@Override public IMarker[] findOtherMarkers(IMarker[] markers) { HashSet<IMarker> mset = new HashSet<>(markers.length); int id = ApiProblemFactory.getProblemId(fBackingMarker); for (int i = 0; i < markers.length; i++) { try { if (Util.isApiProblemMarker(markers[i]) && !fBackingMarker.equals(markers[i]) && !markers[i].getType().equals(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER)) { if (ApiProblemFactory.getProblemId(markers[i]) == id) { mset.add(markers[i]); } } } catch (CoreException ce) { // do nothing just don't add the filter } } int size = mset.size(); return mset.toArray(new IMarker[size]); }
/** * resolves the {@link IApiProblemFilter} for the given marker * * @param marker */ static IApiProblemFilter resolveFilter(IMarker marker) { try { String filterhandle = marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_FILTER_HANDLE_ID, null); String[] values = filterhandle.split(ApiProblemFilter.HANDLE_DELIMITER); IProject project = marker.getResource().getProject(); IApiComponent component = ApiBaselineManager.getManager().getWorkspaceBaseline().getApiComponent(project); if (component != null) { IApiFilterStore store = component.getFilterStore(); IPath path = new Path(values[1]); IResource resource = project.findMember(path); if (resource == null) { resource = project.getFile(path); } int hashcode = ApiProblemFactory.getProblemHashcode(filterhandle); IApiProblemFilter[] filters = store.getFilters(resource); for (IApiProblemFilter filter : filters) { if (filter.getUnderlyingProblem().hashCode() == hashcode) { return filter; } } } } catch (CoreException ce) { } return null; }
public static String getSinceVersionTagPrefererenceKey(int id) { int problemCategory = ApiProblemFactory.getProblemCategory(id); int problemKind = ApiProblemFactory.getProblemKind(id); switch (problemCategory) { case IApiProblem.CATEGORY_SINCETAGS: {
public static String getAPIUseScanKey(int id) { int problemKind = ApiProblemFactory.getProblemKind(id); switch (problemKind) { case IApiProblem.API_USE_SCAN_TYPE_PROBLEM: return IApiProblemTypes.API_USE_SCAN_TYPE_SEVERITY; case IApiProblem.API_USE_SCAN_METHOD_PROBLEM: return IApiProblemTypes.API_USE_SCAN_METHOD_SEVERITY; case IApiProblem.API_USE_SCAN_FIELD_PROBLEM: return IApiProblemTypes.API_USE_SCAN_FIELD_SEVERITY; default: break; } return null; }
int id = ApiProblemFactory.getProblemId(marker); if (id > -1 && ApiProblemFactory.getProblemKind(id) == IApiProblem.MISSING_EE_DESCRIPTIONS) { return new IMarkerResolution[] { installEEResolution, new ConfigureProblemSeverityForAPIToolsResolution(marker) };
problem = ApiProblemFactory.newApiProblem(resource.getProjectRelativePath().toPortableString(), typeNameFromMarker, getMessageArgumentsFromMarker(marker), null, null, marker.getAttribute(IMarker.LINE_NUMBER, -1), marker.getAttribute(IMarker.CHAR_START, -1), marker.getAttribute(IMarker.CHAR_END, -1), marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_PROBLEM_ID, 0)); filters.add(ApiProblemFactory.newProblemFilter(component.getSymbolicName(), problem, comment)); Util.touchCorrespondingResource(project, resource, typeNameFromMarker);