Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api-editor/gui/src/features/filter/FilterHelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ export const FilterHelpButton = function () {
.
</ChakraText>
</ListItem>
<ListItem>
<ChakraText>
<strong>is:removed</strong>
</ChakraText>
<ChakraText>
Displays only elements that will be removed. These are either annotated with @remove
directly or have an ancestors with this annotation.
</ChakraText>
</ListItem>
<ListItem>
<ChakraText>
<strong>usages:[operator][expected]</strong>
Expand Down
44 changes: 44 additions & 0 deletions api-editor/gui/src/features/filter/model/RemovedFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { PythonClass } from '../../packageData/model/PythonClass';
import { PythonFunction } from '../../packageData/model/PythonFunction';
import { PythonModule } from '../../packageData/model/PythonModule';
import { PythonParameter } from '../../packageData/model/PythonParameter';
import { PythonDeclaration } from '../../packageData/model/PythonDeclaration';
import { UsageCountStore } from '../../usages/model/UsageCountStore';
import { AbstractPythonFilter } from './AbstractPythonFilter';
import { AnnotationStore, ReviewResult } from '../../annotations/versioning/AnnotationStoreV2';

/**
* Keeps only declarations that have the @remove annotation directly or have an ancestor with this annotation.
*/
export class RemovedFilter extends AbstractPythonFilter {
shouldKeepModule(pythonModule: PythonModule, annotations: AnnotationStore, usages: UsageCountStore): boolean {
return this.shouldKeepDeclaration(pythonModule, annotations, usages);
}

shouldKeepClass(pythonClass: PythonClass, annotations: AnnotationStore, usages: UsageCountStore): boolean {
return this.shouldKeepDeclaration(pythonClass, annotations, usages);
}

shouldKeepFunction(pythonFunction: PythonFunction, annotations: AnnotationStore, usages: UsageCountStore): boolean {
return this.shouldKeepDeclaration(pythonFunction, annotations, usages);
}

shouldKeepParameter(
pythonParameter: PythonParameter,
annotations: AnnotationStore,
usages: UsageCountStore,
): boolean {
return this.shouldKeepDeclaration(pythonParameter, annotations, usages);
}

shouldKeepDeclaration(
pythonDeclaration: PythonDeclaration,
annotations: AnnotationStore,
_usages: UsageCountStore,
): boolean {
return [...pythonDeclaration.ancestorsOrSelf()].some((ancestor) => {
const annotation = annotations.removeAnnotations[ancestor.id];
return annotation && !annotation.isRemoved && annotation.reviewResult !== ReviewResult.Wrong;
});
}
}
4 changes: 4 additions & 0 deletions api-editor/gui/src/features/filter/model/filterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DoneFilter } from './DoneFilter';
import { PythonParameterAssignment } from '../../packageData/model/PythonParameter';
import { QualifiedNameStringFilter } from './QualifiedNameStringFilter';
import { QualifiedNameRegexFilter } from './QualifiedNameRegexFilter';
import { RemovedFilter } from './RemovedFilter';

/**
* Creates a filter from the given string. This method handles conjunctions, negations, and non-negated tokens.
Expand Down Expand Up @@ -92,6 +93,9 @@ const fixedFilters: { [name: string]: AbstractPythonFilter } = {
'annotation:@rename': new AnnotationFilter(AnnotationType.Rename),
'annotation:@todo': new AnnotationFilter(AnnotationType.Todo),
'annotation:@value': new AnnotationFilter(AnnotationType.Value),

// Removed
'is:removed': new RemovedFilter(),
};

/**
Expand Down