/* package-private
497565
final PublishResponse publish(String topic, List<PubsubMessage> messages) {

    PublishRequest request =
        PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build();
    return publish(request);
  }
318611
function parsePackageSpecifier(rawPackageSpecifier) {
    rawPackageSpecifier = (rawPackageSpecifier || '').trim();
    const separatorIndex = rawPackageSpecifier.lastIndexOf('@');
    let name;
    let version = undefined;
    if (separatorIndex === 0) {
        // The specifier starts with a scope and doesn't have a version specified
        name = rawPackageSpecifier;
    }
    else if (separatorIndex === -1) {
        // The specifier doesn't have a version
        name = rawPackageSpecifier;
    }
    else {
        name = rawPackageSpecifier.substring(0, separatorIndex);
        version = rawPackageSpecifier.substring(separatorIndex + 1);
    }
    if (!name) {
        throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`);
    }
    return { name, version };
}
805121
static Fix createFix(
      ImmutableList<ImportTree> wildcardImports,
      Set<TypeToImport> typesToImport,
      VisitorState state) {
    Map<Symbol, List<TypeToImport>> toFix =
        typesToImport.stream().collect(Collectors.groupingBy(TypeToImport::owner));
    final SuggestedFix.Builder fix = SuggestedFix.builder();
    for (ImportTree importToDelete : wildcardImports) {
      String importSpecification = importToDelete.getQualifiedIdentifier().toString();
      if (importToDelete.isStatic()) {
        fix.removeStaticImport(importSpecification);
      } else {
        fix.removeImport(importSpecification);
      }
    }
    for (Map.Entry<Symbol, List<TypeToImport>> entry : toFix.entrySet()) {
      final Symbol owner = entry.getKey();
      if (entry.getKey().getKind() != ElementKind.PACKAGE
          && entry.getValue().size() > MAX_MEMBER_IMPORTS) {
        qualifiedNameFix(fix, owner, state);
      } else {
        for (TypeToImport toImport : entry.getValue()) {
          toImport.addFix(fix);
        }
      }
    }
    return fix.build();
  }
873159
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            stack = new OpcodeStack();
            toStringRegisters = new HashMap<>();
            packageName = classContext.getJavaClass().getPackageName();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            toStringRegisters = null;
        }
    }
802505
void makePackageDoc(PackageSymbol pack, TreePath treePath) {
        PackageDocImpl result = packageMap.get(pack);
        if (result != null) {
            if (treePath != null) result.setTreePath(treePath);
        } else {
            result = new PackageDocImpl(this, pack, treePath);
            packageMap.put(pack, result);
        }
    }
831591
static String fromPackageName(String packageName) {
        List<String> tokens = tokenOf(packageName);
        return fromTokens(tokens);
    }
463208
function(callback) {
    async.waterfall([
      // Make root directory.
      maybeMkdir.bind(null, this.root),

      // Make tmp directory.
      function(done) {
        this.tempdir = path.join(this.root, '.tmp');
        maybeMkdir(this.tempdir, { purge: true }, done);
      }.bind(this),

      // Make directories for each package, package version.
      function(done) {
        var dirs = [];
        for (var package in this.packageToVersions) {
          dirs.push(path.resolve(this.tempdir, package));
          var versions = this.packageToVersions[package];
          for (var version in versions) {
            dirs.push(path.resolve(this.tempdir, package, version));
          }
        }

        async.parallel(dirs.map(function(dir) {
          return maybeMkdir.bind(null, dir);
        }), function(err) {
          return done && done(err);
        });
      }.bind(this)
    ], callback);
  }
1047194
@Override
    public T addPackage(Package pack) throws IllegalArgumentException {
        Validate.notNull(pack, "Pack must be specified");

        return addPackage(pack.getName());
    }
921002
@VisibleForTesting
  static String packageName(String source) {
    try (StringReader r = new StringReader(source)) {
      StreamTokenizer tokenizer = new StreamTokenizer(r);
      tokenizer.slashSlashComments(true);
      tokenizer.slashStarComments(true);
      StringBuilder sb = new StringBuilder();
      boolean inName = false;
      while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
        if (inName) {
          switch (tokenizer.ttype) {
            case ';':
              return sb.length() > 0 ? sb.toString() : null;
            case '.':
              sb.append('.');
              break;
            case StreamTokenizer.TT_WORD:
              sb.append(tokenizer.sval);
              break;
            default:
              inName = false; // Invalid package statement pattern.
              break;
          }
        } else if (tokenizer.ttype == StreamTokenizer.TT_WORD && tokenizer.sval.equals("package")) {
          inName = true;
        }
      }
      return null; // Package statement not found.
    } catch (IOException e) {
      throw new AssertionError("Exception reading string: " + e);
    }
  }
937995
function stopPackage(packageName, cb) {
   var packageRuntime = packageRuntimes[packageName];

   if (isUndefined(packageRuntime) || isUndefined(packageRuntime.process)) {
      cb();
      return;
   }

   if (!isUndefined(packageRuntime.killTimer)) {
      cb(new Error('already attempting to stop package ' + packageName));
      return;
   }

   if (!isUndefined(packageRuntime.startupTimer)) {
      clearTimeout(packageRuntime.startupTimer);
      packageRuntime.startupTimer = null;
   }

   packageRuntime.killedCallback = cb;
   packageRuntime.killTimer = setTimeout(function() {
      packageRuntime.killedCallback = null; 
      packageRuntime.killTimer = null;
      cb(new Error('unable to stop package ' + packageName));
   }, killTimout * 1000);

   packageRuntime.process.kill();
}
1344898
void buildPackagePrefix(final String className) {
        // TODO test
        final int lastPackageSeparator = className.lastIndexOf('/');
        final String packageName = className.substring(0, lastPackageSeparator == -1 ? className.length() : lastPackageSeparator);
        final String[] splitPackage = packageName.split("/");

        if (splitPackage.length >= PROJECT_PACKAGE_HIERARCHIES) {
            projectPackagePrefix = IntStream.range(0, PROJECT_PACKAGE_HIERARCHIES).mapToObj(i -> splitPackage[i]).collect(Collectors.joining("/"));
        } else {
            projectPackagePrefix = packageName;
        }
    }
587900
function dtsBundler() {
  const packageDirectories = fs.readdirSync(D_TS_DIRECTORY);
  packageDirectories.forEach((packageDirectory) => {
    const packagePath = path.join(PACKAGES_DIRECTORY, packageDirectory);
    const name = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8')).name;
    const main = path.join(D_TS_DIRECTORY, packageDirectory, './index.d.ts');
    const isAllInOne = packageDirectory === ALL_IN_ONE_PACKAGE;
    const destBasename = isAllInOne ? packageDirectory : `mdc.${toCamelCase(packageDirectory.replace(/^mdc-/, ''))}`;
    const destFilename = path.join(packagePath, 'dist', `${destBasename}.d.ts`);

    console.log(`Writing UMD declarations in ${destFilename.replace(process.cwd() + '/', '')}`);
    dts.bundle({
      name,
      main,
      out: destFilename,
    });
  });
}
740005
function package(cb) {
    const pkgjson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
    delete pkgjson.scripts;
    delete pkgjson.devDependencies;
    const filepath = './dist/package.json';
    fs.writeFileSync(filepath, JSON.stringify(pkgjson, null, 2), 'utf-8');
    console.log('package.json Copied to Dist Directory');
    cb();
}
572385
private static void extractAndAddPackageInfo(ClassInfo classInfo, Set<String> packages, IndexView indexView) {
        if (classInfo == null) {
            return;
        }

        // Check if we were given an abstract class / interface, in which case we need to check the IndexView to see if there
        // is an implementation or not.
        String className = classInfo.name().toString();
        if (indexView != null) {
            DotName dotName = DotName.createSimple(className);
            if (Modifier.isInterface(classInfo.flags())) {
                indexView.getAllKnownImplementors(dotName).forEach(ci -> extractAndAddPackageInfo(ci, packages, indexView));
            } else if (Modifier.isAbstract(classInfo.flags())) {
                indexView.getAllKnownSubclasses(dotName).forEach(ci -> extractAndAddPackageInfo(ci, packages, indexView));
            }
        }
        StringBuilder builder = new StringBuilder(className).reverse();
        int idx = builder.indexOf(".");
        if (idx != -1) {
            builder.delete(0, idx + 1);
        }
        packages.add(builder.reverse().toString());
    }
467041
public void process(String packageNames) {

		if (packageNames == null) {
			processPackage("", true);
			return;
		}

		String[] pkgs = packageNames.split(",");
		for (int i = 0; i < pkgs.length; i++) {

			String pkg = pkgs[i].trim().replace('.', '/');

			boolean recurse = false;
			if (pkg.endsWith("**")) {
				recurse = true;
				pkg = pkg.substring(0, pkg.length() - 2);
			} else if (pkg.endsWith("*")) {
				recurse = true;
				pkg = pkg.substring(0, pkg.length() - 1);
			}
			
			pkg = trimSlash(pkg);

			processPackage(pkg, recurse);
		}
	}
761243
function (options, dir, callback) {
  var name = _.template('<%= id %>_<%= branch %>_<%= arch %>.flatpak')(options)
  var dest = options.rename(options.dest, name)
  options.logger('Creating package at ' + dest)
  var extraExports = []
  if (options.icon && !_.isObject(options.icon)) extraExports.push(getPixmapPath(options))

  var files = [
    [dir, '/']
  ]
  var symlinks = [
    [path.join('/lib', options.id, options.bin), path.join('/bin', options.bin)]
  ]

  flatpak.bundle({
    id: options.id,
    branch: options.branch,
    base: options.base,
    baseVersion: options.baseVersion,
    baseFlatpakref: options.baseFlatpakref,
    runtime: options.runtime,
    runtimeVersion: options.runtimeVersion,
    runtimeFlatpakref: options.runtimeFlatpakref,
    sdk: options.sdk,
    sdkFlatpakref: options.sdkFlatpakref,
    finishArgs: options.finishArgs,
    command: options.bin,
    files: files.concat(options.files),
    symlinks: symlinks.concat(options.symlinks),
    extraExports: extraExports,
    modules: options.modules
  }, {
    arch: options.arch,
    bundlePath: dest
  }, function (err) {
    callback(err, dir)
  })
}
1249560
public String build(final InternalKnowledgePackage pkg,
                        final FunctionDescr functionDescr,
                        final TypeResolver typeResolver,
                        final Map<String, LineMappings> lineMappings,
                        final List<KnowledgeBuilderResult> errors) {

        final Map<String, Object> vars = new HashMap<String, Object>();

        vars.put("package",
                 pkg.getName());

        vars.put("imports",
                 pkg.getImports().keySet());

        final List<String> staticImports = new LinkedList<String>();
        for (String staticImport : pkg.getStaticImports()) {
            if (!staticImport.endsWith(functionDescr.getName())) {
                staticImports.add(staticImport);
            }
        }

        vars.put("staticImports",
                 staticImports);

        vars.put("className",
                 StringUtils.ucFirst(functionDescr.getName()));

        vars.put("methodName",
                 functionDescr.getName());

        vars.put("returnType",
                 functionDescr.getReturnType());

        vars.put("parameterTypes",
                 functionDescr.getParameterTypes());

        vars.put("parameterNames",
                 functionDescr.getParameterNames());

        vars.put("hashCode",
                 functionDescr.getText().hashCode());

        // Check that all the parameters are resolvable
        final List<String> names = functionDescr.getParameterNames();
        final List<String> types = functionDescr.getParameterTypes();
        for (int i = 0, size = names.size(); i < size; i++) {
            try {
                typeResolver.resolveType(types.get(i));
            } catch (final ClassNotFoundException e) {
                errors.add(new FunctionError(functionDescr,
                                             e,
                                             "Unable to resolve type " + types.get(i) + " while building function."));
                break;
            }
        }

        vars.put("text",
                 functionDescr.getText());

        final String text = String.valueOf(TemplateRuntime.eval(template, null, new MapVariableResolverFactory(vars)));

        final BufferedReader reader = new BufferedReader(new StringReader(text));
        final String lineStartsWith = "    public static " + functionDescr.getReturnType() + " " + functionDescr.getName();
        try {
            String line;
            int offset = 0;
            while ((line = reader.readLine()) != null) {
                offset++;
                if (line.startsWith(lineStartsWith)) {
                    break;
                }
            }
            functionDescr.setOffset(offset);
        } catch (final IOException e) {
            // won't ever happen, it's just reading over a string.
            throw new RuntimeException("Error determining start offset with function");
        }

        final String name = pkg.getName() + "." + StringUtils.ucFirst(functionDescr.getName());
        final LineMappings mapping = new LineMappings(name);
        mapping.setStartLine(functionDescr.getLine());
        mapping.setOffset(functionDescr.getOffset());
        lineMappings.put(name,
                         mapping);

        return text;
    }