| 1 | /******************************************************************************* |
|---|---|
| 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. |
| 3 | * |
| 4 | * This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License 2.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * https://www.eclipse.org/legal/epl-2.0/ |
| 8 | * |
| 9 | * SPDX-License-Identifier: EPL-2.0 |
| 10 | * |
| 11 | * Contributors: |
| 12 | * IBM Corporation - initial API and implementation |
| 13 | *******************************************************************************/ |
| 14 | package org.eclipse.jdt.astview.views; |
| 15 | |
| 16 | import org.eclipse.swt.graphics.Image; |
| 17 | |
| 18 | import org.eclipse.jdt.core.compiler.IProblem; |
| 19 | |
| 20 | import org.eclipse.jdt.core.dom.CompilationUnit; |
| 21 | |
| 22 | /** |
| 23 | * |
| 24 | */ |
| 25 | public class ProblemsProperty extends ASTAttribute { |
| 26 | |
| 27 | private final CompilationUnit fRoot; |
| 28 | |
| 29 | public ProblemsProperty(CompilationUnit root) { |
| 30 | fRoot= root; |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public Object getParent() { |
| 35 | return fRoot; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public Object[] getChildren() { |
| 40 | IProblem[] problems= fRoot.getProblems(); |
| 41 | Object[] res= new Object[problems.length]; |
| 42 | for (int i= 0; i < res.length; i++) { |
| 43 | res[i]= new ProblemNode(this, problems[i]); |
| 44 | } |
| 45 | return res; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public String getLabel() { |
| 50 | return "> compiler problems (" + fRoot.getProblems().length + ")"; //$NON-NLS-1$//$NON-NLS-2$ |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public Image getImage() { |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * @see java.lang.Object#equals(java.lang.Object) |
| 60 | */ |
| 61 | @Override |
| 62 | public boolean equals(Object obj) { |
| 63 | if (this == obj) |
| 64 | return true; |
| 65 | if (obj == null || !obj.getClass().equals(getClass())) { |
| 66 | return false; |
| 67 | } |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | * @see java.lang.Object#hashCode() |
| 73 | */ |
| 74 | @Override |
| 75 | public int hashCode() { |
| 76 | return 18; |
| 77 | } |
| 78 | } |
| 79 |
Members