List of usage examples for org.eclipse.jdt.internal.core.util Messages build_inconsistentClassFile
String build_inconsistentClassFile
To view the source code for org.eclipse.jdt.internal.core.util Messages build_inconsistentClassFile.
Click Source Link
From source file:net.sf.j2s.core.builder.AbstractImageBuilder.java
License:Open Source License
public void acceptResult(CompilationResult result) { // In Batch mode, we write out the class files, hold onto the dependency info // & additional types and report problems. // In Incremental mode, when writing out a class file we need to compare it // against the previous file, remembering if structural changes occured. // Before reporting the new problems, we need to update the problem count & // remove the old problems. Plus delete additional class files that no longer exist. SourceFile compilationUnit = (SourceFile) result.getCompilationUnit(); // go directly back to the sourceFile if (!this.workQueue.isCompiled(compilationUnit)) { this.workQueue.finished(compilationUnit); try {/*from w ww . j a v a 2s.c o m*/ updateProblemsFor(compilationUnit, result); // record compilation problems before potentially adding duplicate errors updateTasksFor(compilationUnit, result); // record tasks } catch (CoreException e) { throw internalException(e); } if (result.hasInconsistentToplevelHierarchies) // ensure that this file is always retrieved from source for the rest of the build if (!this.problemSourceFiles.contains(compilationUnit)) this.problemSourceFiles.add(compilationUnit); IType mainType = null; String mainTypeName = null; String typeLocator = compilationUnit.typeLocator(); ClassFile[] classFiles = result.getClassFiles(); int length = classFiles.length; ArrayList duplicateTypeNames = null; ArrayList definedTypeNames = new ArrayList(length); for (int i = 0; i < length; i++) { ClassFile classFile = classFiles[i]; char[][] compoundName = classFile.getCompoundName(); char[] typeName = compoundName[compoundName.length - 1]; boolean isNestedType = classFile.isNestedType; // Look for a possible collision, if one exists, report an error but do not write the class file if (isNestedType) { String qualifiedTypeName = new String(classFile.outerMostEnclosingClassFile().fileName()); if (this.newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) continue; } else { String qualifiedTypeName = new String(classFile.fileName()); // the qualified type name "p1/p2/A" if (this.newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) { if (duplicateTypeNames == null) duplicateTypeNames = new ArrayList(); duplicateTypeNames.add(compoundName); if (mainType == null) { try { mainTypeName = compilationUnit.initialTypeName; // slash separated qualified name "p1/p1/A" mainType = this.javaBuilder.javaProject.findType(mainTypeName.replace('/', '.')); } catch (JavaModelException e) { // ignore } } IType type; if (qualifiedTypeName.equals(mainTypeName)) { type = mainType; } else { String simpleName = qualifiedTypeName.substring(qualifiedTypeName.lastIndexOf('/') + 1); type = mainType == null ? null : mainType.getCompilationUnit().getType(simpleName); } createProblemFor(compilationUnit.resource, type, Messages.bind(Messages.build_duplicateClassFile, new String(typeName)), JavaCore.ERROR); continue; } this.newState.recordLocatorForType(qualifiedTypeName, typeLocator); if (result.checkSecondaryTypes && !qualifiedTypeName.equals(compilationUnit.initialTypeName)) acceptSecondaryType(classFile); } try { definedTypeNames.add(writeClassFile(classFile, compilationUnit, !isNestedType)); } catch (CoreException e) { Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$ if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) createProblemFor(compilationUnit.resource, null, Messages.bind(Messages.build_classFileCollision, e.getMessage()), JavaCore.ERROR); else createProblemFor(compilationUnit.resource, null, Messages.build_inconsistentClassFile, JavaCore.ERROR); } } if (result.hasAnnotations && this.filesWithAnnotations != null) // only initialized if an annotation processor is attached this.filesWithAnnotations.add(compilationUnit); this.compiler.lookupEnvironment.releaseClassFiles(classFiles); finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames); this.notifier.compiled(compilationUnit); } }