@Nullable public static Label createLabelFromString(@Nullable BuildFile file,@Nullable String labelString){
  if (labelString == null) {
    return null;
  }
  int colonIndex=labelString.indexOf(':');
  if (labelString.startsWith("//")) {
    if (colonIndex == -1) {
      labelString+=":" + PathUtil.getFileName(labelString);
    }
    return Label.createIfValid(labelString);
  }
  WorkspacePath packagePath=file != null ? file.getPackageWorkspacePath() : null;
  if (packagePath == null) {
    return null;
  }
  String localPath=colonIndex == -1 ? labelString : labelString.substring(1);
  return Label.createIfValid("//" + packagePath.relativePath() + ":"+ localPath);
}

@ Nullable public static Label createLabelFromString ( @ Nullable BuildFile file , @ Nullable String labelString ) { if ( labelString == null ) { return null ; } int colonIndex = labelString . indexOf ( ':' ) ; if ( labelString . startsWith ( "//" ) ) { if ( colonIndex == - 1 ) { labelString += ":" + PathUtil . getFileName ( labelString ) ; } return Label . createIfValid ( labelString ) ; } WorkspacePath packagePath = file != null ? file . getPackageWorkspacePath ( ) : null ; if ( packagePath == null ) { return null ; } String localPath = colonIndex == - 1 ? labelString : labelString . substring ( 1 ) ; return Label . createIfValid ( "//" + packagePath . relativePath ( ) + ":" + localPath ) ; }
canonicalizes the label ( to the form / / packagepath : packagerelativetarget ) . returns null if the string does not represent a valid label .
