| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2008, 2009 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.pde.api.tools.internal.builder; |
| 12 | |
| 13 | import java.util.Set; |
| 14 | |
| 15 | import org.eclipse.pde.api.tools.internal.provisional.builder.IReference; |
| 16 | import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod; |
| 17 | import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; |
| 18 | import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes; |
| 19 | |
| 20 | /** |
| 21 | * Detects leaks in method parameter types |
| 22 | * |
| 23 | * @since 1.1 |
| 24 | */ |
| 25 | public class LeakParameterTypeDetector extends MethodLeakDetector { |
| 26 | |
| 27 | /** |
| 28 | * @param nonApiPackageNames |
| 29 | */ |
| 30 | public LeakParameterTypeDetector(Set nonApiPackageNames) { |
| 31 | super(nonApiPackageNames); |
| 32 | } |
| 33 | |
| 34 | /* (non-Javadoc) |
| 35 | * @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getSeverityKey() |
| 36 | */ |
| 37 | protected String getSeverityKey() { |
| 38 | return IApiProblemTypes.LEAK_METHOD_PARAM; |
| 39 | } |
| 40 | |
| 41 | /* (non-Javadoc) |
| 42 | * @see org.eclipse.pde.api.tools.internal.provisional.search.IApiProblemDetector#getReferenceKinds() |
| 43 | */ |
| 44 | public int getReferenceKinds() { |
| 45 | return IReference.REF_PARAMETER; |
| 46 | } |
| 47 | |
| 48 | /* (non-Javadoc) |
| 49 | * @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getProblemFlags(org.eclipse.pde.api.tools.internal.provisional.model.IReference) |
| 50 | */ |
| 51 | protected int getProblemFlags(IReference reference) { |
| 52 | IApiMethod method = (IApiMethod) reference.getMember(); |
| 53 | if (method.isConstructor()) { |
| 54 | return IApiProblem.LEAK_CONSTRUCTOR_PARAMETER; |
| 55 | } |
| 56 | return IApiProblem.LEAK_METHOD_PARAMETER; |
| 57 | } |
| 58 | |
| 59 | } |