]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | package no.uio.ifi.refaktor.analyze.collectors; |
2 | ||
3 | import no.uio.ifi.refaktor.prefix.Prefix; | |
4 | import no.uio.ifi.refaktor.textselection.CompilationUnitTextSelection; | |
5 | ||
6 | public class LongestCommonPrefixCollector extends AbstractPrefixCollector { | |
7 | private Prefix longestCommonPrefix; | |
8 | ||
9 | public LongestCommonPrefixCollector(CompilationUnitTextSelection selection) { | |
10 | super(selection); | |
11 | } | |
12 | ||
13 | protected void registerPrefix(Prefix prefix) { | |
14 | if (longestCommonPrefix == null) { | |
15 | longestCommonPrefix = prefix; | |
16 | } else { | |
17 | longestCommonPrefix = longestCommonPrefix.intersectWith(prefix); | |
18 | } | |
19 | } | |
20 | ||
21 | public Prefix getProperty() { | |
22 | return longestCommonPrefix; | |
23 | } | |
24 | ||
25 | @Override | |
26 | public void clearData() { | |
27 | longestCommonPrefix = null; | |
28 | } | |
29 | } |