org.eclipse.jdt.internal.core.util.Util.getPackageFragment()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.eclipse.jdt.internal.core.util.Util.getPackageFragment()方法的一些代码示例,展示了Util.getPackageFragment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getPackageFragment()方法的具体详情如下:
包路径:org.eclipse.jdt.internal.core.util.Util
类名称:Util
方法名:getPackageFragment

Util.getPackageFragment介绍

暂无

代码示例

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg == null) return null;
  int start;
  ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
  if (workingCopyOwner != null) {
    ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
    if (workingCopy != null)
      return workingCopy;
  }
  return cu;
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.lastIndexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

private static IClassFile getClassFile(char[] fileName) {
  int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
  int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
  if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
    pkgEnd = jarSeparator;
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
  if (pkg == null) return null;
  int start;
  return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start));
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg == null) return null;
  int start;
  ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
  if (workingCopyOwner != null) {
    ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
    if (workingCopy != null)
      return workingCopy;
  }
  return cu;
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg == null) return null;
  int start;
  ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
  if (workingCopyOwner != null) {
    ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
    if (workingCopy != null)
      return workingCopy;
  }
  return cu;
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg == null) return null;
  int start;
  ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
  if (workingCopyOwner != null) {
    ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
    if (workingCopy != null)
      return workingCopy;
  }
  return cu;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg == null) return null;
  int start;
  ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
  if (workingCopyOwner != null) {
    ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
    if (workingCopy != null)
      return workingCopy;
  }
  return cu;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg == null) return null;
  int start;
  ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
  if (workingCopyOwner != null) {
    ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
    if (workingCopy != null)
      return workingCopy;
  }
  return cu;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
  char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
  int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
  if (pkgEnd == -1)
    return null;
  IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
  if (pkg != null) {
    int start;
    ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
    if (workingCopyOwner != null) {
      ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
      if (workingCopy != null)
        return workingCopy;
    }
    return cu;
  }
  IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
  IFile file = wsRoot.getFile(new Path(String.valueOf(fileName)));
  if (file.exists()) {
    // this approach works if file exists but is not on the project's build path:
    return JavaCore.createCompilationUnitFrom(file);
  }
  return null;
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

if (pkgEnd == -1)
  return null;
IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
char[] constantPoolName = referenceBinding.constantPoolName();
if (constantPoolName == null) {

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

if (pkgEnd == -1)
  return null;
IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
char[] constantPoolName = referenceBinding.constantPoolName();
if (constantPoolName == null) {

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

if (pkgEnd == -1)
  return null;
IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
char[] constantPoolName = referenceBinding.constantPoolName();
if (constantPoolName == null) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

if (pkgEnd == -1)
  return null;
IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
char[] constantPoolName = referenceBinding.constantPoolName();
if (constantPoolName == null) {

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

if (pkgEnd == -1)
  return null;
IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
char[] constantPoolName = referenceBinding.constantPoolName();
if (constantPoolName == null) {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

if (pkgEnd == -1)
  return null;
IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
char[] constantPoolName = referenceBinding.constantPoolName();
if (constantPoolName == null) {

相关文章

微信公众号

最新文章

更多

Util类方法