| 1 | /******************************************************************************* |
|---|---|
| 2 | * Copyright (c) 2000, 2015 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 java.util.List; |
| 17 | |
| 18 | import org.eclipse.swt.graphics.Image; |
| 19 | |
| 20 | import org.eclipse.jdt.core.dom.Comment; |
| 21 | import org.eclipse.jdt.core.dom.CompilationUnit; |
| 22 | |
| 23 | /** |
| 24 | * |
| 25 | */ |
| 26 | public class CommentsProperty extends ASTAttribute { |
| 27 | |
| 28 | private final CompilationUnit fRoot; |
| 29 | |
| 30 | public CommentsProperty(CompilationUnit root) { |
| 31 | fRoot= root; |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public Object getParent() { |
| 36 | return fRoot; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public Object[] getChildren() { |
| 41 | List<Comment> commentList= fRoot.getCommentList(); |
| 42 | return (commentList == null ? EMPTY : commentList.toArray()); |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public String getLabel() { |
| 47 | List<Comment> commentList= fRoot.getCommentList(); |
| 48 | return "> comments (" + (commentList == null ? 0 : commentList.size()) + ")"; //$NON-NLS-1$//$NON-NLS-2$ |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Image getImage() { |
| 53 | return null; |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | * @see java.lang.Object#equals(java.lang.Object) |
| 58 | */ |
| 59 | @Override |
| 60 | public boolean equals(Object obj) { |
| 61 | if (this == obj) |
| 62 | return true; |
| 63 | if (obj == null || !obj.getClass().equals(getClass())) { |
| 64 | return false; |
| 65 | } |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | /* |
| 70 | * @see java.lang.Object#hashCode() |
| 71 | */ |
| 72 | @Override |
| 73 | public int hashCode() { |
| 74 | return 17; |
| 75 | } |
| 76 | } |
| 77 |
Members