Lines 171-176
Link Here
|
171 |
static final String SOURCE_LEVEL_ROOT = "sourceLevel"; //NOI18N |
171 |
static final String SOURCE_LEVEL_ROOT = "sourceLevel"; //NOI18N |
172 |
static final String EXTRA_COMPILER_OPTIONS = "extraCompilerOptions"; //NOI18N |
172 |
static final String EXTRA_COMPILER_OPTIONS = "extraCompilerOptions"; //NOI18N |
173 |
static final String CLASSPATH_ATTRIBUTE = "classPath"; //NOI18N |
173 |
static final String CLASSPATH_ATTRIBUTE = "classPath"; //NOI18N |
|
|
174 |
static final String DIGEST = "digest"; //NOI18N |
174 |
|
175 |
|
175 |
//non-final, non-private for tests... |
176 |
//non-final, non-private for tests... |
176 |
static int DELAY = Utilities.isWindows() ? 2000 : 1000; |
177 |
static int DELAY = Utilities.isWindows() ? 2000 : 1000; |
Lines 1788-1794
Link Here
|
1788 |
Iterable<? extends File> children, Iterable<? extends File> virtualChildren, |
1789 |
Iterable<? extends File> children, Iterable<? extends File> virtualChildren, |
1789 |
boolean clean, ProgressHandle handle, JavaFileFilterImplementation filter, |
1790 |
boolean clean, ProgressHandle handle, JavaFileFilterImplementation filter, |
1790 |
Map<String,List<File>> resources, Set<File> compiledFiles, Set<File> toRecompile, |
1791 |
Map<String,List<File>> resources, Set<File> compiledFiles, Set<File> toRecompile, |
1791 |
Map<URI, List<String>> misplacedSource2FQNs, boolean allowCancel, boolean generateVirtual) throws IOException { |
1792 |
Map<URI, List<String>> misplacedSource2FQNs, boolean allowCancel, boolean generateVirtual) |
|
|
1793 |
throws IOException |
1794 |
{ |
1795 |
parseFiles(root, classCache, isInitialCompilation, children, |
1796 |
virtualChildren, clean, handle, filter, resources, compiledFiles, |
1797 |
toRecompile, misplacedSource2FQNs, allowCancel, generateVirtual, |
1798 |
true, null); |
1799 |
} |
1800 |
|
1801 |
private void parseFiles(URL root, final File classCache, boolean isInitialCompilation, |
1802 |
Iterable<? extends File> children, Iterable<? extends File> virtualChildren, |
1803 |
boolean clean, ProgressHandle handle, JavaFileFilterImplementation filter, |
1804 |
Map<String,List<File>> resources, Set<File> compiledFiles, Set<File> toRecompile, |
1805 |
Map<URI, List<String>> misplacedSource2FQNs, boolean allowCancel, boolean generateVirtual, |
1806 |
boolean digestChanged, File folderFile) throws IOException { |
1807 |
|
1792 |
assert !allowCancel || compiledFiles != null; |
1808 |
assert !allowCancel || compiledFiles != null; |
1793 |
LOGGER.fine("parseFiles: " + root); |
1809 |
LOGGER.fine("parseFiles: " + root); |
1794 |
final FileObject rootFo = URLMapper.findFileObject(root); |
1810 |
final FileObject rootFo = URLMapper.findFileObject(root); |
Lines 1876-1881
Link Here
|
1876 |
if (uqImpl == null) { |
1892 |
if (uqImpl == null) { |
1877 |
//IDE is exiting, indeces are already closed. |
1893 |
//IDE is exiting, indeces are already closed. |
1878 |
return; |
1894 |
return; |
|
|
1895 |
} |
1896 |
if (clean == false && digestChanged == false) { |
1897 |
// no need to recompile whole root and no change detected |
1898 |
// in source root. |
1899 |
return; |
1900 |
} |
1901 |
if (resources == null && folderFile != null) { |
1902 |
resources = getAllClassFiles(classCache, FileObjects.getRelativePath(rootFile, folderFile), true); |
1879 |
} |
1903 |
} |
1880 |
SourceAnalyser sa = uqImpl.getSourceAnalyser(); |
1904 |
SourceAnalyser sa = uqImpl.getSourceAnalyser(); |
1881 |
assert sa != null; |
1905 |
assert sa != null; |
Lines 2174-2188
Link Here
|
2174 |
Map<String, List<File>> resources = Collections.<String, List<File>>emptyMap(); |
2198 |
Map<String, List<File>> resources = Collections.<String, List<File>>emptyMap(); |
2175 |
final FileList children = new FileList(folderFile); |
2199 |
final FileList children = new FileList(folderFile); |
2176 |
Set<File> compiledFiles = new HashSet<File>(); |
2200 |
Set<File> compiledFiles = new HashSet<File>(); |
2177 |
children.getJavaFiles(); |
2201 |
parseFiles(root, classCache, isInitialCompilation, |
2178 |
if (children.digestChanged()) { |
2202 |
children.getJavaFiles(), children.getVirtualJavaFiles(), |
2179 |
resources = getAllClassFiles(classCache, FileObjects.getRelativePath(rootFile, folderFile), true); |
2203 |
clean, handle, filter, null, compiledFiles, null, misplacedSource2FQNs, |
2180 |
parseFiles(root, classCache, isInitialCompilation, |
2204 |
false, true, children.digestChanged(), folderFile); |
2181 |
children.getJavaFiles(), children.getVirtualJavaFiles(), |
|
|
2182 |
clean, handle, filter, resources, compiledFiles, null, misplacedSource2FQNs, false, true); |
2183 |
} else { |
2184 |
ClassIndexManager.getDefault().createUsagesQuery(root, true); |
2185 |
} |
2186 |
|
2205 |
|
2187 |
if (!misplacedSource2FQNs.isEmpty()) { |
2206 |
if (!misplacedSource2FQNs.isEmpty()) { |
2188 |
if (LOGGER.isLoggable(Level.FINE)) { |
2207 |
if (LOGGER.isLoggable(Level.FINE)) { |
Lines 2753-2777
Link Here
|
2753 |
|
2772 |
|
2754 |
private void computeDigest(File root, final List<File> javaFiles) { |
2773 |
private void computeDigest(File root, final List<File> javaFiles) { |
2755 |
StringBuilder sb = new StringBuilder(200); |
2774 |
StringBuilder sb = new StringBuilder(200); |
2756 |
sb.append(SourceLevelQuery.getSourceLevel(FileUtil.toFileObject(root))); |
|
|
2757 |
for (File f : javaFiles) { |
2775 |
for (File f : javaFiles) { |
2758 |
sb.append(f.getPath()).append(f.lastModified()); |
2776 |
sb.append(f.getPath()).append(f.lastModified()); |
2759 |
} |
2777 |
} |
2760 |
try { |
2778 |
try { |
2761 |
MessageDigest md5 = MessageDigest.getInstance("MD5"); |
2779 |
MessageDigest md5 = MessageDigest.getInstance("MD5"); // NOI18N |
2762 |
byte[] b = sb.toString().getBytes(); |
2780 |
byte[] b = sb.toString().getBytes(); |
2763 |
byte[] digest = md5.digest(b); |
2781 |
byte[] digest = md5.digest(b); |
2764 |
URL rootUrl = root.toURI().toURL(); |
2782 |
URL rootUrl = root.toURI().toURL(); |
2765 |
Properties prop = loadProperties(rootUrl); |
2783 |
String data = getAttribute(rootUrl, DIGEST, null); |
2766 |
String data = prop.getProperty("digest"); |
2784 |
if (data != null && getAttribute(rootUrl, DIRTY_ROOT, null) == null) { |
2767 |
if (data != null) { |
|
|
2768 |
String newDigest = printDigest(digest); |
2785 |
String newDigest = printDigest(digest); |
2769 |
if (data.equals(newDigest) == true) { |
2786 |
if (data.equals(newDigest) == true) { |
2770 |
digestChanged = false; |
2787 |
digestChanged = false; |
|
|
2788 |
return; |
2771 |
} |
2789 |
} |
2772 |
} |
2790 |
} |
2773 |
prop.put("digest", printDigest(digest)); |
2791 |
ensureAttributeValue(rootUrl, DIGEST, printDigest(digest), true); |
2774 |
storeProperties(rootUrl, prop); |
|
|
2775 |
} catch (IOException e) { |
2792 |
} catch (IOException e) { |
2776 |
} catch (NoSuchAlgorithmException ex) { |
2793 |
} catch (NoSuchAlgorithmException ex) { |
2777 |
Exceptions.printStackTrace(ex); |
2794 |
Exceptions.printStackTrace(ex); |