| /******************************************************************************* |
| * Copyright (c) 2008 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.pde.api.tools.internal.search; |
| |
| import java.util.Set; |
| |
| import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod; |
| import org.eclipse.pde.api.tools.internal.provisional.model.IReference; |
| import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; |
| import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes; |
| import org.eclipse.pde.api.tools.internal.provisional.search.ReferenceModifiers; |
| |
| /** |
| * Detects leaks in method parameter types |
| * |
| * @since 1.1 |
| */ |
| public class LeakParameterTypeDetector extends MethodLeakDetector { |
| |
| /** |
| * @param nonApiPackageNames |
| */ |
| public LeakParameterTypeDetector(Set nonApiPackageNames) { |
| super(nonApiPackageNames); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getSeverityKey() |
| */ |
| protected String getSeverityKey() { |
| return IApiProblemTypes.LEAK_METHOD_PARAM; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiProblemDetector#getReferenceKinds() |
| */ |
| public int getReferenceKinds() { |
| return ReferenceModifiers.REF_PARAMETER; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getProblemFlags(org.eclipse.pde.api.tools.internal.provisional.model.IReference) |
| */ |
| protected int getProblemFlags(IReference reference) { |
| IApiMethod method = (IApiMethod) reference.getMember(); |
| if (method.isConstructor()) { |
| return IApiProblem.LEAK_CONSTRUCTOR_PARAMETER; |
| } |
| return IApiProblem.LEAK_METHOD_PARAMETER; |
| } |
| |
| } |