private void info(@NonNull String message) { if (mExtractor != null) { mExtractor.info(message); } else { System.out.println(message); } }
/** * Performs the actual deletion (or display, if in dry-run mode) of the typedef annotation * files */ private void deleteAnnotationClasses() { for (File mFile : mAnnotationClassFiles) { if (mVerbose) { if (mDryRun) { mExtractor.info("Would delete " + mFile); } else { mExtractor.info("Deleting " + mFile); } } if (!mDryRun) { boolean deleted = mFile.delete(); if (!deleted) { Extractor.warning("Could not delete " + mFile); } } } } }
info("Skipping constant from typedef because it is not part of the SDK: " + fqn);
info("Skipping constant from typedef because it is not part of the SDK: " + fqn);
public void export(@Nullable File annotationsZip, @Nullable File proguardCfg) { if (proguardCfg != null) { if (keepItems.isEmpty()) { if (proguardCfg.exists()) { //noinspection ResultOfMethodCallIgnored proguardCfg.delete(); } } else if (writeKeepRules(proguardCfg)) { info("ProGuard keep rules written to " + proguardCfg); } } if (annotationsZip != null) { if (itemMap.isEmpty()) { if (annotationsZip.exists()) { //noinspection ResultOfMethodCallIgnored annotationsZip.delete(); } } else if (writeExternalAnnotations(annotationsZip)) { writeStats(); info("Annotations written to " + annotationsZip); } } }
public void export(@Nullable File annotationsZip, @Nullable File proguardCfg) { if (proguardCfg != null) { if (keepItems.isEmpty()) { if (proguardCfg.exists()) { //noinspection ResultOfMethodCallIgnored proguardCfg.delete(); } } else if (writeKeepRules(proguardCfg)) { info("ProGuard keep rules written to " + proguardCfg); } } if (annotationsZip != null) { if (itemMap.isEmpty()) { if (annotationsZip.exists()) { //noinspection ResultOfMethodCallIgnored annotationsZip.delete(); } } else if (writeExternalAnnotations(annotationsZip)) { writeStats(); info("Annotations written to " + annotationsZip); } } }
private boolean isRelevantAnnotation(Element annotationElement) { AnnotationData annotation = createAnnotation(annotationElement); if (annotation == null) { // Unsupported annotation in import return false; } if (isNullable(annotation.name) || isNonNull(annotation.name) || annotation.name.startsWith(ANDROID_ANNOTATIONS_PREFIX) || annotation.name.startsWith(SUPPORT_ANNOTATIONS_PREFIX)) { return true; } else if (annotation.name.equals(IDEA_CONTRACT)) { return true; } else if (annotation.name.equals(IDEA_NON_NLS)) { return false; } else { if (!ignoredAnnotations.contains(annotation.name)) { ignoredAnnotations.add(annotation.name); if (isListIgnored()) { info("(Ignoring merge annotation " + annotation.name + ")"); } } } return false; }
private boolean isRelevantAnnotation(Element annotationElement) { AnnotationData annotation = createAnnotation(annotationElement); if (annotation == null) { // Unsupported annotation in import return false; } if (isNullable(annotation.name) || isNonNull(annotation.name) || annotation.name.startsWith(ANDROID_ANNOTATIONS_PREFIX) || annotation.name.startsWith(SUPPORT_ANNOTATIONS_PREFIX)) { return true; } else if (annotation.name.equals(IDEA_CONTRACT)) { return true; } else if (annotation.name.equals(IDEA_NON_NLS)) { return false; } else { if (!ignoredAnnotations.contains(annotation.name)) { ignoredAnnotations.add(annotation.name); if (isListIgnored()) { info("(Ignoring merge annotation " + annotation.name + ")"); } } } return false; }
private void addItem(@NonNull String fqn, @NonNull Item item) { // Not part of the API? if (apiFilter != null && item.isFiltered(apiFilter)) { if (isListIgnored()) { info("Skipping API because it is not part of the API file: " + item); } filteredCount++; return; } String pkg = getPackage(fqn); Map<String, List<Item>> classMap = itemMap.get(pkg); if (classMap == null) { classMap = Maps.newHashMapWithExpectedSize(100); itemMap.put(pkg, classMap); } List<Item> items = classMap.get(fqn); if (items == null) { items = Lists.newArrayList(); classMap.put(fqn, items); } items.add(item); }
public void remove(@NonNull File classDir, @NonNull List<String> owners) { if (!mQuiet) { mExtractor.info("Deleting @IntDef and @StringDef annotation class files"); } // Record typedef annotation names and files for (String owner : owners) { File file = new File(classDir, owner.replace('/', File.separatorChar) + DOT_CLASS); addTypeDef(owner, file); } // Rewrite the .class files for any classes that *contain* typedefs as innerclasses rewriteOuterClasses(); // Removes the actual .class files for the typedef annotations deleteAnnotationClasses(); }
private void addItem(@NonNull String fqn, @NonNull Item item) { // Not part of the API? if (apiFilter != null && item.isFiltered(apiFilter)) { if (isListIgnored()) { info("Skipping API because it is not part of the API file: " + item); } filteredCount++; return; } addItemUnconditionally(fqn, item); }
new String(fb.name))) { if (isListIgnored()) { info("Filtering out typedef constant " + new String(fb.declaringClass.readableName()) + "." + new String(fb.name) + "");
new String(fb.name))) { if (isListIgnored()) { info("Filtering out typedef constant " + new String(fb.declaringClass.readableName()) + "." + new String(fb.name) + "");
!apiFilter.hasMethod(containingClass, methodName, parameters)) { if (isListIgnored()) { info("Skipping imported element because it is not part of the API file: " + containingClass + "#" + methodName + "(" + parameters + ")");
!apiFilter.hasMethod(containingClass, methodName, parameters)) { if (isListIgnored()) { info("Skipping imported element because it is not part of the API file: " + containingClass + "#" + methodName + "(" + parameters + ")");
private void mergeField(Element item, String containingClass, String fieldName) { if (apiFilter != null && !apiFilter.hasField(containingClass, fieldName)) { if (isListIgnored()) { info("Skipping imported element because it is not part of the API file: " + containingClass + "#" + fieldName); } filteredCount++; } else { FieldItem fieldItem = new FieldItem(containingClass, ClassKind.CLASS, fieldName, null); Item existing = findItem(containingClass, fieldItem); if (existing != null) { mergedCount += mergeAnnotations(item, existing); } else { addItem(containingClass, fieldItem); mergedCount += addAnnotations(item, fieldItem); } } }
private void mergeField(Element item, String containingClass, String fieldName) { if (apiFilter != null && !hasHistoricData(item) && !apiFilter.hasField(containingClass, fieldName)) { if (isListIgnored()) { info("Skipping imported element because it is not part of the API file: " + containingClass + "#" + fieldName); } filteredCount++; } else { FieldItem fieldItem = new FieldItem(containingClass, ClassKind.CLASS, fieldName, null); Item existing = findItem(containingClass, fieldItem); if (existing != null) { mergedCount += mergeAnnotations(item, existing); } else { addItemUnconditionally(containingClass, fieldItem); mergedCount += addAnnotations(item, fieldItem); } } }