private Optional<XmlDocument> merge( @NonNull Optional<XmlDocument> xmlDocument, @NonNull LoadedManifestInfo lowerPriorityDocument, @NonNull MergingReport.Builder mergingReportBuilder) throws MergeFailureException { MergingReport.Result validationResult = PreValidator .validate(mergingReportBuilder, lowerPriorityDocument.getXmlDocument()); if (validationResult == MergingReport.Result.ERROR) { mergingReportBuilder.addMessage( lowerPriorityDocument.getXmlDocument().getSourceFile(), MergingReport.Record.Severity.ERROR, "Validation failed, exiting"); return Optional.absent(); } Optional<XmlDocument> result; if (xmlDocument.isPresent()) { result = xmlDocument.get().merge( lowerPriorityDocument.getXmlDocument(), mergingReportBuilder); } else { mergingReportBuilder.getActionRecorder().recordDefaultNodeAction( lowerPriorityDocument.getXmlDocument().getRootNode()); result = Optional.of(lowerPriorityDocument.getXmlDocument()); } // if requested, dump each intermediary merging stage into the report. if (mOptionalFeatures.contains(Invoker.Feature.KEEP_INTERMEDIARY_STAGES) && result.isPresent()) { mergingReportBuilder.addMergingStage(result.get().prettyPrint()); } return result; }
loadedMainManifestInfo.getXmlDocument().getPackage(); if (mDocumentType != XmlDocument.Type.OVERLAY && !mainPackageAttribute.isPresent()) { mergingReportBuilder.addMessage( loadedMainManifestInfo.getXmlDocument().getSourceFile(), MergingReport.Record.Severity.ERROR, mainPackageAttribute.get().getValue(), mainPackageAttribute.get().printPosition()); mergingReportBuilder.addMessage( overlayDocument.getXmlDocument().getSourceFile(), MergingReport.Record.Severity.ERROR,
if (usesSdkElement.getOperationType() != NodeOperationType.MERGE) { mergingReport .addMessage( new SourceFilePosition( getSourceFile(), mergingReport.addMessage(getSourceFile(), MergingReport.Record.Severity.ERROR, String.format( "uses-sdk:targetSdkVersion %1$s cannot be different than version " mergingReport.addMessage(getSourceFile(), MergingReport.Record.Severity.ERROR, String.format( "uses-sdk:minSdkVersion %1$s cannot be different than version " lowerPriorityDocument.getPackageName()); if (usesSdk.isPresent()) { mergingReport.addMessage( new SourceFilePosition(getSourceFile(), usesSdk.get().getPosition()), MergingReport.Record.Severity.ERROR, error); } else { mergingReport.addMessage( getSourceFile(), MergingReport.Record.Severity.ERROR, error);
mergingReport.addMessage(getSourceFilePosition(), MergingReport.Record.Severity.ERROR, String.format("'tools:selector=\"%1$s\"' is not a valid library identifier, "
@NonNull @VisibleForTesting Builder addMessage(@NonNull SourceFile sourceFile, int line, int column, @NonNull Record.Severity severity, @NonNull String message) { // The line and column used are 1-based, but SourcePosition uses zero-based. return addMessage( new SourceFilePosition(sourceFile, new SourcePosition(line - 1, column -1, -1)), severity, message); }
void addMessage(@NonNull MergingReport.Builder mergingReport, @NonNull MergingReport.Record.Severity severity, @NonNull String message) { mergingReport.addMessage(getSourceFilePosition(), severity, message); } }
@NonNull Builder addMessage(@NonNull SourceFile sourceFile, @NonNull Record.Severity severity, @NonNull String message) { return addMessage( new SourceFilePosition(sourceFile, SourcePosition.UNKNOWN), severity, message); }
void addMessage(@NonNull MergingReport.Builder report, @NonNull SourcePosition position, @NonNull MergingReport.Record.Severity severity, @NonNull String message) { report.addMessage( new SourceFilePosition(getOwnerElement().getDocument().getSourceFile(), position), severity, message); }