Lines 457-462
Link Here
|
457 |
|
457 |
|
458 |
IProject project = javaProject.getProject(); |
458 |
IProject project = javaProject.getProject(); |
459 |
IPath projectPath= project.getFullPath(); |
459 |
IPath projectPath= project.getFullPath(); |
|
|
460 |
String projectName = javaProject.getElementName(); |
460 |
|
461 |
|
461 |
/* validate output location */ |
462 |
/* validate output location */ |
462 |
if (projectOutputLocation == null) { |
463 |
if (projectOutputLocation == null) { |
Lines 503-515
Link Here
|
503 |
|
504 |
|
504 |
if (resolvedEntry.getExclusionPatterns() != null && resolvedEntry.getExclusionPatterns().length > 0 |
505 |
if (resolvedEntry.getExclusionPatterns() != null && resolvedEntry.getExclusionPatterns().length > 0 |
505 |
&& JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) { |
506 |
&& JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) { |
506 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, resolvedEntry.getPath()); |
507 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, javaProject, resolvedEntry.getPath()); |
507 |
} |
508 |
} |
508 |
IPath customOutput; |
509 |
IPath customOutput; |
509 |
if ((customOutput = resolvedEntry.getOutputLocation()) != null) { |
510 |
if ((customOutput = resolvedEntry.getOutputLocation()) != null) { |
510 |
|
511 |
|
511 |
if (JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true))) { |
512 |
if (JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true))) { |
512 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, resolvedEntry.getPath()); |
513 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, javaProject, resolvedEntry.getPath()); |
513 |
} |
514 |
} |
514 |
// ensure custom output is in project |
515 |
// ensure custom output is in project |
515 |
if (customOutput.isAbsolute()) { |
516 |
if (customOutput.isAbsolute()) { |
Lines 576-585
Link Here
|
576 |
if (entry == null) continue; |
577 |
if (entry == null) continue; |
577 |
IPath entryPath = entry.getPath(); |
578 |
IPath entryPath = entry.getPath(); |
578 |
int kind = entry.getEntryKind(); |
579 |
int kind = entry.getEntryKind(); |
|
|
580 |
|
581 |
// Build some common strings for status message |
582 |
boolean epStartsWithProject = entryPath.segment(0).toString().equals(projectName); |
583 |
String entryPathMsg = epStartsWithProject ? entryPath.removeFirstSegments(1).toString() : entryPath.makeRelative().toString(); |
579 |
|
584 |
|
580 |
// complain if duplicate path |
585 |
// complain if duplicate path |
581 |
if (!pathes.add(entryPath)){ |
586 |
if (!pathes.add(entryPath)){ |
582 |
return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, Util.bind("classpath.duplicateEntryPath", entryPath.makeRelative().toString())); //$NON-NLS-1$ |
587 |
return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, Util.bind("classpath.duplicateEntryPath", entryPathMsg, projectName)); //$NON-NLS-1$ |
583 |
} |
588 |
} |
584 |
// no further check if entry coincidates with project or output location |
589 |
// no further check if entry coincidates with project or output location |
585 |
if (entryPath.equals(projectPath)){ |
590 |
if (entryPath.equals(projectPath)){ |
Lines 616-622
Link Here
|
616 |
exclusionPattern += '/'; |
621 |
exclusionPattern += '/'; |
617 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInEntry", new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString(), exclusionPattern})); //$NON-NLS-1$ |
622 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInEntry", new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString(), exclusionPattern})); //$NON-NLS-1$ |
618 |
} else { |
623 |
} else { |
619 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInLibrary", new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString()})); //$NON-NLS-1$ |
624 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInLibrary", entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString())); //$NON-NLS-1$ |
620 |
} |
625 |
} |
621 |
} |
626 |
} |
622 |
} |
627 |
} |
Lines 651-656
Link Here
|
651 |
IPath entryPath = entry.getPath(); |
656 |
IPath entryPath = entry.getPath(); |
652 |
int kind = entry.getEntryKind(); |
657 |
int kind = entry.getEntryKind(); |
653 |
|
658 |
|
|
|
659 |
// Build some common strings for status message |
660 |
boolean epStartsWithProject = entryPath.segment(0).toString().equals(projectName); |
661 |
String entryPathMsg = epStartsWithProject ? entryPath.removeFirstSegments(1).toString() : entryPath.makeRelative().toString(); |
662 |
|
654 |
if (kind == IClasspathEntry.CPE_SOURCE) { |
663 |
if (kind == IClasspathEntry.CPE_SOURCE) { |
655 |
IPath output = entry.getOutputLocation(); |
664 |
IPath output = entry.getOutputLocation(); |
656 |
if (output == null) continue; // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate) |
665 |
if (output == null) continue; // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate) |
Lines 658-672
Link Here
|
658 |
for (int j = 0; j < length; j++) { |
667 |
for (int j = 0; j < length; j++) { |
659 |
IClasspathEntry otherEntry = classpath[j]; |
668 |
IClasspathEntry otherEntry = classpath[j]; |
660 |
if (otherEntry == entry) continue; |
669 |
if (otherEntry == entry) continue; |
|
|
670 |
|
671 |
// Build some common strings for status message |
672 |
boolean opStartsWithProject = otherEntry.getPath().segment(0).toString().equals(projectName); |
673 |
String otherPathMsg = opStartsWithProject ? otherEntry.getPath().removeFirstSegments(1).toString() : otherEntry.getPath().makeRelative().toString(); |
674 |
|
661 |
switch (otherEntry.getEntryKind()) { |
675 |
switch (otherEntry.getEntryKind()) { |
662 |
case IClasspathEntry.CPE_SOURCE : |
676 |
case IClasspathEntry.CPE_SOURCE : |
663 |
if (otherEntry.getPath().equals(output)) { |
677 |
if (otherEntry.getPath().equals(output)) { |
664 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotUseDistinctSourceFolderAsOutput", entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString())); //$NON-NLS-1$ |
678 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotUseDistinctSourceFolderAsOutput", new String[] {entryPathMsg, otherPathMsg, projectName})); //$NON-NLS-1$ |
665 |
} |
679 |
} |
666 |
break; |
680 |
break; |
667 |
case IClasspathEntry.CPE_LIBRARY : |
681 |
case IClasspathEntry.CPE_LIBRARY : |
668 |
if (otherEntry.getPath().equals(output)) { |
682 |
if (otherEntry.getPath().equals(output)) { |
669 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotUseLibraryAsOutput", entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString())); //$NON-NLS-1$ |
683 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotUseLibraryAsOutput", new String[] {entryPathMsg, otherPathMsg, projectName})); //$NON-NLS-1$ |
670 |
} |
684 |
} |
671 |
} |
685 |
} |
672 |
} |
686 |
} |
Lines 690-695
Link Here
|
690 |
|
704 |
|
691 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
705 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
692 |
IPath path = entry.getPath(); |
706 |
IPath path = entry.getPath(); |
|
|
707 |
|
708 |
// Build some common strings for status message |
709 |
String projectName = project.getElementName(); |
710 |
boolean pathStartsWithProject = path.segment(0).toString().equals(projectName); |
711 |
String entryPathMsg = pathStartsWithProject ? path.removeFirstSegments(1).toString() : path.makeRelative().toString(); |
712 |
|
693 |
switch(entry.getEntryKind()){ |
713 |
switch(entry.getEntryKind()){ |
694 |
|
714 |
|
695 |
// container entry check |
715 |
// container entry check |
Lines 724-730
Link Here
|
724 |
return new JavaModelStatus(e); |
744 |
return new JavaModelStatus(e); |
725 |
} |
745 |
} |
726 |
} else { |
746 |
} else { |
727 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalContainerPath", path.makeRelative().toString())); //$NON-NLS-1$ |
747 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalContainerPath", entryPathMsg, projectName)); //$NON-NLS-1$ |
728 |
} |
748 |
} |
729 |
break; |
749 |
break; |
730 |
|
750 |
|
Lines 737-743
Link Here
|
737 |
} |
757 |
} |
738 |
return validateClasspathEntry(project, entry, checkSourceAttachment); |
758 |
return validateClasspathEntry(project, entry, checkSourceAttachment); |
739 |
} else { |
759 |
} else { |
740 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalVariablePath", path.makeRelative().toString())); //$NON-NLS-1$ |
760 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalVariablePath", path.makeRelative().toString(), projectName)); //$NON-NLS-1$ |
741 |
} |
761 |
} |
742 |
|
762 |
|
743 |
// library entry check |
763 |
// library entry check |
Lines 761-767
Link Here
|
761 |
&& sourceAttachment != null |
781 |
&& sourceAttachment != null |
762 |
&& !sourceAttachment.isEmpty() |
782 |
&& !sourceAttachment.isEmpty() |
763 |
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){ |
783 |
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){ |
764 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.makeRelative().toString(), path.makeRelative().toString())); //$NON-NLS-1$ |
784 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", new String [] {sourceAttachment.makeRelative().toString(), path.makeRelative().toString(), projectName})); //$NON-NLS-1$ |
765 |
} |
785 |
} |
766 |
} |
786 |
} |
767 |
break; |
787 |
break; |
Lines 770-776
Link Here
|
770 |
&& sourceAttachment != null |
790 |
&& sourceAttachment != null |
771 |
&& !sourceAttachment.isEmpty() |
791 |
&& !sourceAttachment.isEmpty() |
772 |
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){ |
792 |
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){ |
773 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.makeRelative().toString(), path.makeRelative().toString())); //$NON-NLS-1$ |
793 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", new String [] {sourceAttachment.makeRelative().toString(), path.makeRelative().toString(), projectName})); //$NON-NLS-1$ |
774 |
} |
794 |
} |
775 |
} |
795 |
} |
776 |
} else if (target instanceof File){ |
796 |
} else if (target instanceof File){ |
Lines 778-790
Link Here
|
778 |
&& sourceAttachment != null |
798 |
&& sourceAttachment != null |
779 |
&& !sourceAttachment.isEmpty() |
799 |
&& !sourceAttachment.isEmpty() |
780 |
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){ |
800 |
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){ |
781 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString(), path.makeRelative().toString())); //$NON-NLS-1$ |
801 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", new String [] {sourceAttachment.toString(), path.makeRelative().toString(), projectName})); //$NON-NLS-1$ |
782 |
} |
802 |
} |
783 |
} else { |
803 |
} else { |
784 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundLibrary", path.makeRelative().toString())); //$NON-NLS-1$ |
804 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundLibrary", path.makeRelative().toString(), projectName)); //$NON-NLS-1$ |
785 |
} |
805 |
} |
786 |
} else { |
806 |
} else { |
787 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalLibraryPath", path.makeRelative().toString())); //$NON-NLS-1$ |
807 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalLibraryPath", path.makeRelative().toString(), projectName)); //$NON-NLS-1$ |
788 |
} |
808 |
} |
789 |
break; |
809 |
break; |
790 |
|
810 |
|
Lines 795-801
Link Here
|
795 |
IJavaProject prereqProject = JavaCore.create(prereqProjectRsc); |
815 |
IJavaProject prereqProject = JavaCore.create(prereqProjectRsc); |
796 |
try { |
816 |
try { |
797 |
if (!prereqProjectRsc.exists() || !prereqProjectRsc.hasNature(JavaCore.NATURE_ID)){ |
817 |
if (!prereqProjectRsc.exists() || !prereqProjectRsc.hasNature(JavaCore.NATURE_ID)){ |
798 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.makeRelative().segment(0).toString())); //$NON-NLS-1$ |
818 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.makeRelative().segment(0).toString(), projectName)); //$NON-NLS-1$ |
799 |
} |
819 |
} |
800 |
if (!prereqProjectRsc.isOpen()){ |
820 |
if (!prereqProjectRsc.isOpen()){ |
801 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.closedProject", path.segment(0).toString())); //$NON-NLS-1$ |
821 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.closedProject", path.segment(0).toString())); //$NON-NLS-1$ |
Lines 809-818
Link Here
|
809 |
} |
829 |
} |
810 |
} |
830 |
} |
811 |
} catch (CoreException e){ |
831 |
} catch (CoreException e){ |
812 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.segment(0).toString())); //$NON-NLS-1$ |
832 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.segment(0).toString(), projectName)); //$NON-NLS-1$ |
813 |
} |
833 |
} |
814 |
} else { |
834 |
} else { |
815 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalProjectPath", path.segment(0).toString())); //$NON-NLS-1$ |
835 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalProjectPath", path.segment(0).toString(), projectName)); //$NON-NLS-1$ |
816 |
} |
836 |
} |
817 |
break; |
837 |
break; |
818 |
|
838 |
|
Lines 821-838
Link Here
|
821 |
if (entry.getExclusionPatterns() != null |
841 |
if (entry.getExclusionPatterns() != null |
822 |
&& entry.getExclusionPatterns().length > 0 |
842 |
&& entry.getExclusionPatterns().length > 0 |
823 |
&& JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) { |
843 |
&& JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) { |
824 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, path); |
844 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, project, path); |
825 |
} |
845 |
} |
826 |
if (entry.getOutputLocation() != null && JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true))) { |
846 |
if (entry.getOutputLocation() != null && JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true))) { |
827 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, path); |
847 |
return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, project, path); |
828 |
} |
848 |
} |
829 |
if (path != null && path.isAbsolute() && !path.isEmpty()) { |
849 |
if (path != null && path.isAbsolute() && !path.isEmpty()) { |
830 |
IPath projectPath= project.getProject().getFullPath(); |
850 |
IPath projectPath= project.getProject().getFullPath(); |
831 |
if (!projectPath.isPrefixOf(path) || JavaModel.getTarget(workspaceRoot, path, true) == null){ |
851 |
if (!projectPath.isPrefixOf(path) || JavaModel.getTarget(workspaceRoot, path, true) == null){ |
832 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceFolder", path.makeRelative().toString())); //$NON-NLS-1$ |
852 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceFolder", entryPathMsg, projectName)); //$NON-NLS-1$ |
833 |
} |
853 |
} |
834 |
} else { |
854 |
} else { |
835 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalSourceFolderPath", path.makeRelative().toString())); //$NON-NLS-1$ |
855 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalSourceFolderPath", entryPathMsg, projectName)); //$NON-NLS-1$ |
836 |
} |
856 |
} |
837 |
break; |
857 |
break; |
838 |
} |
858 |
} |