Home | History | Annotate | Download | only in ast
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.google.currysrc.api.process.ast;
     17 
     18 import org.eclipse.jdt.core.dom.BodyDeclaration;
     19 import org.eclipse.jdt.core.dom.CompilationUnit;
     20 
     21 /**
     22  * Interface for objects that match and find {@link org.eclipse.jdt.core.dom.BodyDeclaration}
     23  * instances within an AST.
     24  */
     25 public interface BodyDeclarationLocator {
     26 
     27   boolean matches(BodyDeclaration node);
     28 
     29   BodyDeclaration find(CompilationUnit cu);
     30 
     31   /**
     32    * The prefix used to identify the {@link BodyDeclarationLocator} in string form. e.g. "method",
     33    * "field".
     34    */
     35   String getStringFormType();
     36 
     37   /**
     38    * Generates a string form of the locator that identifies the declaration being targeted. e.g.
     39    * {@code com.foo.Bar#baz}, {@code com.foo.Bar$Baz}, {@code com.foo.Bar#baz()}. Note, it differs
     40    * from Javadoc locators used in {@literal @}see and {@literal @}link by using '$' to delineate
     41    * classes from package separators. Used by {@link BodyDeclarationLocators}.
     42    */
     43   String getStringFormTarget();
     44 
     45   /**
     46    * Returns the {@link TypeLocator} for the type declaration associated with this
     47    * locator. e.g. for a {@link MethodLocator} it returns a type locator that can find the
     48    * declaring type of the method. When called on a {@link TypeLocator} it returns {@code this}.
     49    */
     50   TypeLocator getTypeLocator();
     51 }
     52