Esempio n. 1
0
 private static PackageFragment defaultPackage(IProject proj) {
   IJavaProject jp = JavaCore.create(proj);
   try {
     IPackageFragment[] packageFragments = jp.getPackageFragments();
     for (IPackageFragment frag : packageFragments) {
       if (frag.getElementName().equals(DEFAULT_PACKAGE_NAME)) return (PackageFragment) frag;
     }
     return null;
   } catch (JavaModelException e) {
     e.printStackTrace();
     System.out.printf("Yikes!%n");
     return null;
   }
 }
Esempio n. 2
0
 private IStatus validateClassFile() {
   IPackageFragmentRoot root = getPackageFragmentRoot();
   try {
     if (root.getKind() != IPackageFragmentRoot.K_BINARY)
       return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root);
   } catch (JavaModelException e) {
     return e.getJavaModelStatus();
   }
   IJavaProject project = getJavaProject();
   return JavaConventions.validateClassFileName(
       getElementName(),
       project.getOption(JavaCore.COMPILER_SOURCE, true),
       project.getOption(JavaCore.COMPILER_COMPLIANCE, true));
 }