--- a/cnd.utils/nbproject/project.xml Tue Oct 04 17:46:49 2011 +0400
+++ a/cnd.utils/nbproject/project.xml Wed Oct 05 00:54:53 2011 +0400
@@ -146,6 +146,7 @@
org.netbeans.modules.cnd.testrunner
org.netbeans.modules.cnd.tha
org.netbeans.modules.cnd.toolchain
+ org.netbeans.modules.dlight.annotationsupport
org.netbeans.modules.dlight.discover
org.netbeans.modules.dlight.previse
org.netbeans.modules.dlight.tha
--- a/dlight.annotationsupport/nbproject/project.xml Tue Oct 04 17:46:49 2011 +0400
+++ a/dlight.annotationsupport/nbproject/project.xml Wed Oct 05 00:54:53 2011 +0400
@@ -6,6 +6,14 @@
org.netbeans.modules.dlight.annotationsupport
+ org.netbeans.modules.cnd.utils
+
+
+
+ 1.10.4
+
+
+
org.netbeans.modules.dlight
--- a/dlight.annotationsupport/src/org/netbeans/modules/dlight/annotationsupport/AnnotatedSourceSupportImpl.java Tue Oct 04 17:46:49 2011 +0400
+++ a/dlight.annotationsupport/src/org/netbeans/modules/dlight/annotationsupport/AnnotatedSourceSupportImpl.java Wed Oct 05 00:54:53 2011 +0400
@@ -54,16 +54,15 @@
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import org.netbeans.api.editor.EditorRegistry;
+import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
import org.netbeans.modules.dlight.api.storage.DataTableMetadata.Column;
import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric;
import org.netbeans.modules.dlight.core.stack.api.support.FunctionMetricFormatter;
import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider;
import org.netbeans.modules.dlight.core.stack.spi.AnnotatedSourceSupport;
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
-import org.netbeans.modules.dlight.spi.SourceSupportProvider.FileObjectsToSourceMap;
import org.netbeans.modules.dlight.util.DLightExecutorService;
import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.util.Lookup;
@@ -92,6 +91,24 @@
}
return instance;
}
+
+ private String getCacheKey(final FileObject fileObject) {
+ if (fileObject == null) {
+ return null;
+ }
+
+ CharSequence url = CndFileUtils.fileObjectToUrl(fileObject);
+ return url == null ? null : url.toString();
+ }
+
+ private String getCacheKey(final CharSequence filePath) {
+ FileObject fo = CndFileUtils.toFileObject(filePath);
+ String result = getCacheKey(fo);
+ if (result != null) {
+ return result;
+ }
+ return filePath.toString();
+ }
private synchronized void preProcessAnnotations(SourceFileInfoDataProvider sourceFileInfoProvider, List metrics, List list, boolean lineAnnotations) {
if (list == null || list.size() == 0) {
@@ -102,16 +119,14 @@
if (sourceFileInfo != null) {
if (sourceFileInfo.isSourceKnown()) {
String filePath = sourceFileInfo.getFileName();
- if (new File(filePath).exists()) {
- filePath = FileUtil.normalizePath(filePath);
- }
- FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(filePath);
+ String key = getCacheKey(filePath);
+ FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(key);
if (fileAnnotationInfo == null) {
fileAnnotationInfo = new FileAnnotationInfo();
fileAnnotationInfo.setFilePath(filePath);
fileAnnotationInfo.setColumnNames(new String[metrics.size()]);
fileAnnotationInfo.setMaxColumnWidth(new int[metrics.size()]);
- activeAnnotations.put(filePath, fileAnnotationInfo);
+ activeAnnotations.put(key, fileAnnotationInfo);
}
LineAnnotationInfo lineAnnotationInfo = new LineAnnotationInfo(fileAnnotationInfo);
lineAnnotationInfo.setLine(sourceFileInfo.getLine());
@@ -154,7 +169,7 @@
}
public synchronized FileAnnotationInfo getFileAnnotationInfo(String filePath) {
- return activeAnnotations.get(filePath);
+ return activeAnnotations.get(getCacheKey(filePath));
}
public synchronized void updateSource(SourceFileInfoDataProvider sourceFileInfoProvider, List metrics, List list, List functionCalls) {
@@ -187,29 +202,21 @@
}
}
- private String fileFromEditorPane(JTextComponent jEditorPane) {
- String ret = null;
+ private FileObject getFileObjectFromEditorPane(JTextComponent jEditorPane) {
+ if (jEditorPane != null) {
+ Document doc = jEditorPane.getDocument();
+ if (doc != null) {
+ Object source = doc.getProperty(Document.StreamDescriptionProperty);
- if (jEditorPane != null) {
- Object source = jEditorPane.getDocument().getProperty(Document.StreamDescriptionProperty);
- if (source instanceof DataObject) {
- FileObject fo = ((DataObject) source).getPrimaryFile();
- ret = FileObjectsToSourceMap.getInstance().get(fo);
- if (ret == null) {
- ret = (String)fo.getAttribute("URI"); // NOI18N
- }
- if (ret == null && FileUtil.toFile(fo) != null) {
- ret = FileUtil.toFile(fo).getPath();
- }
- if (ret != null) {
- ret = FileUtil.normalizePath(ret);
+ if (source instanceof DataObject) {
+ FileObject fo = ((DataObject) source).getPrimaryFile();
+ return fo;
}
}
}
-
- return ret;
+ return null;
}
-
+
private synchronized void annotateCurrentFocusedFiles() {
// FIXUP: could there be more than one file in view?
if (activeAnnotations.size() == 0) {
@@ -220,9 +227,11 @@
jEditorPane = EditorRegistry.lastFocusedComponent();
}
if (jEditorPane != null) {
- String fileURI = fileFromEditorPane(jEditorPane);
- if (fileURI != null) {
- final FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(fileURI);
+ FileObject fileObject = getFileObjectFromEditorPane(jEditorPane);
+ String key = getCacheKey(fileObject);
+ if (key != null) {
+ FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(key);
+
if (fileAnnotationInfo != null) {
// if (!fileAnnotationInfo.isAnnotated()) {
fileAnnotationInfo.setEditorPane((JEditorPane) jEditorPane);