definitionToSelectionMap = new HashMap<>(); referenceToSelectionsMap = new HashMap<>(); currentTypeQualifiedName = type.getPackageName() + "." + type.getName(); final StringWriter stringwriter = new StringWriter(); PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter) {
/** * Constructs the path from FQCN, validates writability, and creates a writer. */ private static synchronized FileOutputWriter createFileWriter(final TypeDefinition type, final DecompilerSettings settings) throws IOException { final String outputDirectory = settings.getOutputDirectory(); final String fileName = type.getName() + settings.getLanguage().getFileExtension(); final String packageName = type.getPackageName(); // foo.Bar -> foo/Bar.java final String subDir = StringUtils.defaultIfEmpty(packageName, "").replace('.', File.separatorChar); final String outputPath = PathHelper.combine(outputDirectory, subDir, fileName); final File outputFile = new File(outputPath); final File parentDir = outputFile.getParentFile(); if (parentDir != null && !parentDir.exists() && !parentDir.mkdirs()) { throw new IllegalStateException("Could not create directory:" + parentDir); } if (!outputFile.exists() && !outputFile.createNewFile()) { throw new IllegalStateException("Could not create output file: " + outputPath); } return new FileOutputWriter(outputFile, settings); }
/** * Constructs the path from FQCN, validates writability, and creates a writer. */ private static synchronized FileOutputWriter createFileWriter(final TypeDefinition type, final DecompilerSettings settings) throws IOException { final String outputDirectory = settings.getOutputDirectory(); final String fileName = type.getName() + settings.getLanguage().getFileExtension(); final String packageName = type.getPackageName(); // foo.Bar -> foo/Bar.java final String subDir = StringUtils.defaultIfEmpty(packageName, "").replace('.', File.separatorChar); final String outputPath = PathHelper.combine(outputDirectory, subDir, fileName); final File outputFile = new File(outputPath); final File parentDir = outputFile.getParentFile(); if (parentDir != null && !parentDir.exists() && !parentDir.mkdirs()) { throw new IllegalStateException("Could not create directory:" + parentDir); } if (!outputFile.exists() && !outputFile.createNewFile()) { throw new IllegalStateException("Could not create output file: " + outputPath); } return new FileOutputWriter(outputFile, settings); }
void link(MethodDefinition src, FieldReference fr, boolean isStatic, boolean write, boolean hadNull) { if(fieldRecords == null) return; int prevStatus = fieldRecords.getOrDefault(fr.getName(), 0); int curStatus = prevStatus; if(src.getDeclaringType().isEquivalentTo(fr.getDeclaringType())) { if(write && (src.isConstructor() && !isStatic || src.isTypeInitializer() && isStatic)) { curStatus |= WRITE_CONSTRUCTOR; } else { curStatus |= write ? WRITE_CLASS : READ_CLASS; } } else if(src.getDeclaringType().getPackageName().equals(fr.getDeclaringType().getPackageName())) { curStatus |= write ? WRITE_PACKAGE : READ_PACKAGE; } else { curStatus |= write ? WRITE_OUTSIDE : READ_OUTSIDE; } if(write && !hadNull) { curStatus |= WRITE_NONNULL; } if(prevStatus != curStatus) { fieldRecords.put(fr.getName(), curStatus); } } }
public final void addType(final TypeDefinition type) { final TypeDeclaration astType = createType(type); final String packageName = type.getPackageName(); if (_compileUnit.getPackage().isNull() && !StringUtilities.isNullOrWhitespace(packageName)) { _compileUnit.insertChildBefore( _packagePlaceholder, new PackageDeclaration(packageName), Roles.PACKAGE ); _packagePlaceholder.remove(); } _compileUnit.addChild(astType, CompilationUnit.TYPE_ROLE); }
public final void addType(final TypeDefinition type) { final TypeDeclaration astType = createType(type); final String packageName = type.getPackageName(); if (_compileUnit.getPackage().isNull() && !StringUtilities.isNullOrWhitespace(packageName)) { _compileUnit.insertChildBefore( _packagePlaceholder, new PackageDeclaration(packageName), Roles.PACKAGE ); _packagePlaceholder.remove(); } _compileUnit.addChild(astType, CompilationUnit.MEMBER_ROLE); }
public final void addType(final TypeDefinition type) { final TypeDeclaration astType = createType(type); final String packageName = type.getPackageName(); if (_compileUnit.getPackage().isNull() && !StringUtilities.isNullOrWhitespace(packageName)) { _compileUnit.insertChildBefore( _packagePlaceholder, new PackageDeclaration(packageName), Roles.PACKAGE ); _packagePlaceholder.remove(); } _compileUnit.addChild(astType, CompilationUnit.MEMBER_ROLE); }
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName();
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName();
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName();
final TypeReference declaringType = method.getDeclaringType(); if (StringUtilities.equals(declaringType.getPackageName(), context.getCurrentType().getPackageName()) && !MetadataResolver.areEquivalent(context.getCurrentType(), declaringType) && !MetadataHelper.isEnclosedBy(context.getCurrentType(), declaringType) &&