@Override public void run() { if (uniqueStr == null) return; String[] linkParts = uniqueStr.split("\\|"); if (linkParts.length <= 1) return; String destinationTypeStr = linkParts[1]; try { bar.setVisible(true); getLabel().setText("Navigating: " + destinationTypeStr.replaceAll("/", ".")); TypeReference type = metadataSystem.lookupType(destinationTypeStr); if (type == null) throw new RuntimeException("Cannot lookup type: " + destinationTypeStr); TypeDefinition typeDef = type.resolve(); if (typeDef == null) throw new RuntimeException("Cannot resolve type: " + destinationTypeStr); String tabTitle = typeDef.getName() + ".class"; extractClassToTextPane(typeDef, tabTitle, destinationTypeStr, uniqueStr); getLabel().setText("Complete"); } catch (Exception e) { getLabel().setText("Cannot navigate: " + destinationTypeStr.replaceAll("/", ".")); Luyten.showExceptionDialog("Cannot Navigate!", e); } finally { bar.setVisible(false); } } }).start();
String constructorName = typeDef.getName(); TypeReference declaringTypeRef = typeRef.getDeclaringType(); if (declaringTypeRef != null) { TypeDefinition declaringTypeDef = declaringTypeRef.resolve(); if (declaringTypeDef != null) { String declaringTypeName = declaringTypeDef.getName(); if (declaringTypeName != null) { constructorName = StringUtilities.removeLeft(constructorName, declaringTypeName);
definitionToSelectionMap = new HashMap<>(); referenceToSelectionsMap = new HashMap<>(); currentTypeQualifiedName = type.getPackageName() + "." + type.getName(); final StringWriter stringwriter = new StringWriter(); PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter) {
@Override public String getSimpleName() { return _simpleName != null ? _simpleName : getName(); }
@Override public String getSimpleName() { return _simpleName != null ? _simpleName : getName(); }
@Override public String getSimpleName() { return _simpleName != null ? _simpleName : getName(); }
@Override public String getName() { final String name = super.getName(); if (!StringUtilities.isNullOrEmpty(name)) { return name; } return "T" + _position; }
@Override public String getName() { final String name = super.getName(); if (!StringUtilities.isNullOrEmpty(name)) { return name; } return "T" + _position; }
@Override public String getName() { final String name = super.getName(); if (!StringUtilities.isNullOrEmpty(name)) { return name; } return "T" + _position; }
static TypeDefinition getNestedType(final List<TypeDefinition> candidates, final TypeReference reference) { for (int i = 0, n = candidates.size(); i < n; i++) { final TypeDefinition candidate = candidates.get(i); if (StringComparator.Ordinal.equals(candidate.getName(), reference.getName())) { return candidate; } } return null; }
static TypeDefinition getNestedType(final List<TypeDefinition> candidates, final TypeReference reference) { for (int i = 0, n = candidates.size(); i < n; i++) { final TypeDefinition candidate = candidates.get(i); if (StringComparator.Ordinal.equals(candidate.getName(), reference.getName())) { return candidate; } } return null; }
static TypeDefinition getNestedType(final List<TypeDefinition> candidates, final TypeReference reference) { for (int i = 0, n = candidates.size(); i < n; i++) { final TypeDefinition candidate = candidates.get(i); if (StringComparator.Ordinal.equals(candidate.getName(), reference.getName())) { return candidate; } } return null; }
@MethodVisitor public boolean check(MethodDefinition md, TypeDefinition td) { // Skip some autogenerated methods if(md.getName().equals("yyparse") && md.getReturnType().getInternalName().equals("java/lang/Object")) return false; if(md.getName().startsWith("jj") && td.getName().endsWith("TokenManager")) return false; if(md.getName().equals("getNextToken") && md.getSignature().equals("()I")) return false; return true; }
/** * 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); }
final TypeDefinition gp = tp.getUserData(Keys.TYPE_DEFINITION); if (gp != null && StringUtilities.equals(gp.getName(), name)) { if (results == null) { results = new LinkedHashSet<>();
private ConstructorDeclaration createConstructor(final MethodDefinition method) { final ConstructorDeclaration astMethod = new ConstructorDeclaration(); EntityDeclaration.setModifiers( astMethod, Flags.asModifierSet(scrubAccessModifiers(method.getFlags() & Flags.ConstructorFlags)) ); astMethod.setName(method.getDeclaringType().getName()); astMethod.getParameters().addAll(createParameters(method.getParameters())); astMethod.setBody(createMethodBody(method, astMethod.getParameters())); astMethod.putUserData(Keys.METHOD_DEFINITION, method); astMethod.putUserData(Keys.MEMBER_REFERENCE, method); for (final TypeReference thrownType : method.getThrownTypes()) { astMethod.addChild(convertType(thrownType), Roles.THROWN_TYPE); } return astMethod; }
output.writeReference(method.getDeclaringType().getName(), method.getDeclaringType());
private ConstructorDeclaration createConstructor(final MethodDefinition method) { final ConstructorDeclaration astMethod = new ConstructorDeclaration(); EntityDeclaration.setModifiers( astMethod, Flags.asModifierSet(scrubAccessModifiers(method.getFlags() & Flags.ConstructorFlags)) ); astMethod.setName(method.getDeclaringType().getName()); astMethod.getParameters().addAll(createParameters(method.getParameters())); astMethod.setBody(createMethodBody(method, astMethod.getParameters())); astMethod.putUserData(Keys.METHOD_DEFINITION, method); astMethod.putUserData(Keys.MEMBER_REFERENCE, method); for (final TypeReference thrownType : method.getThrownTypes()) { astMethod.addChild(convertType(thrownType), Roles.THROWN_TYPE); } return astMethod; }
private ConstructorDeclaration createConstructor(final MethodDefinition method) { final ConstructorDeclaration astMethod = new ConstructorDeclaration(); EntityDeclaration.setModifiers( astMethod, Flags.asModifierSet(scrubAccessModifiers(method.getFlags() & Flags.ConstructorFlags)) ); astMethod.setName(method.getDeclaringType().getName()); astMethod.getParameters().addAll(createParameters(method.getParameters())); astMethod.getTypeParameters().addAll(createTypeParameters(method.getGenericParameters())); astMethod.setBody(createMethodBody(method, astMethod.getParameters())); astMethod.putUserData(Keys.METHOD_DEFINITION, method); astMethod.putUserData(Keys.MEMBER_REFERENCE, method); for (final CustomAnnotation annotation : method.getAnnotations()) { astMethod.getAnnotations().add(createAnnotation(annotation)); } for (final TypeReference thrownType : method.getThrownTypes()) { astMethod.addChild(convertType(thrownType), Roles.THROWN_TYPE); } return astMethod; }