packageSegments.retainAll(JSweetConfig.TS_TOP_LEVEL_KEYWORDS); if (!packageSegments.isEmpty()) { report(topLevel.getPackageName(), JSweetProblem.PACKAGE_NAME_CONTAINS_KEYWORD, packageSegments);
public void printImportsBlock(java.util.List<? extends JCTree> imports, boolean maybeAppendNewLine) { boolean hasImports = !imports.isEmpty(); CodeStyle.ImportGroups importGroups = null; if (hasImports) { blankLines(Math.max(cs.getBlankLinesBeforeImports(), diffContext.origUnit.getPackageName() != null ? cs.getBlankLinesAfterPackage() : 0)); if (cs.separateImportGroups()) importGroups = cs.getImportGroups(); } int lastGroup = -1; for (JCTree importStat : imports) { if (importGroups != null) { Name name = fullName(((JCImport)importStat).qualid); int group = name != null ? importGroups.getGroupId(name.toString(), ((JCImport)importStat).staticImport) : -1; if (lastGroup >= 0 && lastGroup != group) blankline(); lastGroup = group; } printStat(importStat); newline(); } if (hasImports && maybeAppendNewLine) { blankLines(cs.getBlankLinesAfterImports()); } }
public static ImportStatements create( JCCompilationUnit compilationUnit, ImportOrganizer importOrganizer) { return new ImportStatements( (JCExpression) compilationUnit.getPackageName(), compilationUnit.getImports(), compilationUnit.endPositions, importOrganizer); }
private boolean checkRootPackageParent(JCCompilationUnit topLevel, PackageSymbol rootPackage, PackageSymbol parentPackage) { if (parentPackage == null) { return true; } if (!context.options.isNoRootDirectories() || context.options.isBundle()) { return true; } if (context.isRootPackage(parentPackage)) { report(topLevel.getPackageName(), JSweetProblem.ENCLOSED_ROOT_PACKAGES, rootPackage.getQualifiedName().toString(), parentPackage.getQualifiedName().toString()); return false; } for (Symbol s : parentPackage.getEnclosedElements()) { if (s instanceof ClassSymbol) { if (Util.isSourceElement(s)) { report(topLevel.getPackageName(), JSweetProblem.CLASS_OUT_OF_ROOT_PACKAGE_SCOPE, s.getQualifiedName().toString(), rootPackage.getQualifiedName().toString()); return false; } } } return checkRootPackageParent(topLevel, rootPackage, (PackageSymbol) parentPackage.owner); }
public static ImportStatements create( JCCompilationUnit compilationUnit, ImportOrganizer importOrganizer) { return new ImportStatements( (JCExpression) compilationUnit.getPackageName(), compilationUnit.getImports(), compilationUnit.endPositions, importOrganizer); }