* @throws IOException
* @throws CommonException
* @throws RecognitionException
*/
public static CodeContext getExternalCodeContext(final IProject project, String packagePath) throws IOException, CommonException {
GoEnvironment goEnvironment = GoProjectEnvironment.getGoEnvironment(project);
CodeContext codeContext = new CodeContext(packagePath, project);
// InterfaceParser interfaceParser = new InterfaceParser(tokenizer);
// find path
File pkgdir = goEnvironment.getGoRoot().getSourceRootLocation().resolve(packagePath).toFile();
// TODO Get rid of the following duplication
if (pkgdir.exists() && pkgdir.isDirectory()) {
processExternalPackage(codeContext, pkgdir);
} else {
for (IFolder folder : Environment.getSourceFolders(project)) {
// String path = Environment.INSTANCE.getAbsoluteProjectPath();
pkgdir = new File(folder.getLocation().toOSString() + File.separator + packagePath);
if (pkgdir.exists() && pkgdir.isDirectory()) {
processExternalPackage(codeContext, pkgdir);
} else {
continue;
}
List<String> goPathElements = goEnvironment.getGoPathEntries();
// FIXME: BM: this code is most certainly buggy, perhaps the whole function too.
String goPath = goPathElements.get(0);
pkgdir = new File(goPath + "/src/" + packagePath);
if (pkgdir.exists() && pkgdir.isDirectory()) {