Lines 56-63
Link Here
|
56 |
import java.util.logging.Level; |
56 |
import java.util.logging.Level; |
57 |
import java.util.logging.Logger; |
57 |
import java.util.logging.Logger; |
58 |
import org.netbeans.api.project.Project; |
58 |
import org.netbeans.api.project.Project; |
|
|
59 |
import org.netbeans.modules.cnd.api.project.NativeFileItem; |
59 |
import org.netbeans.modules.cnd.api.toolchain.CompilerSet; |
60 |
import org.netbeans.modules.cnd.api.toolchain.CompilerSet; |
60 |
import org.netbeans.modules.cnd.makeproject.MakeProjectImpl; |
61 |
import org.netbeans.modules.cnd.makeproject.MakeProjectImpl; |
|
|
62 |
import org.netbeans.modules.cnd.makeproject.NativeProjectProvider; |
61 |
import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptor.State; |
63 |
import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptor.State; |
62 |
import org.netbeans.modules.cnd.makeproject.configurations.ConfigurationXMLReader; |
64 |
import org.netbeans.modules.cnd.makeproject.configurations.ConfigurationXMLReader; |
63 |
import org.netbeans.modules.cnd.makeproject.uiapi.ConfirmSupport; |
65 |
import org.netbeans.modules.cnd.makeproject.uiapi.ConfirmSupport; |
Lines 566-615
Link Here
|
566 |
public static final class Delta implements SnapShot { |
568 |
public static final class Delta implements SnapShot { |
567 |
|
569 |
|
568 |
private final Map<String, Pair> oldState = new HashMap<>(); |
570 |
private final Map<String, Pair> oldState = new HashMap<>(); |
569 |
private final List<Item> included = new ArrayList<>(); |
571 |
private final List<NativeFileItem> included = new ArrayList<>(); |
570 |
private final List<Item> added = new ArrayList<>(); |
572 |
private final List<NativeFileItem> added = new ArrayList<>(); |
571 |
private final List<Item> excluded = new ArrayList<>(); |
573 |
private final List<NativeFileItem> excluded = new ArrayList<>(); |
572 |
private final List<Item> deleted = new ArrayList<>(); |
574 |
private final List<NativeFileItem> deleted = new ArrayList<>(); |
573 |
private final List<Item> changed = new ArrayList<>(); |
575 |
private final List<NativeFileItem> changed = new ArrayList<>(); |
574 |
private final List<Item> replaced = new ArrayList<>(); |
576 |
private final List<NativeFileItem> replaced = new ArrayList<>(); |
575 |
|
577 |
|
576 |
private Delta(MakeConfigurationDescriptor oldDescriptor) { |
578 |
private Delta(MakeConfigurationDescriptor oldDescriptor) { |
577 |
if (oldDescriptor != null) { |
579 |
if (oldDescriptor != null) { |
578 |
for(Item item : oldDescriptor.getProjectItems()) { |
580 |
for(Item item : oldDescriptor.getProjectItems()) { |
579 |
oldState.put(item.getAbsolutePath(), new Pair(item, item.getCRC(), item.isExcluded())); |
581 |
oldState.put(item.getAbsolutePath(), new Pair(item, item.getCRC(), item.isExcluded())); |
580 |
} |
582 |
} |
|
|
583 |
NativeProjectProvider np = oldDescriptor.getProject().getLookup().lookup(NativeProjectProvider.class); |
584 |
for(NativeFileItem item : np.getStandardHeadersIndexers()) { |
585 |
if (item instanceof NativeProjectProvider.NativeFileIndexer) { |
586 |
NativeProjectProvider.NativeFileIndexer indexer = (NativeProjectProvider.NativeFileIndexer)item; |
587 |
oldState.put(item.getAbsolutePath(), new Pair(indexer, indexer.getCRC(), indexer.isExcluded())); |
588 |
} |
589 |
} |
581 |
} |
590 |
} |
582 |
} |
591 |
} |
583 |
|
592 |
|
584 |
private void computeDelta(MakeConfigurationDescriptor newDescriptor) { |
593 |
private void computeDelta(MakeConfigurationDescriptor newDescriptor) { |
585 |
Set<Item> oldSet = new HashSet<>(); |
594 |
Set<NativeFileItem> oldSet = new HashSet<>(); |
586 |
oldState.entrySet().forEach((entry) -> { |
595 |
oldState.entrySet().forEach((entry) -> { |
587 |
oldSet.add(entry.getValue().item); |
596 |
oldSet.add(entry.getValue().item); |
588 |
}); |
597 |
}); |
589 |
Item[] newItems = newDescriptor.getProjectItems(); |
598 |
Item[] newItems = newDescriptor.getProjectItems(); |
590 |
for (Item item : newItems) { |
599 |
for (Item item : newItems) { |
591 |
Delta.Pair pair = oldState.get(item.getAbsolutePath()); |
600 |
checkItem(item, oldSet, item.getCRC()); |
592 |
if (pair == null) { |
601 |
} |
593 |
added.add(item); |
602 |
NativeProjectProvider np = newDescriptor.getProject().getLookup().lookup(NativeProjectProvider.class); |
594 |
} else { |
603 |
for(NativeFileItem item : np.getStandardHeadersIndexers()) { |
595 |
oldSet.remove(pair.item); |
604 |
if (item instanceof NativeProjectProvider.NativeFileIndexer) { |
596 |
if (item.isExcluded() && pair.excluded) { |
605 |
NativeProjectProvider.NativeFileIndexer indexer = (NativeProjectProvider.NativeFileIndexer)item; |
597 |
// no changes |
606 |
checkItem(indexer, oldSet, indexer.getCRC()); |
598 |
replaced.add(item); |
|
|
599 |
} else if (item.isExcluded() && !pair.excluded) { |
600 |
excluded.add(item); |
601 |
} else if (!item.isExcluded() && pair.excluded) { |
602 |
included.add(item); |
603 |
} else { |
604 |
// compare item properties |
605 |
if (item.getCRC() != pair.crc) { |
606 |
changed.add(item); |
607 |
} else { |
608 |
if (pair.item != item) { |
609 |
replaced.add(item); |
610 |
} |
611 |
} |
612 |
} |
613 |
} |
607 |
} |
614 |
} |
608 |
} |
615 |
oldSet.forEach((item) -> { |
609 |
oldSet.forEach((item) -> { |
Lines 617-622
Link Here
|
617 |
}); |
611 |
}); |
618 |
oldState.clear(); |
612 |
oldState.clear(); |
619 |
} |
613 |
} |
|
|
614 |
|
615 |
private void checkItem(NativeFileItem item, Set<NativeFileItem> oldSet, int itemCRC) { |
616 |
Delta.Pair pair = oldState.get(item.getAbsolutePath()); |
617 |
if (pair == null) { |
618 |
added.add(item); |
619 |
} else { |
620 |
oldSet.remove(pair.item); |
621 |
if (item.isExcluded() && pair.excluded) { |
622 |
// no changes |
623 |
replaced.add(item); |
624 |
} else if (item.isExcluded() && !pair.excluded) { |
625 |
excluded.add(item); |
626 |
} else if (!item.isExcluded() && pair.excluded) { |
627 |
included.add(item); |
628 |
} else { |
629 |
// compare item properties |
630 |
if (itemCRC != pair.crc) { |
631 |
changed.add(item); |
632 |
} else { |
633 |
if (pair.item != item) { |
634 |
replaced.add(item); |
635 |
} |
636 |
} |
637 |
} |
638 |
} |
639 |
} |
620 |
|
640 |
|
621 |
public void printStatistic(Logger logger) { |
641 |
public void printStatistic(Logger logger) { |
622 |
if (logger.isLoggable(CndUtils.isUnitTestMode()? Level.FINE : Level.INFO)) { |
642 |
if (logger.isLoggable(CndUtils.isUnitTestMode()? Level.FINE : Level.INFO)) { |
Lines 632-681
Link Here
|
632 |
/** |
652 |
/** |
633 |
* marked as included items |
653 |
* marked as included items |
634 |
*/ |
654 |
*/ |
635 |
public List<Item> getIncluded() { |
655 |
public List<NativeFileItem> getIncluded() { |
636 |
return Collections.unmodifiableList(included); |
656 |
return Collections.unmodifiableList(included); |
637 |
} |
657 |
} |
638 |
|
658 |
|
639 |
/** |
659 |
/** |
640 |
* added in project items |
660 |
* added in project items |
641 |
*/ |
661 |
*/ |
642 |
public List<Item> getAdded() { |
662 |
public List<NativeFileItem> getAdded() { |
643 |
return Collections.unmodifiableList(added); |
663 |
return Collections.unmodifiableList(added); |
644 |
} |
664 |
} |
645 |
|
665 |
|
646 |
/** |
666 |
/** |
647 |
* marked as excluded items |
667 |
* marked as excluded items |
648 |
*/ |
668 |
*/ |
649 |
public List<Item> getExcluded() { |
669 |
public List<NativeFileItem> getExcluded() { |
650 |
return Collections.unmodifiableList(excluded); |
670 |
return Collections.unmodifiableList(excluded); |
651 |
} |
671 |
} |
652 |
|
672 |
|
653 |
/** |
673 |
/** |
654 |
* deleted from project items |
674 |
* deleted from project items |
655 |
*/ |
675 |
*/ |
656 |
public List<Item> getDeleted() { |
676 |
public List<NativeFileItem> getDeleted() { |
657 |
return Collections.unmodifiableList(deleted); |
677 |
return Collections.unmodifiableList(deleted); |
658 |
} |
678 |
} |
659 |
|
679 |
|
660 |
/** |
680 |
/** |
661 |
* items with changed properties |
681 |
* items with changed properties |
662 |
*/ |
682 |
*/ |
663 |
public List<Item> getChanged() { |
683 |
public List<NativeFileItem> getChanged() { |
664 |
return Collections.unmodifiableList(changed); |
684 |
return Collections.unmodifiableList(changed); |
665 |
} |
685 |
} |
666 |
|
686 |
|
667 |
/** |
687 |
/** |
668 |
* Items which properties were not changed (from code model point of view) but instances were replaced |
688 |
* Items which properties were not changed (from code model point of view) but instances were replaced |
669 |
*/ |
689 |
*/ |
670 |
public List<Item> getReplaced() { |
690 |
public List<NativeFileItem> getReplaced() { |
671 |
return Collections.unmodifiableList(replaced); |
691 |
return Collections.unmodifiableList(replaced); |
672 |
} |
692 |
} |
673 |
|
693 |
|
674 |
private static final class Pair { |
694 |
private static final class Pair { |
675 |
final int crc; |
695 |
final int crc; |
676 |
final boolean excluded; |
696 |
final boolean excluded; |
677 |
final Item item; |
697 |
final NativeFileItem item; |
678 |
private Pair(Item item, int crc, boolean excluded) { |
698 |
private Pair(NativeFileItem item, int crc, boolean excluded) { |
679 |
this.crc = crc; |
699 |
this.crc = crc; |
680 |
this.excluded = excluded; |
700 |
this.excluded = excluded; |
681 |
this.item = item; |
701 |
this.item = item; |