This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 203102
Collapse All | Expand All

(-)a/dlight.annotationsupport/nbproject/project.xml (+8 lines)
Lines 22-27 Link Here
22
                    </run-dependency>
22
                    </run-dependency>
23
                </dependency>
23
                </dependency>
24
                <dependency>
24
                <dependency>
25
                    <code-name-base>org.netbeans.modules.dlight.remote</code-name-base>
26
                    <build-prerequisite/>
27
                    <compile-dependency/>
28
                    <run-dependency>
29
                        <specification-version>1.9.5</specification-version>
30
                    </run-dependency>
31
                </dependency>
32
                <dependency>
25
                    <code-name-base>org.netbeans.modules.dlight.spi</code-name-base>
33
                    <code-name-base>org.netbeans.modules.dlight.spi</code-name-base>
26
                    <build-prerequisite/>
34
                    <build-prerequisite/>
27
                    <compile-dependency/>
35
                    <compile-dependency/>
(-)a/dlight.annotationsupport/src/org/netbeans/modules/dlight/annotationsupport/AnnotatedSourceSupportImpl.java (-30 / +38 lines)
Lines 43-49 Link Here
43
43
44
import java.beans.PropertyChangeEvent;
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeListener;
46
import java.io.File;
47
import java.util.HashMap;
46
import java.util.HashMap;
48
import java.util.HashSet;
47
import java.util.HashSet;
49
import java.util.List;
48
import java.util.List;
Lines 60-69 Link Here
60
import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider;
59
import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider;
61
import org.netbeans.modules.dlight.core.stack.spi.AnnotatedSourceSupport;
60
import org.netbeans.modules.dlight.core.stack.spi.AnnotatedSourceSupport;
62
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
61
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
63
import org.netbeans.modules.dlight.spi.SourceSupportProvider.FileObjectsToSourceMap;
64
import org.netbeans.modules.dlight.util.DLightExecutorService;
62
import org.netbeans.modules.dlight.util.DLightExecutorService;
63
import org.netbeans.modules.remote.spi.FileSystemProvider;
65
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
66
import org.openide.filesystems.FileUtil;
67
import org.openide.loaders.DataObject;
65
import org.openide.loaders.DataObject;
68
import org.openide.util.Lookup;
66
import org.openide.util.Lookup;
69
67
Lines 92-97 Link Here
92
        }
90
        }
93
        return instance;
91
        return instance;
94
    }
92
    }
93
    
94
    private String getCacheKey(final FileObject fileObject) {
95
        if (fileObject == null) {
96
            return null;
97
        }
98
        
99
        CharSequence url = FileSystemProvider.fileObjectToUrl(fileObject);
100
        return url == null ? null : url.toString();
101
    }
102
    
103
    private String getCacheKey(final String filePath) {
104
        FileObject fo = FileSystemProvider.urlToFileObject(filePath);
105
        String result = getCacheKey(fo);
106
        if (result != null) {
107
            return result;
108
        }
109
        return filePath.toString();
110
    }
95
111
96
    private synchronized void preProcessAnnotations(SourceFileInfoDataProvider sourceFileInfoProvider, List<Column> metrics, List<FunctionCallWithMetric> list, boolean lineAnnotations) {
112
    private synchronized void preProcessAnnotations(SourceFileInfoDataProvider sourceFileInfoProvider, List<Column> metrics, List<FunctionCallWithMetric> list, boolean lineAnnotations) {
97
        if (list == null || list.size() == 0) {
113
        if (list == null || list.size() == 0) {
Lines 102-117 Link Here
102
            if (sourceFileInfo != null) {
118
            if (sourceFileInfo != null) {
103
                if (sourceFileInfo.isSourceKnown()) {
119
                if (sourceFileInfo.isSourceKnown()) {
104
                    String filePath = sourceFileInfo.getFileName();
120
                    String filePath = sourceFileInfo.getFileName();
105
                    if (new File(filePath).exists()) {
121
                    String key = getCacheKey(filePath);
106
                        filePath = FileUtil.normalizePath(filePath);
122
                    FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(key);
107
                    }
108
                    FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(filePath);
109
                    if (fileAnnotationInfo == null) {
123
                    if (fileAnnotationInfo == null) {
110
                        fileAnnotationInfo = new FileAnnotationInfo();
124
                        fileAnnotationInfo = new FileAnnotationInfo();
111
                        fileAnnotationInfo.setFilePath(filePath);
125
                        fileAnnotationInfo.setFilePath(filePath);
112
                        fileAnnotationInfo.setColumnNames(new String[metrics.size()]);
126
                        fileAnnotationInfo.setColumnNames(new String[metrics.size()]);
113
                        fileAnnotationInfo.setMaxColumnWidth(new int[metrics.size()]);
127
                        fileAnnotationInfo.setMaxColumnWidth(new int[metrics.size()]);
114
                        activeAnnotations.put(filePath, fileAnnotationInfo);
128
                        activeAnnotations.put(key, fileAnnotationInfo);
115
                    }
129
                    }
116
                    LineAnnotationInfo lineAnnotationInfo = new LineAnnotationInfo(fileAnnotationInfo);
130
                    LineAnnotationInfo lineAnnotationInfo = new LineAnnotationInfo(fileAnnotationInfo);
117
                    lineAnnotationInfo.setLine(sourceFileInfo.getLine());
131
                    lineAnnotationInfo.setLine(sourceFileInfo.getLine());
Lines 154-160 Link Here
154
    }
168
    }
155
169
156
    public synchronized FileAnnotationInfo getFileAnnotationInfo(String filePath) {
170
    public synchronized FileAnnotationInfo getFileAnnotationInfo(String filePath) {
157
        return activeAnnotations.get(filePath);
171
        return activeAnnotations.get(getCacheKey(filePath));
158
    }
172
    }
159
173
160
    public synchronized void updateSource(SourceFileInfoDataProvider sourceFileInfoProvider, List<Column> metrics, List<FunctionCallWithMetric> list, List<FunctionCallWithMetric> functionCalls) {
174
    public synchronized void updateSource(SourceFileInfoDataProvider sourceFileInfoProvider, List<Column> metrics, List<FunctionCallWithMetric> list, List<FunctionCallWithMetric> functionCalls) {
Lines 187-215 Link Here
187
        }
201
        }
188
    }
202
    }
189
203
190
    private String fileFromEditorPane(JTextComponent jEditorPane) {
204
    private FileObject getFileObjectFromEditorPane(JTextComponent jEditorPane) {
191
        String ret = null;
205
        if (jEditorPane != null) {
206
            Document doc = jEditorPane.getDocument();
207
            if (doc != null) {
208
                Object source = doc.getProperty(Document.StreamDescriptionProperty);
192
209
193
        if (jEditorPane != null) {
210
                if (source instanceof DataObject) {
194
            Object source = jEditorPane.getDocument().getProperty(Document.StreamDescriptionProperty);
211
                    FileObject fo = ((DataObject) source).getPrimaryFile();
195
            if (source instanceof DataObject) {
212
                    return fo;
196
                FileObject fo = ((DataObject) source).getPrimaryFile();
197
                ret = FileObjectsToSourceMap.getInstance().get(fo);
198
                if (ret == null) {
199
                    ret = (String)fo.getAttribute("URI"); // NOI18N
200
                }
201
                if (ret == null && FileUtil.toFile(fo) != null) {
202
                    ret = FileUtil.toFile(fo).getPath();
203
                }
204
                if (ret != null) {
205
                    ret = FileUtil.normalizePath(ret);
206
                }
213
                }
207
            }
214
            }
208
        }
215
        }
209
216
        return null;
210
        return ret;
211
    }
217
    }
212
218
    
213
    private synchronized void annotateCurrentFocusedFiles() {
219
    private synchronized void annotateCurrentFocusedFiles() {
214
        // FIXUP: could there be more than one file in view?
220
        // FIXUP: could there be more than one file in view?
215
        if (activeAnnotations.size() == 0) {
221
        if (activeAnnotations.size() == 0) {
Lines 220-228 Link Here
220
            jEditorPane = EditorRegistry.lastFocusedComponent();
226
            jEditorPane = EditorRegistry.lastFocusedComponent();
221
        }
227
        }
222
        if (jEditorPane != null) {
228
        if (jEditorPane != null) {
223
            String fileURI = fileFromEditorPane(jEditorPane);
229
            FileObject fileObject = getFileObjectFromEditorPane(jEditorPane);
224
            if (fileURI != null) {
230
            String key = getCacheKey(fileObject);
225
                final FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(fileURI);
231
            if (key != null) {
232
                FileAnnotationInfo fileAnnotationInfo = activeAnnotations.get(key);
233
226
                if (fileAnnotationInfo != null) {
234
                if (fileAnnotationInfo != null) {
227
//                    if (!fileAnnotationInfo.isAnnotated()) {
235
//                    if (!fileAnnotationInfo.isAnnotated()) {
228
                    fileAnnotationInfo.setEditorPane((JEditorPane) jEditorPane);
236
                    fileAnnotationInfo.setEditorPane((JEditorPane) jEditorPane);
(-)a/dlight.remote/nbproject/project.xml (+1 lines)
Lines 114-119 Link Here
114
                <friend>org.netbeans.modules.cnd.remote</friend>
114
                <friend>org.netbeans.modules.cnd.remote</friend>
115
                <friend>org.netbeans.modules.cnd.tha</friend>
115
                <friend>org.netbeans.modules.cnd.tha</friend>
116
                <friend>org.netbeans.modules.cnd.toolchain</friend>
116
                <friend>org.netbeans.modules.cnd.toolchain</friend>
117
                <friend>org.netbeans.modules.dlight.annotationsupport</friend>
117
                <friend>org.netbeans.modules.dlight.discover</friend>
118
                <friend>org.netbeans.modules.dlight.discover</friend>
118
                <friend>org.netbeans.modules.dlight.previse</friend>
119
                <friend>org.netbeans.modules.dlight.previse</friend>
119
                <friend>org.netbeans.modules.dlight.remote.impl</friend>
120
                <friend>org.netbeans.modules.dlight.remote.impl</friend>

Return to bug 203102