Returns a tree path for a tree node within a compilation unit,
or {@code null} if the node is not found.
@param unit the compilation unit to search
@param target the node to locate
@return the tree path
773668
public static TreePath getPath(CompilationUnitTree unit, Tree target) {
        return getPath(new TreePath(unit), target);
    }
966224
@Nullable
  public static MethodSymbol getSymbol(MemberReferenceTree tree) {
    Symbol sym = ((JCMemberReference) tree).sym;
    return sym instanceof MethodSymbol ? (MethodSymbol) sym : null;
  }
834176
private CommandLineCompilerConfiguration getBaseCompilerConfiguration(final Map<String, TargetInfo> targets) {
    //
    // find first target with an DevStudio C compilation
    //
    CommandLineCompilerConfiguration compilerConfig;
    //
    // get the first target and assume that it is representative
    //
    for (final TargetInfo targetInfo : targets.values()) {
      final ProcessorConfiguration config = targetInfo.getConfiguration();
      //
      // for the first cl compiler
      //
      if (config instanceof CommandLineCompilerConfiguration) {
        compilerConfig = (CommandLineCompilerConfiguration) config;
        if (compilerConfig.getCompiler() instanceof MsvcCCompiler) {
          return compilerConfig;
        }
      }
    }
    return null;
  }
127344
def _source_roots_for_target(target):
    
    def root_package_prefix(source_file):
      source = os.path.dirname(source_file)
      return os.path.join(get_buildroot(), target.target_base, source), source.replace(os.sep, '.')
    return {root_package_prefix(source) for source in target.sources_relative_to_source_root()}
754767
def tree_path(treemap, tree)
      if (ptree = treemap[tree])
        tree_path(treemap, ptree) + '/' + tree.name
      else
        ''
      end
    end
75192
public VirtualFile getFile(VirtualFile mountPoint, VirtualFile target) {
        final String path = target.getPathNameRelativeTo(mountPoint);
        return rootNode.getFile(new Path(path), mountPoint);
    }
211788
private CommandLineCompilerConfiguration getBaseCompilerConfiguration(final Map targets) {
    //
    // find first target with an GNU C++ compilation
    //
    CommandLineCompilerConfiguration compilerConfig;
    //
    // get the first target and assume that it is representative
    //
    for (final Object o : targets.values()) {
      final TargetInfo targetInfo = (TargetInfo) o;
      final ProcessorConfiguration config = targetInfo.getConfiguration();
      //
      // for the first cl compiler
      //
      if (config instanceof CommandLineCompilerConfiguration) {
        compilerConfig = (CommandLineCompilerConfiguration) config;
        if (compilerConfig.getCompiler() instanceof GccCCompiler) {
          return compilerConfig;
        }
      }
    }
    return null;
  }
157863
public final hqlParser.path_return path() throws RecognitionException {
		hqlParser.path_return retval = new hqlParser.path_return();
		retval.start = input.LT(1);

		CommonTree root_0 = null;

		Token DOT303=null;
		ParserRuleReturnScope identifier302 =null;
		ParserRuleReturnScope identifier304 =null;

		CommonTree DOT303_tree=null;


		// TODO - need to clean up DotIdent - suspect that DotIdent2 supersedes the other one, but need to do the analysis
		//HandleDotIdent2();

		try {
			// hql.g:714:2: ( identifier ( DOT ^ identifier )* )
			// hql.g:714:4: identifier ( DOT ^ identifier )*
			{
			root_0 = (CommonTree)adaptor.nil();


			pushFollow(FOLLOW_identifier_in_path3609);
			identifier302=identifier();
			state._fsp--;

			adaptor.addChild(root_0, identifier302.getTree());

			// hql.g:714:15: ( DOT ^ identifier )*
			loop108:
			while (true) {
				int alt108=2;
				int LA108_0 = input.LA(1);
				if ( (LA108_0==DOT) ) {
					alt108=1;
				}

				switch (alt108) {
				case 1 :
					// hql.g:714:17: DOT ^ identifier
					{
					DOT303=(Token)match(input,DOT,FOLLOW_DOT_in_path3613);
					DOT303_tree = (CommonTree)adaptor.create(DOT303);
					root_0 = (CommonTree)adaptor.becomeRoot(DOT303_tree, root_0);

					 WeakKeywords();
					pushFollow(FOLLOW_identifier_in_path3618);
					identifier304=identifier();
					state._fsp--;

					adaptor.addChild(root_0, identifier304.getTree());

					}
					break;

				default :
					break loop108;
				}
			}

			}

			retval.stop = input.LT(-1);

			retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
			retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
		}
		finally {
			// do for sure before leaving
		}
		return retval;
	}
849533
@Nullable
    public final Folder findTargetFolder(@NotEmpty final String generatorName, @NotEmpty final String artifactName) {
        Contract.requireArgNotEmpty("generatorName", generatorName);
        Contract.requireArgNotEmpty("artifactName", artifactName);
        if (parent == null) {
            throw new IllegalStateException("Parent for generators is not set");
        }
        try {
            return parent.findTargetFolder(generatorName, artifactName);
        } catch (final ProjectNameNotDefinedException ex) {
            throw new RuntimeException(
                    "Couldn't determine target folder for generator '" + generatorName + "' and artifact '" + artifactName + "'", ex);
        } catch (final ArtifactNotFoundException ex) {
            throw new RuntimeException(
                    "Couldn't determine target folder for generator '" + generatorName + "' and artifact '" + artifactName + "'", ex);
        } catch (final FolderNameNotDefinedException ex) {
            throw new RuntimeException(
                    "Couldn't determine target folder for generator '" + generatorName + "' and artifact '" + artifactName + "'", ex);
        } catch (final GeneratorNotFoundException ex) {
            throw new RuntimeException(
                    "Couldn't determine target folder for generator '" + generatorName + "' and artifact '" + artifactName + "'", ex);
        } catch (final ProjectNotFoundException ex) {
            throw new RuntimeException(
                    "Couldn't determine target folder for generator '" + generatorName + "' and artifact '" + artifactName + "'", ex);
        } catch (final FolderNotFoundException ex) {
            throw new RuntimeException(
                    "Couldn't determine target folder for generator '" + generatorName + "' and artifact '" + artifactName + "'", ex);
        }
    }
220821
public static String findCodeBaseInClassPath(@Nonnull String codeBaseName, String classPath) {
        if (classPath == null) {
            return null;
        }

        StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
        while (tok.hasMoreTokens()) {
            String t = tok.nextToken();
            File f = new File(t);
            if (f.getName().equals(codeBaseName)) {
                return t;
            }
        }

        return null;
    }
560442
public FileNode locateClasspathEntry(Class<?> c) {
        return locateEntry(c, Reflect.resourceName(c), false);
    }
509443
public static Map<CompilerConfiguration, Vector<TargetInfo>> getTargetsToBuildByConfiguration(
      final Map<String, TargetInfo> targets) {
    final Map<CompilerConfiguration, Vector<TargetInfo>> targetsByConfig = new HashMap<>();
    for (final TargetInfo target : targets.values()) {
      if (target.getRebuild()) {
        // FIXME: Types do not match between the key of targetsByConfig and the return value of target.getConfiguration
        Vector<TargetInfo> targetsForSameConfig = targetsByConfig.get(target.getConfiguration());
        if (targetsForSameConfig != null) {
          targetsForSameConfig.addElement(target);
        } else {
          targetsForSameConfig = new Vector<>();
          targetsForSameConfig.addElement(target);
          targetsByConfig.put((CompilerConfiguration) target.getConfiguration(), targetsForSameConfig);
        }
      }
    }
    return targetsByConfig;
  }
909467
public static boolean classNodeImplementsType(ClassNode node, Class target) {
        ClassNode targetNode = ClassHelper.make(target);
        if (node.implementsInterface(targetNode)) {
            return true;
        }
        if (node.isDerivedFrom(targetNode)) {
            return true;
        }
        if (node.getName().equals(target.getName())) {
            return true;
        }
        if (node.getName().equals(target.getSimpleName())) {
            return true;
        }
        if (node.getSuperClass() != null && node.getSuperClass().getName().equals(target.getName())) {
            return true;
        }
        if (node.getSuperClass() != null && node.getSuperClass().getName().equals(target.getSimpleName())) {
            return true;
        }
        if (node.getInterfaces() != null) {
            for (ClassNode declaredInterface : node.getInterfaces()) {
                if (classNodeImplementsType(declaredInterface, target)) {
                    return true;
                }
            }
        }
        return false;
    }
883056
public Iterable<? extends Element> enter(Iterable<? extends CompilationUnitTree> trees)
    {
        if (trees == null && notYetEntered != null && notYetEntered.isEmpty())
            return List.nil();

        boolean wasInitialized = compiler != null;

        prepareCompiler(true);

        ListBuffer<JCCompilationUnit> roots = null;

        if (trees == null) {
            // If there are still files which were specified to be compiled
            // (i.e. in fileObjects) but which have not yet been entered,
            // then we make sure they have been parsed and add them to the
            // list to be entered.
            if (notYetEntered.size() > 0) {
                if (!parsed)
                    parseInternal(); // TODO would be nice to specify files needed to be parsed
                for (JavaFileObject file: args.getFileObjects()) {
                    JCCompilationUnit unit = notYetEntered.remove(file);
                    if (unit != null) {
                        if (roots == null)
                            roots = new ListBuffer<>();
                        roots.append(unit);
                    }
                }
                notYetEntered.clear();
            }
        }
        else {
            for (CompilationUnitTree cu : trees) {
                if (cu instanceof JCCompilationUnit) {
                    if (roots == null)
                        roots = new ListBuffer<>();
                    roots.append((JCCompilationUnit)cu);
                    notYetEntered.remove(cu.getSourceFile());
                }
                else
                    throw new IllegalArgumentException(cu.toString());
            }
        }

        if (roots == null) {
            if (trees == null && !wasInitialized) {
                compiler.initModules(List.nil());
            }
            return List.nil();
        }

        List<JCCompilationUnit> units = compiler.initModules(roots.toList());

        try {
            units = compiler.enterTrees(units);

            if (notYetEntered.isEmpty())
                compiler.processAnnotations(units);

            ListBuffer<Element> elements = new ListBuffer<>();
            for (JCCompilationUnit unit : units) {
                boolean isPkgInfo = unit.sourcefile.isNameCompatible("package-info",
                                                                     JavaFileObject.Kind.SOURCE);
                if (isPkgInfo) {
                    elements.append(unit.packge);
                } else {
                    for (JCTree node : unit.defs) {
                        if (node.hasTag(JCTree.Tag.CLASSDEF)) {
                            JCClassDecl cdef = (JCClassDecl) node;
                            if (cdef.sym != null) // maybe null if errors in anno processing
                                elements.append(cdef.sym);
                        } else if (node.hasTag(JCTree.Tag.MODULEDEF)) {
                            JCModuleDecl mdef = (JCModuleDecl) node;
                            if (mdef.sym != null)
                                elements.append(mdef.sym);
                        }
                    }
                }
            }
            return elements.toList();
        }
        finally {
            compiler.log.flush();
        }
    }
618897
private File getTargetDir( File path)
    {
    return
      path == null?
      targetDir_ :

      path.isAbsolute()?
      path :

      new File( targetDir_, path.getPath());
    }
195445
public List<String> getChildNames(VirtualFile mountPoint, VirtualFile target) {
        List<String> names = new LinkedList<String>();
        AssemblyNode targetNode = null;
        if (mountPoint.equals(target)) {
            targetNode = rootNode;
        } else {
            targetNode = rootNode.find(target.getPathNameRelativeTo(mountPoint));
        }
        if (targetNode != null) {
            for (AssemblyNode childNode : targetNode.children.values()) {
                names.add(childNode.realName);
            }
        }
        return names;
    }
425071
@Nullable
  private static Symbol tryGetSymbol(Tree tree) {
    if (tree instanceof JCIdent) {
      return ((JCIdent) tree).sym;
    }
    if (tree instanceof JCFieldAccess) {
      return ((JCFieldAccess) tree).sym;
    }
    if (tree instanceof JCVariableDecl) {
      return ((JCVariableDecl) tree).sym;
    }
    return null;
  }