/** * @see ICodeSnippetRequestor */ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { int length = classFiles.length; byte[][] classFileBytes = new byte[length][]; String[][] compoundNames = new String[length][]; for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; classFileBytes[i] = classFile.getBytes(); char[][] classFileCompundName = classFile.getCompoundName(); int length2 = classFileCompundName.length; String[] compoundName = new String[length2]; for (int j = 0; j < length2; j++){ compoundName[j] = new String(classFileCompundName[j]); } compoundNames[i] = compoundName; } return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName)); } /**
/** * @see ICodeSnippetRequestor */ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { int length = classFiles.length; byte[][] classFileBytes = new byte[length][]; String[][] compoundNames = new String[length][]; for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; classFileBytes[i] = classFile.getBytes(); char[][] classFileCompundName = classFile.getCompoundName(); int length2 = classFileCompundName.length; String[] compoundName = new String[length2]; for (int j = 0; j < length2; j++){ compoundName[j] = new String(classFileCompundName[j]); } compoundNames[i] = compoundName; } return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName)); } /**
/** * @see ICodeSnippetRequestor */ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { int length = classFiles.length; byte[][] classFileBytes = new byte[length][]; String[][] compoundNames = new String[length][]; for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; classFileBytes[i] = classFile.getBytes(); char[][] classFileCompundName = classFile.getCompoundName(); int length2 = classFileCompundName.length; String[] compoundName = new String[length2]; for (int j = 0; j < length2; j++){ compoundName[j] = new String(classFileCompundName[j]); } compoundNames[i] = compoundName; } return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName)); } /**
/** * @see ICodeSnippetRequestor */ @Override public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { int length = classFiles.length; byte[][] classFileBytes = new byte[length][]; String[][] compoundNames = new String[length][]; for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; classFileBytes[i] = classFile.getBytes(); char[][] classFileCompundName = classFile.getCompoundName(); int length2 = classFileCompundName.length; String[] compoundName = new String[length2]; for (int j = 0; j < length2; j++){ compoundName[j] = new String(classFileCompundName[j]); } compoundNames[i] = compoundName; } return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName)); } /**
/** * @see ICodeSnippetRequestor */ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { int length = classFiles.length; byte[][] classFileBytes = new byte[length][]; String[][] compoundNames = new String[length][]; for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; classFileBytes[i] = classFile.getBytes(); char[][] classFileCompundName = classFile.getCompoundName(); int length2 = classFileCompundName.length; String[] compoundName = new String[length2]; for (int j = 0; j < length2; j++){ compoundName[j] = new String(classFileCompundName[j]); } compoundNames[i] = compoundName; } return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName)); } /**
/** * @see ICodeSnippetRequestor */ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { int length = classFiles.length; byte[][] classFileBytes = new byte[length][]; String[][] compoundNames = new String[length][]; for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; classFileBytes[i] = classFile.getBytes(); char[][] classFileCompundName = classFile.getCompoundName(); int length2 = classFileCompundName.length; String[] compoundName = new String[length2]; for (int j = 0; j < length2; j++){ compoundName[j] = new String(classFileCompundName[j]); } compoundNames[i] = compoundName; } return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName)); } /**
private static Map<String, byte[]> classes(final CompilationResult result) { final Map<String, byte[]> classes = new HashMap<String, byte[]>(); if (!result.hasErrors()) { for (final ClassFile cls : result.getClassFiles()) { final String className = CharOperation .toString(cls.getCompoundName()); classes.put(className, cls.getBytes()); } } return classes; }
public void acceptResult(CompilationResult result) { boolean hasErrors = false; if (result.hasProblems()) { problems = result.getProblems(); } if (!hasErrors) { ClassFile[] classFiles = result.getClassFiles(); for (int i = 0; i < classFiles.length; i++) { ClassFile classFile = classFiles[i]; char[][] compoundName = classFile.getCompoundName(); StringBuilder className = new StringBuilder(); String sep = ""; for (int j = 0; j < compoundName.length; j++) { className.append(sep); className.append(new String(compoundName[j])); sep = "."; } byte[] bytes = classFile.getBytes(); compiledClassFiles.put(className.toString(), bytes); } } } }
public void acceptResult( org.eclipse.jdt.internal.compiler.CompilationResult result ) { if (result.hasProblems()) { if (result.hasErrors()) hasErrors = true; problems.addAll(Arrays.asList((IProblem[]) result.getProblems())); } if (!result.hasErrors()) { ClassFile[] clazzFiles = result.getClassFiles(); for (ClassFile clazzFile : clazzFiles) { char[][] compoundName = clazzFile.getCompoundName(); StringBuffer clazzName = new StringBuffer(); for (char[] part : compoundName) { if (clazzName.length() > 0) { clazzName.append('.'); } clazzName.append(part); } byteCode.put(clazzName.toString(), clazzFile.getBytes()); } } } }
public void acceptResult( final CompilationResult pResult ) { if (pResult.hasProblems()) { for (IProblem iproblem : pResult.getProblems()) { final CompilationProblem problem = new EclipseCompilationProblem(iproblem); if (problemHandler != null) { problemHandler.handle(problem); } problems.add(problem); } } if (!pResult.hasErrors()) { final ClassFile[] clazzFiles = pResult.getClassFiles(); for (ClassFile clazzFile : clazzFiles) { final char[][] compoundName = clazzFile.getCompoundName(); final StringBuilder clazzName = new StringBuilder(); for (int j = 0; j < compoundName.length; j++) { if (j != 0) { clazzName.append('.'); } clazzName.append(compoundName[j]); } pStore.write(clazzName.toString().replace('.', '/') + ".class", clazzFile.getBytes()); } } } };
public void acceptResult( final CompilationResult pResult ) { if (pResult.hasProblems()) { final IProblem[] iproblems = pResult.getProblems(); for (int i = 0; i < iproblems.length; i++) { final IProblem iproblem = iproblems[i]; final CompilationProblem problem = new EclipseCompilationProblem(iproblem); if (problemHandler != null) { problemHandler.handle(problem); } problems.add(problem); } } if (!pResult.hasErrors()) { final ClassFile[] clazzFiles = pResult.getClassFiles(); for (int i = 0; i < clazzFiles.length; i++) { final ClassFile clazzFile = clazzFiles[i]; final char[][] compoundName = clazzFile.getCompoundName(); final StringBuilder clazzName = new StringBuilder(); for (int j = 0; j < compoundName.length; j++) { if (j != 0) { clazzName.append('.'); } clazzName.append(compoundName[j]); } pStore.write(clazzName.toString().replace('.', '/') + ".class", clazzFile.getBytes()); } } } };
private void writeClassFile(Resource<File> input, String relativeStringName, ClassFile classFile) throws IOException { final byte[] bytes = classFile.getBytes(); final File outputFile = new File(getOutputDirectory(), relativeStringName); // context.associatedOutput resets output attributes set during earlier iterations of this incremental compile // so deal with classfile digest before context.associatedOutput final byte[] oldHash = context.getAttribute(outputFile, ATTR_CLASS_DIGEST, byte[].class); final byte[] hash = digestClassFile(outputFile, bytes); boolean significantChange = oldHash == null || hash == null || !Arrays.equals(hash, oldHash); final Output<File> output = context.associatedOutput(input, outputFile); if (hash != null) { // TODO evaluate if this is useful // trade-off is between storing digest on disk between builds // and recomputing the hash each time class files are written context.setAttribute(outputFile, ATTR_CLASS_DIGEST, hash); } if (significantChange) { // find all sources that reference this type and put them into work queue strategy.addDependentsOf(CharOperation.toString(classFile.getCompoundName())); } try (final BufferedOutputStream os = new BufferedOutputStream(output.newOutputStream())) { os.write(bytes); os.flush(); } }
private void writeClassFile(Resource<File> input, String relativeStringName, ClassFile classFile) throws IOException { final byte[] bytes = classFile.getBytes(); final File outputFile = new File(getOutputDirectory(), relativeStringName); // context.associatedOutput resets output attributes set during earlier iterations of this incremental compile // so deal with classfile digest before context.associatedOutput final byte[] oldHash = context.getAttribute(outputFile, ATTR_CLASS_DIGEST, byte[].class); final byte[] hash = digestClassFile(outputFile, bytes); boolean significantChange = oldHash == null || hash == null || !Arrays.equals(hash, oldHash); final Output<File> output = context.associatedOutput(input, outputFile); if (hash != null) { // TODO evaluate if this is useful // trade-off is between storing digest on disk between builds // and recomputing the hash each time class files are written context.setAttribute(outputFile, ATTR_CLASS_DIGEST, hash); } if (significantChange) { // find all sources that reference this type and put them into work queue strategy.addDependentsOf(CharOperation.toString(classFile.getCompoundName())); } try (final BufferedOutputStream os = new BufferedOutputStream(output.newOutputStream())) { os.write(bytes); os.flush(); } }
for (int i = 0; i < clazzFiles.length; i++) { final ClassFile clazzFile = clazzFiles[i]; final char[][] compoundName = clazzFile.getCompoundName(); final StringBuffer clazzName = new StringBuffer(); for (int j = 0; j < compoundName.length; j++) {
public void acceptResult(CompilationResult result) { if (result.hasProblems()) { if (pProblemHandler != null) { final IProblem[] problems = result.getProblems(); for (int i = 0; i < problems.length; i++) { final IProblem problem = problems[i]; pProblemHandler.handle(new EclipseCompilationProblem(problem)); } } } if (!result.hasErrors()) { final ClassFile[] clazzFiles = result.getClassFiles(); for (int i = 0; i < clazzFiles.length; i++) { final ClassFile clazzFile = clazzFiles[i]; final char[][] compoundName = clazzFile.getCompoundName(); final StringBuffer clazzName = new StringBuffer(); for (int j = 0; j < compoundName.length; j++) { if (j != 0) { clazzName.append('.'); } clazzName.append(compoundName[j]); } pStore.write(clazzName.toString(), clazzFile.getBytes()); } } } };
for (int i = 0; i < clazzFiles.length; i++) { ClassFile clazzFile = clazzFiles[i]; char[][] compoundName = clazzFile.getCompoundName(); StringBuilder clazzName = new StringBuilder(); for (int j = 0; j < compoundName.length; j++) {
for (int i = 0; i < classFiles.length; i++) { ClassFile classFile = classFiles[i]; if (CharOperation.equals(compoundTypeName, classFile.getCompoundName())) { ClassFileReader binary = null; try {
for (int i = 0; i < classFiles.length; i++) { ClassFile classFile = classFiles[i]; if (CharOperation.equals(compoundTypeName, classFile.getCompoundName())) { ClassFileReader binary = null; try {
for (int i = 0; i < classFiles.length; i++) { ClassFile classFile = classFiles[i]; String className = CharOperation.toString(classFile.getCompoundName()); try { this.write(className, classFile.getBytes());
for (int i = 0; i < classFiles.length; i++) { ClassFile classFile = classFiles[i]; if (CharOperation.equals(compoundTypeName, classFile.getCompoundName())) { ClassFileReader binary = null; try {