1 /******************************************************************************* 2 * Copyright (c) 2000, 2016 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.internal.core.manipulation.search; 15 16 import org.eclipse.jdt.core.dom.ASTNode; 17 import org.eclipse.jdt.core.dom.CompilationUnit; 18 19 public interface IOccurrencesFinder { 20 21 public static final int K_OCCURRENCE= 5; 22 23 public static final int K_EXCEPTION_OCCURRENCE= 6; 24 public static final int K_EXIT_POINT_OCCURRENCE= 7; 25 public static final int K_IMPLEMENTS_OCCURRENCE= 8; 26 public static final int K_BREAK_TARGET_OCCURRENCE= 9; 27 28 public static final int F_WRITE_OCCURRENCE= 1; 29 public static final int F_READ_OCCURRENCE= 2; 30 public static final int F_EXCEPTION_DECLARATION= 8; 31 32 33 /** 34 * Element representing a occurrence 35 */ 36 public static class OccurrenceLocation { 37 private final int fOffset; 38 private final int fLength; 39 private final int fFlags; 40 private final String fDescription; 41 OccurrenceLocation(int offset, int length, int flags, String description)42 public OccurrenceLocation(int offset, int length, int flags, String description) { 43 fOffset= offset; 44 fLength= length; 45 fFlags= flags; 46 fDescription= description; 47 } 48 getOffset()49 public int getOffset() { 50 return fOffset; 51 } 52 getLength()53 public int getLength() { 54 return fLength; 55 } 56 getFlags()57 public int getFlags() { 58 return fFlags; 59 } 60 getDescription()61 public String getDescription() { 62 return fDescription; 63 } 64 65 @Override toString()66 public String toString() { 67 return "[" + fOffset + " / " + fLength + "] " + fDescription; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ 68 } 69 70 } 71 72 initialize(CompilationUnit root, int offset, int length)73 public String initialize(CompilationUnit root, int offset, int length); 74 initialize(CompilationUnit root, ASTNode node)75 public String initialize(CompilationUnit root, ASTNode node); 76 getJobLabel()77 public String getJobLabel(); 78 79 /** 80 * Returns the plural label for this finder with 3 placeholders: 81 * <ul> 82 * <li>{0} for the {@link #getElementName() element name}</li> 83 * <li>{1} for the number of results found</li> 84 * <li>{2} for the scope (name of the compilation unit)</li> 85 * </ul> 86 * @return the unformatted label 87 */ getUnformattedPluralLabel()88 public String getUnformattedPluralLabel(); 89 90 /** 91 * Returns the singular label for this finder with 2 placeholders: 92 * <ul> 93 * <li>{0} for the {@link #getElementName() element name}</li> 94 * <li>{1} for the scope (name of the compilation unit)</li> 95 * </ul> 96 * @return the unformatted label 97 */ getUnformattedSingularLabel()98 public String getUnformattedSingularLabel(); 99 100 /** 101 * Returns the name of the element to look for or <code>null</code> if the finder hasn't 102 * been initialized yet. 103 * @return the name of the element 104 */ getElementName()105 public String getElementName(); 106 107 108 /** 109 * Returns the AST root. 110 * 111 * @return the AST root 112 */ getASTRoot()113 public CompilationUnit getASTRoot(); 114 115 /** 116 * Returns the occurrences 117 * 118 * @return the occurrences 119 */ getOccurrences()120 public OccurrenceLocation[] getOccurrences(); 121 122 getSearchKind()123 public int getSearchKind(); 124 125 /** 126 * Returns the id of this finder. 127 * @return returns the id of this finder. 128 */ getID()129 public String getID(); 130 131 } 132