mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
duplicate class checks
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
Compiling files:
|
||||
src2/pkg/Constants.java
|
||||
End of files
|
||||
Cleaning output files:
|
||||
out/production/addDuplicateClass/pkg/Constants.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/pkg/Constants.java
|
||||
src2/pkg/Constants.java
|
||||
End of files
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="ProjectResources">
|
||||
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/addDuplicateClass.iml" filepath="$PROJECT_DIR$/addDuplicateClass.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src2" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="common" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package pkg;
|
||||
public class Client {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Constants.NUMBER);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package pkg;
|
||||
public class Constants {
|
||||
public static final Integer NUMBER = new Integer(10);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package pkg;
|
||||
public class Constants {
|
||||
}
|
||||
@@ -1761,13 +1761,35 @@ public class Mappings {
|
||||
debug("End of removed classes processing.");
|
||||
}
|
||||
|
||||
private void processAddedClasses(final DiffState state) {
|
||||
private void processAddedClasses(final DiffState state, File srcFile) {
|
||||
final Collection<ClassRepr> addedClasses = state.myClassDiff.added();
|
||||
if (addedClasses.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug("Processing added classes:");
|
||||
|
||||
if (!myEasyMode) {
|
||||
// checking if this newly added class duplicates already existing one
|
||||
for (ClassRepr c : addedClasses) {
|
||||
if (!c.isLocal() && !c.isAnonymous() && isEmpty(c.getOuterClassName())) {
|
||||
final File currentlyMappedTo = myClassToSourceFile.get(c.name);
|
||||
if (currentlyMappedTo != null && !FileUtil.filesEqual(currentlyMappedTo, srcFile) && currentlyMappedTo.exists()) {
|
||||
if (myFilter == null || myFilter.accept(currentlyMappedTo)) {
|
||||
// Same classes from different source files.
|
||||
// Schedule for recompilation both to make possible 'duplicate sources' error evident
|
||||
debug("Scheduling for recompilation duplicated sources: ", currentlyMappedTo.getPath() + "; " + srcFile.getPath());
|
||||
myAffectedFiles.add(currentlyMappedTo);
|
||||
myAffectedFiles.add(srcFile);
|
||||
myCompiledFiles.remove(srcFile); // this will force sending the file to compilation again
|
||||
return; // do not process this file because it should not be integrated
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final ClassRepr c : addedClasses) {
|
||||
debug("Class name: ", c.name);
|
||||
myDelta.addChangedClass(c.name);
|
||||
@@ -1898,7 +1920,7 @@ public class Mappings {
|
||||
}
|
||||
|
||||
processRemovedClases(state);
|
||||
processAddedClasses(state);
|
||||
processAddedClasses(state, fileName);
|
||||
|
||||
if (!myEasyMode) {
|
||||
calculateAffectedFiles(state);
|
||||
|
||||
@@ -134,7 +134,8 @@ final class FilesDelta {
|
||||
isMarkedDeleted = !myDeletedPaths.isEmpty() && myDeletedPaths.contains(FileUtil.toCanonicalPath(file.getPath()));
|
||||
}
|
||||
if (!isMarkedDeleted) {
|
||||
return _addToRecompiled(root, file);
|
||||
_addToRecompiled(root, file);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,4 +101,8 @@ public class CommonTest extends IncrementalTestCase {
|
||||
public void testAddClass() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAddDuplicateClass() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user