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 42666
Collapse All | Expand All

(-)ant/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.apache.tools.ant.module/3
2
OpenIDE-Module: org.apache.tools.ant.module/3
3
OpenIDE-Module-Localizing-Bundle: org/apache/tools/ant/module/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/apache/tools/ant/module/Bundle.properties
4
OpenIDE-Module-Specification-Version: 3.9
4
OpenIDE-Module-Specification-Version: 3.10
5
OpenIDE-Module-Install: org/apache/tools/ant/module/AntModule.class
5
OpenIDE-Module-Install: org/apache/tools/ant/module/AntModule.class
6
OpenIDE-Module-Layer: org/apache/tools/ant/module/resources/AntModuleLayer.xml
6
OpenIDE-Module-Layer: org/apache/tools/ant/module/resources/AntModuleLayer.xml
7
OpenIDE-Module-Requires: 
7
OpenIDE-Module-Requires: 
(-)ant/api/doc/changes/apichanges.xml (+30 lines)
Lines 77-82 Link Here
77
<!-- ACTUAL CHANGES BEGIN HERE: -->
77
<!-- ACTUAL CHANGES BEGIN HERE: -->
78
78
79
  <changes>
79
  <changes>
80
  
81
        <change id="AntOutputStream.writeLine.URL">
82
            <api name="general"/>
83
            <summary><code>AntOutputStream</code> should be passed <code>URL</code> not <code>FileObject</code></summary>
84
            <version major="3" minor="10"/>
85
            <date day="30" month="4" year="2004"/>
86
            <author login="jglick"/>
87
            <compatibility addition="yes" deprecation="yes" source="compatible" semantic="compatible">
88
                <p>
89
                    Old subclasses of <code>AntOutputStream</code> should continue
90
                    to work unmodified. But new subclasses which override the new
91
                    method taking URL must return <code>true</code> so that the
92
                    old method is not called. The old method is now non-final but
93
                    cannot be called. The new method is non-final but should be
94
                    treated as abstract.
95
                </p>
96
            </compatibility>
97
            <description>
98
                <p>
99
                    Formerly <code>AntOutputStream</code> was passed a <code>FileObject</code>
100
                    parameter in <code>writeLine</code>. However that was potentially
101
                    inefficient as it required a <code>FileObject</code> to be created for
102
                    each hyperlink, if it was never activated. The former <code>writeLine</code>
103
                    method has been deprecated and subclasses should now override the new
104
                    variant that takes <code>URL</code> (and should return <code>true</code>).
105
                </p>
106
            </description>
107
            <class package="org.apache.tools.ant.module.spi" name="AntOutputStream"/>
108
            <issue number="42666"/>
109
        </change>
80
110
81
        <change id="ActionUtils">
111
        <change id="ActionUtils">
82
            <api name="general"/>
112
            <api name="general"/>
(-)ant/src/org/apache/tools/ant/module/run/AntOutputParser.java (-23 / +18 lines)
Lines 74-80 Link Here
74
        "The following error occurred while executing this line:|Following error occured while executing this line|/nbproject/build-impl\\.xml:"); // NOI18N
74
        "The following error occurred while executing this line:|Following error occured while executing this line|/nbproject/build-impl\\.xml:"); // NOI18N
75
    
75
    
76
    /** returns a hyperlink for the line, or null if not apropos */
76
    /** returns a hyperlink for the line, or null if not apropos */
77
    public AntOutputParser.Result parse(String line) {
77
    public AntOutputParser.Result parse(String line) throws IOException {
78
78
79
        //debug("Analyzing: " + line);
79
        //debug("Analyzing: " + line);
80
        
80
        
Lines 100-106 Link Here
100
                if (source != null) {
100
                if (source != null) {
101
                    // Got it!
101
                    // Got it!
102
                    //debug("Found " + source + " in derived source root " + root);
102
                    //debug("Found " + source + " in derived source root " + root);
103
                    return new AntOutputParser.Result(source, lineNumber, -1, -1, -1, guessExceptionMessage());
103
                    return new AntOutputParser.Result(source.getURL(), lineNumber, -1, -1, -1, guessExceptionMessage());
104
                }
104
                }
105
            }
105
            }
106
            // Also check global sourcepath (sources of open projects, and sources
106
            // Also check global sourcepath (sources of open projects, and sources
Lines 111-117 Link Here
111
            FileObject source = GlobalPathRegistry.getDefault().findResource(resource);
111
            FileObject source = GlobalPathRegistry.getDefault().findResource(resource);
112
            if (source != null) {
112
            if (source != null) {
113
                //debug("Found " + source + " in global source root " + root);
113
                //debug("Found " + source + " in global source root " + root);
114
                return new AntOutputParser.Result(source, lineNumber, -1, -1, -1, guessExceptionMessage());
114
                return new AntOutputParser.Result(source.getURL(), lineNumber, -1, -1, -1, guessExceptionMessage());
115
            }
115
            }
116
        } else {
116
        } else {
117
            // Track the last line which was not a stack trace - probably the exception message.
117
            // Track the last line which was not a stack trace - probably the exception message.
Lines 160-167 Link Here
160
            return null;
160
            return null;
161
        }
161
        }
162
        String fileName = line.substring (0, colon1); //.replace(File.separatorChar, '/');
162
        String fileName = line.substring (0, colon1); //.replace(File.separatorChar, '/');
163
        FileObject fo = findFO(fileName);
163
        File file = FileUtil.normalizeFile(new File(fileName));
164
        if (fo == null) {
164
        if (!file.exists()) {
165
            //debug (" result: no FO for "+fileName); // NOI18N
165
            //debug (" result: no FO for "+fileName); // NOI18N
166
            // maybe we are on windows and filename is "c:\temp\file.java:25"
166
            // maybe we are on windows and filename is "c:\temp\file.java:25"
167
            // try to do the same for the second colon
167
            // try to do the same for the second colon
Lines 171-178 Link Here
171
                return null;
171
                return null;
172
            }
172
            }
173
            fileName = line.substring (0, colon1);
173
            fileName = line.substring (0, colon1);
174
            fo = findFO(fileName);
174
            file = FileUtil.normalizeFile(new File(fileName));
175
            if (fo == null) {
175
            if (!file.exists()) {
176
                //debug (" result: no FO for "+fileName); // NOI18N
176
                //debug (" result: no FO for "+fileName); // NOI18N
177
                return null;
177
                return null;
178
            }
178
            }
Lines 212-218 Link Here
212
        }
212
        }
213
        //debug (" result: [" + fo + "," +line1 + "," +col1 + "," +line2 + "," +col2 + "," +message + "]"); // NOI18N
213
        //debug (" result: [" + fo + "," +line1 + "," +col1 + "," +line2 + "," +col2 + "," +message + "]"); // NOI18N
214
        //debug("Found " + fo + " ~ " + fileName);
214
        //debug("Found " + fo + " ~ " + fileName);
215
        return new AntOutputParser.Result(fo, line1, col1, line2, col2, message);
215
        return new AntOutputParser.Result(file.toURI().toURL(), line1, col1, line2, col2, message);
216
    }
216
    }
217
    
217
    
218
    /**
218
    /**
Lines 264-274 Link Here
264
        return null;
264
        return null;
265
    }
265
    }
266
    
266
    
267
    private FileObject findFO(String name) {
268
        File f = FileUtil.normalizeFile(new File(name));
269
        return FileUtil.toFileObject(f);
270
    }
271
    
272
    /*
267
    /*
273
    private static PrintWriter debugwriter = null;
268
    private static PrintWriter debugwriter = null;
274
    private static void debug(String s) {
269
    private static void debug(String s) {
Lines 287-301 Link Here
287
    /** Class describing successfully parsed line.
282
    /** Class describing successfully parsed line.
288
     */
283
     */
289
    public static final class Result {
284
    public static final class Result {
290
        private FileObject fo;
285
        private final URL url;
291
        private int line1;
286
        private final int line1;
292
        private int col1;
287
        private final int col1;
293
        private int line2;
288
        private final int line2;
294
        private int col2;
289
        private final int col2;
295
        private String message;
290
        private final String message;
296
        
291
        
297
        public Result(FileObject fo, int line1, int col1, int line2, int col2, String message) {
292
        public Result(URL url, int line1, int col1, int line2, int col2, String message) {
298
            this.fo = fo;
293
            this.url = url;
299
            this.line1 = line1;
294
            this.line1 = line1;
300
            this.col1 = col1;
295
            this.col1 = col1;
301
            this.line2 = line2;
296
            this.line2 = line2;
Lines 303-310 Link Here
303
            this.message = message;
298
            this.message = message;
304
        }
299
        }
305
        
300
        
306
        public FileObject getFileObject() {
301
        public URL getURL() {
307
            return fo;
302
            return url;
308
        }
303
        }
309
        
304
        
310
        public int getLineStart() {
305
        public int getLineStart() {
(-)ant/src/org/apache/tools/ant/module/run/OutputWriterOutputStream.java (-11 / +12 lines)
Lines 18-23 Link Here
18
import java.awt.Toolkit;
18
import java.awt.Toolkit;
19
import java.beans.*;
19
import java.beans.*;
20
import java.io.*;
20
import java.io.*;
21
import java.net.URL;
21
import java.util.*;
22
import java.util.*;
22
23
23
import org.openide.*;
24
import org.openide.*;
Lines 51-59 Link Here
51
        writer.close();
52
        writer.close();
52
    }
53
    }
53
54
54
    protected void writeLine(String line, FileObject file, int line1, int col1, int line2, int col2, String message) throws IOException {
55
    protected boolean writeLine(String line, URL file, int line1, int col1, int line2, int col2, String message) throws IOException {
55
        Hyperlink h = new Hyperlink(file, line1, col1, line2, col2, message);
56
        Hyperlink h = new Hyperlink(file, line1, col1, line2, col2, message);
56
        writer.println(line, h);
57
        writer.println(line, h);
58
        return true; // it worked, do not use deprecated variant of the method
57
    }
59
    }
58
    
60
    
59
    protected void writeLine(String line) throws IOException {
61
    protected void writeLine(String line) throws IOException {
Lines 72-88 Link Here
72
    }
74
    }
73
75
74
    /** Represents a linkable line (appears in red in Output Window...).
76
    /** Represents a linkable line (appears in red in Output Window...).
75
     * Its functionality could be replaced in the future by ErrorEvent's from the Compiler API
76
     * (though something like the HyperlinkFactory would have to remain).
77
     * This would also handle the proper error highlighting and so on.
78
     */
77
     */
79
    private static final class Hyperlink extends Annotation implements OutputListener, PropertyChangeListener {
78
    private static final class Hyperlink extends Annotation implements OutputListener, PropertyChangeListener {
80
        private FileObject file; // file to jump to
79
        private URL url; // file to jump to
81
        private int line1, col1, line2, col2; // line/col number to jump to, 0-based, -1 for unspecified
80
        private int line1, col1, line2, col2; // line/col number to jump to, 0-based, -1 for unspecified
82
        private String message; // message it is saying, or null
81
        private String message; // message it is saying, or null
83
        private boolean dead = false; // whether it has been destroyed
82
        private boolean dead = false; // whether it has been destroyed
84
        Hyperlink (FileObject file, int line1, int col1, int line2, int col2, String message) {
83
        Hyperlink(URL url, int line1, int col1, int line2, int col2, String message) {
85
            this.file = file;
84
            this.url = url;
86
            this.line1 = line1;
85
            this.line1 = line1;
87
            this.col1 = col1;
86
            this.col1 = col1;
88
            this.line2 = line2;
87
            this.line2 = line2;
Lines 100-106 Link Here
100
        // OutputListener:
99
        // OutputListener:
101
        public void outputLineAction (OutputEvent ev) {
100
        public void outputLineAction (OutputEvent ev) {
102
            if (dead) return;
101
            if (dead) return;
103
            if (! file.isValid ()) { // #13115
102
            FileObject file = URLMapper.findFileObject(url);
103
            if (file == null) { // #13115
104
                Toolkit.getDefaultToolkit ().beep ();
104
                Toolkit.getDefaultToolkit ().beep ();
105
                return;
105
                return;
106
            }
106
            }
Lines 146-152 Link Here
146
        }
146
        }
147
        public void outputLineSelected (OutputEvent ev) {
147
        public void outputLineSelected (OutputEvent ev) {
148
            if (dead) return;
148
            if (dead) return;
149
            if (! file.isValid ()) {
149
            FileObject file = URLMapper.findFileObject(url);
150
            if (file == null) {
150
                return;
151
                return;
151
            }
152
            }
152
            try {
153
            try {
Lines 193-199 Link Here
193
                        if (log) AntModule.err.log("\tspecified section of the line");
194
                        if (log) AntModule.err.log("\tspecified section of the line");
194
                        ann = l.createPart(new_col1, new_col2 - new_col1 + 1);
195
                        ann = l.createPart(new_col1, new_col2 - new_col1 + 1);
195
                    } else if (new_col1 < text.length()) {
196
                    } else if (new_col1 < text.length()) {
196
                        if (log) AntModule.err.log("\tspecified umn to end of line");
197
                        if (log) AntModule.err.log("\tspecified column to end of line");
197
                        ann = l.createPart(new_col1, text.length() - new_col1 - 1);
198
                        ann = l.createPart(new_col1, text.length() - new_col1 - 1);
198
                    } else {
199
                    } else {
199
                        if (log) AntModule.err.log("\tcolumn numbers are bogus");
200
                        if (log) AntModule.err.log("\tcolumn numbers are bogus");
Lines 274-280 Link Here
274
        }
275
        }
275
        // Debugging:
276
        // Debugging:
276
        public String toString () {
277
        public String toString () {
277
            return "Hyperlink[" + file + ":" + line1 + ":" + col1 + ":" + line2 + ":" + col2 + "]"; // NOI18N
278
            return "Hyperlink[" + url + ":" + line1 + ":" + col1 + ":" + line2 + ":" + col2 + "]"; // NOI18N
278
        }
279
        }
279
    }
280
    }
280
281
(-)ant/src/org/apache/tools/ant/module/spi/AntOutputStream.java (-3 / +41 lines)
Lines 19-28 Link Here
19
import java.io.IOException;
19
import java.io.IOException;
20
import java.io.OutputStream;
20
import java.io.OutputStream;
21
import java.lang.StringBuffer;
21
import java.lang.StringBuffer;
22
import java.net.MalformedURLException;
23
import java.net.URL;
22
24
23
import org.apache.tools.ant.module.AntModule;
25
import org.apache.tools.ant.module.AntModule;
24
import org.apache.tools.ant.module.run.AntOutputParser;
26
import org.apache.tools.ant.module.run.AntOutputParser;
27
import org.openide.ErrorManager;
25
import org.openide.filesystems.FileObject;
28
import org.openide.filesystems.FileObject;
29
import org.openide.filesystems.URLMapper;
26
import org.openide.util.NbBundle;
30
import org.openide.util.NbBundle;
27
31
28
/** OutputStream for wrapping output of Ant task and capable of
32
/** OutputStream for wrapping output of Ant task and capable of
Lines 120-133 Link Here
120
            antOutputParser.setClasspath(cp);
124
            antOutputParser.setClasspath(cp);
121
            return; // do not actually print it!
125
            return; // do not actually print it!
122
        }
126
        }
123
        AntOutputParser.Result r = antOutputParser.parse(l);
127
        AntOutputParser.Result r;
128
        try {
129
            r = antOutputParser.parse(l);
130
        } catch (IOException e) {
131
            r = null;
132
            AntModule.err.notify(ErrorManager.INFORMATIONAL, e);
133
        }
124
        if (r == null) {
134
        if (r == null) {
125
            writeLine(l);
135
            writeLine(l);
126
        } else {
136
        } else {
127
            writeLine(l, r.getFileObject(), r.getLineStart(), r.getColumnStart(), r.getLineEnd(), r.getColumnEnd(), r.getMessage());
137
            URL u = r.getURL();
138
            if (!writeLine(l, u, r.getLineStart(), r.getColumnStart(), r.getLineEnd(), r.getColumnEnd(), r.getMessage())) {
139
                // Fallback for old subclasses of AOS - compatibility. Cf. #42666.
140
                FileObject f = URLMapper.findFileObject(u);
141
                if (f != null) {
142
                    writeLine(l, f, r.getLineStart(), r.getColumnStart(), r.getLineEnd(), r.getColumnEnd(), r.getMessage());
143
                }
144
            }
128
        }
145
        }
129
    }
146
    }
130
147
148
    /**
149
     * Write one line of the parsed text (<strong>must be overridden</strong>).
150
     * All line and column parameters can be -1 meaning
151
     * that the value was not available or parsing was not successful.
152
     * @param line original text of the line
153
     * @param file file location for which this line was generated
154
     * @param line1 starting line of the message
155
     * @param col1 starting column of the message
156
     * @param line2 ending line of the message
157
     * @param col2 ending column of the message
158
     * @param message message
159
     * @return must always return true
160
     * @since org.apache.tools.ant.module/3 3.10
161
     */
162
    protected boolean writeLine(String line, URL file, int line1, int col1, int line2, int col2, String message) throws IOException {
163
        return false;
164
    }
165
131
    /** Write one line of the parsed text. All line and column parameters can be -1 what means
166
    /** Write one line of the parsed text. All line and column parameters can be -1 what means
132
    * that value was not available or parsing was not successful.
167
    * that value was not available or parsing was not successful.
133
    * @param line original text of the line
168
    * @param line original text of the line
Lines 137-144 Link Here
137
    * @param line2 ending line of the message
172
    * @param line2 ending line of the message
138
    * @param col2 ending column of the message
173
    * @param col2 ending column of the message
139
    * @param message message 
174
    * @param message message 
175
     * @deprecated Please override the variant taking URL instead, since org.apache.tools.ant.module/3 3.10.
140
    */
176
    */
141
    abstract protected void writeLine(String line, FileObject file, int line1, int col1, int line2, int col2, String message) throws IOException;
177
    protected void writeLine(String line, FileObject file, int line1, int col1, int line2, int col2, String message) throws IOException {
178
        throw new IllegalStateException("writeLine(...URL...) must return true if writeLine(...FileObject...) is not implemented"); // NOI18N
179
    }
142
180
143
    /** Write one line of text which was not parsed.
181
    /** Write one line of text which was not parsed.
144
     */
182
     */

Return to bug 42666