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

(-)utilities/jumpto/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.netbeans.modules.jumpto/1
2
OpenIDE-Module: org.netbeans.modules.jumpto/1
3
OpenIDE-Module-Layer: org/netbeans/modules/jumpto/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/jumpto/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jumpto/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/jumpto/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.4
5
OpenIDE-Module-Specification-Version: 1.5
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)utilities/jumpto/src/org/netbeans/modules/jumpto/type/GoToTypeAction.java (-11 / +5 lines)
Lines 412-438 Link Here
412
        private List<? extends TypeDescriptor> getTypeNames(String text) {
412
        private List<? extends TypeDescriptor> getTypeNames(String text) {
413
            // TODO: Search twice, first for current project, then for all projects
413
            // TODO: Search twice, first for current project, then for all projects
414
            List<TypeDescriptor> items;
414
            List<TypeDescriptor> items;
415
            if (typeProviders.size() == 1) {
416
                items = (List<TypeDescriptor>) typeProviders.iterator().next().getTypeNames(null, text, nameKind);
417
            } else {
418
                // Multiple providers: merge results
415
                // Multiple providers: merge results
419
                items = new ArrayList<TypeDescriptor>(128);
416
                items = new ArrayList<TypeDescriptor>(128);
417
            String[] message = new String[1];
418
            TypeProvider.Context context = TypeProviderAccessor.DEFAULT.createContext(null, text, nameKind);
419
            TypeProvider.Result result = TypeProviderAccessor.DEFAULT.createResult(items, message);
420
                for (TypeProvider provider : typeProviders) {
420
                for (TypeProvider provider : typeProviders) {
421
                    if (isCanceled) {
421
                    if (isCanceled) {
422
                        return null;
422
                        return null;
423
                    }
423
                    }
424
                    List<? extends TypeDescriptor> list = provider.getTypeNames(null, text, nameKind);
424
                provider.computeTypeNames(context, result);
425
                    if (list != null) {
426
                        items.addAll(list);
427
                    }
425
                    }
428
                }
429
430
            }
431
            
432
            if ( !isCanceled ) {   
426
            if ( !isCanceled ) {   
433
                //time = System.currentTimeMillis();
427
                //time = System.currentTimeMillis();
434
                Collections.sort(items, new TypeComparator());
428
                Collections.sort(items, new TypeComparator());
435
429
                if (message[0] != null) System.err.println(message[0]);
436
                //sort += System.currentTimeMillis() - time;
430
                //sort += System.currentTimeMillis() - time;
437
                //LOGGER.fine("PERF - " + " GSS:  " + gss + " GSB " + gsb + " CP: " + cp + " SFB: " + sfb + " GTN: " + gtn + "  ADD: " + add + "  SORT: " + sort );
431
                //LOGGER.fine("PERF - " + " GSS:  " + gss + " GSB " + gsb + " CP: " + cp + " SFB: " + sfb + " GTN: " + gtn + "  ADD: " + add + "  SORT: " + sort );
438
                return items;
432
                return items;
(-)utilities/jumpto/src/org/netbeans/modules/jumpto/type/TypeProviderAccessor.java (+67 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 * 
35
 * Contributor(s):
36
 * 
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
package org.netbeans.modules.jumpto.type;
40
41
import java.util.List;
42
import org.netbeans.api.project.Project;
43
import org.netbeans.spi.jumpto.type.SearchType;
44
import org.netbeans.spi.jumpto.type.TypeDescriptor;
45
import static org.netbeans.spi.jumpto.type.TypeProvider.*;
46
47
/**
48
 * Accessor class.
49
 * 
50
 * @author Pavel Flaska
51
 */
52
public abstract class TypeProviderAccessor {
53
54
    public static TypeProviderAccessor DEFAULT;
55
56
    static {
57
        try {
58
            Class.forName(Context.class.getName(), true, Context.class.getClassLoader());
59
        } catch (Exception ex) {
60
            ex.printStackTrace();
61
        }
62
    }
63
64
    protected abstract Context createContext(Project p, String text, SearchType t);
65
66
    protected abstract Result createResult(List<? super TypeDescriptor> result, String[] message);
67
}
(-)utilities/jumpto/src/org/netbeans/spi/jumpto/type/TypeProvider.java (-8 / +109 lines)
Lines 42-49 Link Here
42
package org.netbeans.spi.jumpto.type;
42
package org.netbeans.spi.jumpto.type;
43
43
44
import java.util.List;
44
import java.util.List;
45
import org.netbeans.spi.jumpto.type.TypeDescriptor;
46
import org.netbeans.api.project.Project;
45
import org.netbeans.api.project.Project;
46
import org.netbeans.modules.jumpto.type.TypeProviderAccessor;
47
47
48
/**
48
/**
49
 * A Type Provider participates in the Goto Type dialog by providing TypeDescriptors,
49
 * A Type Provider participates in the Goto Type dialog by providing TypeDescriptors,
Lines 77-83 Link Here
77
    String getDisplayName();
77
    String getDisplayName();
78
    
78
    
79
    /** 
79
    /** 
80
     * Provide a list of TypeDescriptors that match the given search text for the given
80
     * Compute a list of TypeDescriptors that match the given search text for the given
81
     * search type. This might be a slow operation, and the infrastructure may end
81
     * search type. This might be a slow operation, and the infrastructure may end
82
     * up calling {@link #cancel} on the same type provider during the operation, in which
82
     * up calling {@link #cancel} on the same type provider during the operation, in which
83
     * case the method can return incomplete results. If there is a "current project",
83
     * case the method can return incomplete results. If there is a "current project",
Lines 92-104 Link Here
92
     * result. There is an explicit {@link #cleanup} call that the Go To Type dialog
92
     * result. There is an explicit {@link #cleanup} call that the Go To Type dialog
93
     * will make at the end of the dialog interaction, which can be used to clean up the cache.
93
     * will make at the end of the dialog interaction, which can be used to clean up the cache.
94
     * 
94
     * 
95
     * @param project If not null, limit the type search to the given project.
95
     * @param context search context containg search text and type, optionally project
96
     * @param text The text to be used for the search; e.g. when type=SearchType.PREFIX,
96
     * @param result  filled with type descriptors and optional message
97
     *   text is the prefix that all returned types should start with.
98
     * @param type A type of search to be performed, such as prefix, regexp or camel case.
99
     * @return A collection of TypeDescriptors that match the given search criteria
100
     */
97
     */
101
    List<? extends TypeDescriptor> getTypeNames(Project project, String text, SearchType type);
98
    void computeTypeNames(Context context, Result result);
102
99
103
    /**
100
    /**
104
     * Cancel the current operation, if possible. This might be called if the user
101
     * Cancel the current operation, if possible. This might be called if the user
Lines 116-119 Link Here
116
     * search is simply a narrower search, it can just filter the previous result.
113
     * search is simply a narrower search, it can just filter the previous result.
117
     */
114
     */
118
    void cleanup();
115
    void cleanup();
116
117
118
    /**
119
     * Represents search context.
120
     * Contains search type (such as prefix, regexp), search text and
121
     * optionally project where to search.
122
     *
123
     * @since 1.5
124
     */
125
    public static final class Context extends Object {
126
        private final Project project;
127
        private final String text;
128
        private final SearchType type;
129
        
130
        static {
131
            TypeProviderAccessor.DEFAULT = new TypeProviderAccessor() {
132
                @Override
133
                protected Context createContext(Project p, String text, SearchType t) {
134
                    return new Context(p, text, t);
135
                }
136
137
                @Override
138
                protected Result createResult(List<? super TypeDescriptor> result, String[] message) {
139
                    return new Result(result, message);
140
                }
141
            };
142
        }
143
        
144
        Context(Project project, String text, SearchType type) {
145
            this.project = project;
146
            this.text = text;
147
            this.type = type;
148
        }
149
        
150
        /**
151
         * Return project representing scope of search, if null, the search is not
152
         * limited.
153
         *
154
         * @return project If not null, the type search is limited to the given project.
155
         */
156
        public Project getProject() { return project; }
157
158
        /**
159
          * Return the text used for search.
160
          *
161
          * @return The text used for the search; e.g. when getSearchType() == SearchType.PREFIX,
162
          *   text is the prefix that all returned types should start with.
163
          */
164
        public String getText() { return text; }
165
166
        /**
167
         * Return the type of search.
168
         *
169
         * @return Type of search performed, such as prefix, regexp or camel case.
170
         */
171
        public SearchType getSearchType() { return type; }
172
    }
173
    
174
    /**
175
     * Represents a collection of <tt>TypeDescriptor</tt>s that match 
176
     * the given search criteria. Moreover, it can contain message 
177
     * for the user, such as an incomplete search result.
178
     *
179
     * @since 1.5
180
     */
181
    public static final class Result extends Object {
182
        
183
        private List<? super TypeDescriptor> result;
184
        private String[] message;
185
186
        Result(List<? super TypeDescriptor> result, String[] message) {
187
            this.result = result;
188
            this.message = message;
189
        }
190
        
191
        /**
192
         * Optional message. It can inform the user about result, e.g.
193
         * that result can be incomplete etc.
194
         * 
195
         * @param  msg  message
196
         */
197
        public void setMessage(String msg) {
198
            message[0] = msg;
199
        }
200
201
        /**
202
          * Adds result descriptor.
203
          *
204
          * @param  typeDescriptor  type descriptor to be added to result
205
          */
206
        public void addResult(TypeDescriptor typeDescriptor) {
207
            result.add(typeDescriptor);
208
        }
209
210
        /**
211
          * Adds list of result descriptors.
212
          *
213
          * @param  typeDescriptor  type descriptor to be added to result
214
          */
215
        public void addResult(List<? extends TypeDescriptor> typeDescriptor) {
216
            result.addAll(typeDescriptor);
217
        }
218
    }
219
119
}
220
}
(-)ruby/gsf/src/org/netbeans/modules/gsf/GsfTypeProvider.java (-8 / +9 lines)
Lines 46-52 Link Here
46
import java.util.Collections;
46
import java.util.Collections;
47
import java.util.EnumSet;
47
import java.util.EnumSet;
48
import java.util.HashSet;
48
import java.util.HashSet;
49
import java.util.List;
50
import java.util.Set;
49
import java.util.Set;
51
import java.util.logging.Logger;
50
import java.util.logging.Logger;
52
import javax.swing.Icon;
51
import javax.swing.Icon;
Lines 204-210 Link Here
204
    
203
    
205
204
206
    //@Override
205
    //@Override
207
       public List<? extends TypeDescriptor> getTypeNames(Project project, String text, SearchType nameKind) {
206
    public void computeTypeNames(Context context, Result res) {
207
        String text = context.getText();
208
        SearchType nameKind = context.getSearchType();
208
        
209
        
209
            long time;
210
            long time;
210
            
211
            
Lines 227-233 Link Here
227
                    LOGGER.fine("GoToTypeAction.getTypeNames created ClasspathInfo for source: " + FileUtil.getFileDisplayName(roots[i])+"\n");
228
                    LOGGER.fine("GoToTypeAction.getTypeNames created ClasspathInfo for source: " + FileUtil.getFileDisplayName(roots[i])+"\n");
228
//                    if ( isCanceled ) {
229
//                    if ( isCanceled ) {
229
                    if ( isCancelled ) {
230
                    if ( isCancelled ) {
230
                        return null;
231
                        return;
231
                    }
232
                    }
232
                    else {
233
                    else {
233
                        sources.add( new CacheItem( roots[i], ci, false ) );
234
                        sources.add( new CacheItem( roots[i], ci, false ) );
Lines 268-274 Link Here
268
                    cache = sources;
269
                    cache = sources;
269
                }
270
                }
270
                else {
271
                else {
271
                    return null;
272
                    return;
272
                }
273
                }
273
                
274
                
274
            }
275
            }
Lines 312-318 Link Here
312
                //Set<ElementHandle<TypeElement>> names = ci.classpathInfo.getClassIndex().getDeclaredTypes(textForQuery, indexNameKind, EnumSet.of( ci.isBinary ? ClassIndex.SearchScope.DEPENDENCIES : ClassIndex.SearchScope.SOURCE ));
313
                //Set<ElementHandle<TypeElement>> names = ci.classpathInfo.getClassIndex().getDeclaredTypes(textForQuery, indexNameKind, EnumSet.of( ci.isBinary ? ClassIndex.SearchScope.DEPENDENCIES : ClassIndex.SearchScope.SOURCE ));
313
//                if ( isCanceled ) {
314
//                if ( isCanceled ) {
314
                if ( isCancelled ) {
315
                if ( isCancelled ) {
315
                    return null;
316
                    return;
316
                }
317
                }
317
                
318
                
318
                gtn += System.currentTimeMillis() - time;            
319
                gtn += System.currentTimeMillis() - time;            
Lines 329-335 Link Here
329
//                    }
330
//                    }
330
//                    if ( isCanceled ) {
331
//                    if ( isCanceled ) {
331
                    if ( isCancelled ) {
332
                    if ( isCancelled ) {
332
                        return null;
333
                        return;
333
                    }
334
                    }
334
                }
335
                }
335
                add += System.currentTimeMillis() - time;
336
                add += System.currentTimeMillis() - time;
Lines 341-350 Link Here
341
                // Collections.sort(types);
342
                // Collections.sort(types);
342
                sort += System.currentTimeMillis() - time;
343
                sort += System.currentTimeMillis() - time;
343
                LOGGER.fine("PERF - " + " GSS:  " + gss + " GSB " + gsb + " CP: " + cp + " SFB: " + sfb + " GTN: " + gtn + "  ADD: " + add + "  SORT: " + sort ); 
344
                LOGGER.fine("PERF - " + " GSS:  " + gss + " GSB " + gsb + " CP: " + cp + " SFB: " + sfb + " GTN: " + gtn + "  ADD: " + add + "  SORT: " + sort ); 
344
                return types;
345
                res.addResult(types);
345
            }
346
            }
346
            else {
347
            else {
347
                return null;
348
                return;
348
            }
349
            }
349
        }
350
        }
350
351
(-)cnd/gotodeclaration/src/org/netbeans/modules/cnd/gotodeclaration/type/CppTypeProvider.java (-7 / +8 lines)
Lines 61-67 Link Here
61
        return NbBundle.getMessage(CppTypeProvider.class, "TYPE_PROVIDER_DISPLAY_NAME"); // NOI18N
61
        return NbBundle.getMessage(CppTypeProvider.class, "TYPE_PROVIDER_DISPLAY_NAME"); // NOI18N
62
    }
62
    }
63
63
64
    public List<? extends TypeDescriptor> getTypeNames(Project project, String text, SearchType type) {
64
//    public List<? extends TypeDescriptor> getTypeNames(Project project, String text, SearchType type) {
65
    public void computeTypeNames(Context context, Result res) {
66
        Project project = context.getProject();
67
        String text = context.getText();
68
        SearchType type = context.getSearchType();
65
	
69
	
66
	if( TRACE ) System.err.printf("CppTypeProvider.getTypeNames(%s, %s, %s)\n", project, text, type);
70
	if( TRACE ) System.err.printf("CppTypeProvider.getTypeNames(%s, %s, %s)\n", project, text, type);
67
	
71
	
Lines 69-75 Link Here
69
	
73
	
70
	NameMatcher comparator = NameMatcherFactory.createNameMatcher(text, type);
74
	NameMatcher comparator = NameMatcherFactory.createNameMatcher(text, type);
71
	if( comparator == null ) {
75
	if( comparator == null ) {
72
	    return Collections.emptyList();
76
	    return;
73
	}
77
	}
74
	
78
	
75
	if( project == null ) {
79
	if( project == null ) {
Lines 88-94 Link Here
88
                        processProjectLibs(csmProject, result, comparator, processedLibs);
92
                        processProjectLibs(csmProject, result, comparator, processedLibs);
89
                    }
93
                    }
90
                }
94
                }
91
                return new ArrayList<TypeDescriptor>(result);
95
                res.addResult(new ArrayList<TypeDescriptor>(result));
92
	    }
96
	    }
93
	}
97
	}
94
	else {
98
	else {
Lines 98-108 Link Here
98
            if( PROCESS_LIBRARIES ) {
102
            if( PROCESS_LIBRARIES ) {
99
                processProjectLibs(csmProject, result, comparator, new HashSet<CsmProject>());
103
                processProjectLibs(csmProject, result, comparator, new HashSet<CsmProject>());
100
            }
104
            }
101
            return new ArrayList<TypeDescriptor>(result);
105
            res.addResult(new ArrayList<TypeDescriptor>(result));
102
	}
106
	}
103
	
104
	
105
	return Collections.emptyList();
106
    }
107
    }
107
108
108
    public void cancel() {
109
    public void cancel() {
(-)java/sourceui/src/org/netbeans/modules/java/source/ui/JavaTypeProvider.java (-20 / +38 lines)
Lines 46-55 Link Here
46
import org.netbeans.api.java.classpath.GlobalPathRegistryEvent;
46
import org.netbeans.api.java.classpath.GlobalPathRegistryEvent;
47
import org.netbeans.api.java.source.ClasspathInfo;
47
import org.netbeans.api.java.source.ClasspathInfo;
48
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
48
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
49
import java.util.ArrayList;
50
import java.util.EnumSet;
49
import java.util.EnumSet;
51
import java.util.HashSet;
50
import java.util.HashSet;
52
import java.util.List;
53
import java.util.Set;
51
import java.util.Set;
54
import java.util.logging.Logger;
52
import java.util.logging.Logger;
55
import javax.lang.model.element.TypeElement;
53
import javax.lang.model.element.TypeElement;
Lines 63-68 Link Here
63
import org.netbeans.api.java.source.CompilationController;
61
import org.netbeans.api.java.source.CompilationController;
64
import org.netbeans.api.java.source.ElementHandle;
62
import org.netbeans.api.java.source.ElementHandle;
65
import org.netbeans.api.java.source.JavaSource;
63
import org.netbeans.api.java.source.JavaSource;
64
import org.netbeans.api.java.source.SourceUtils;
66
import org.netbeans.api.java.source.Task;
65
import org.netbeans.api.java.source.Task;
67
import org.netbeans.api.java.source.ui.TypeElementFinder;
66
import org.netbeans.api.java.source.ui.TypeElementFinder;
68
import org.netbeans.api.project.FileOwnerQuery;
67
import org.netbeans.api.project.FileOwnerQuery;
Lines 73-79 Link Here
73
import org.netbeans.modules.java.source.usages.RepositoryUpdater;
72
import org.netbeans.modules.java.source.usages.RepositoryUpdater;
74
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
73
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
75
import org.netbeans.spi.jumpto.type.SearchType;
74
import org.netbeans.spi.jumpto.type.SearchType;
76
import org.netbeans.spi.jumpto.type.TypeDescriptor;
77
import org.netbeans.spi.jumpto.type.TypeProvider;
75
import org.netbeans.spi.jumpto.type.TypeProvider;
78
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileStateInvalidException;
77
import org.openide.filesystems.FileStateInvalidException;
Lines 91-96 Link Here
91
    private final TypeElementFinder.Customizer customizer;
89
    private final TypeElementFinder.Customizer customizer;
92
    private ClasspathInfo cpInfo;
90
    private ClasspathInfo cpInfo;
93
    private GlobalPathRegistryListener pathListener;
91
    private GlobalPathRegistryListener pathListener;
92
    private boolean cpChanged = false;
94
93
95
    public String name() {
94
    public String name() {
96
        return "java"; // NOI18N
95
        return "java"; // NOI18N
Lines 116-126 Link Here
116
        pathListener = new GlobalPathRegistryListener() {
115
        pathListener = new GlobalPathRegistryListener() {
117
116
118
            public void pathsAdded(GlobalPathRegistryEvent event) {
117
            public void pathsAdded(GlobalPathRegistryEvent event) {
119
                cache = null; cpInfo = null;
118
                if (cache != null) {
119
                    cache = null;
120
                    cpChanged = true;
121
                }
122
                cpInfo = null;
120
            }
123
            }
121
124
122
            public void pathsRemoved(GlobalPathRegistryEvent event) {
125
            public void pathsRemoved(GlobalPathRegistryEvent event) {
123
                cache = null; cpInfo = null;
126
                if (cache != null) {
127
                    cache = null;
128
                    cpChanged = true;
129
                }
130
                cpInfo = null;
124
            }
131
            }
125
        };
132
        };
126
        GlobalPathRegistry.getDefault().addGlobalPathRegistryListener(pathListener);
133
        GlobalPathRegistry.getDefault().addGlobalPathRegistryListener(pathListener);
Lines 148-156 Link Here
148
//        }
155
//        }
149
//    }
156
//    }
150
157
151
   public List<? extends TypeDescriptor> getTypeNames(Project project, String text, SearchType searchType) {
158
    public void computeTypeNames(Context context, Result res) {
159
        String text = context.getText();
160
        SearchType searchType = context.getSearchType();
161
        
152
        boolean hasBinaryOpen = Lookup.getDefault().lookup(BinaryElementOpen.class) != null;
162
        boolean hasBinaryOpen = Lookup.getDefault().lookup(BinaryElementOpen.class) != null;
153
        final ClassIndex.NameKind nameKind;
163
        final ClassIndex.NameKind nameKind;
164
        
154
        switch (searchType) {
165
        switch (searchType) {
155
        case EXACT_NAME: nameKind = ClassIndex.NameKind.SIMPLE_NAME; break;
166
        case EXACT_NAME: nameKind = ClassIndex.NameKind.SIMPLE_NAME; break;
156
        case CASE_INSENSITIVE_EXACT_NAME: nameKind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP; break;        
167
        case CASE_INSENSITIVE_EXACT_NAME: nameKind = ClassIndex.NameKind.CASE_INSENSITIVE_REGEXP; break;        
Lines 167-172 Link Here
167
        long cp, gss, gsb, sfb, gtn, add, sort;
178
        long cp, gss, gsb, sfb, gtn, add, sort;
168
        cp = gss = gsb = sfb = gtn = add = sort = 0;
179
        cp = gss = gsb = sfb = gtn = add = sort = 0;
169
180
181
        // if scan is running set the message
182
        if (cpChanged || SourceUtils.isScanInProgress()) {
183
            res.setMessage("Result could be incomplete!");
184
        } else {
185
            res.setMessage(null);
186
        }
187
        cpChanged = false;
188
        
170
        if (cache == null) {
189
        if (cache == null) {
171
            Set<CacheItem> sources = null;
190
            Set<CacheItem> sources = null;
172
191
Lines 183-189 Link Here
183
                    time = System.currentTimeMillis();                
202
                    time = System.currentTimeMillis();                
184
                    ClasspathInfo ci = ClasspathInfo.create( EMPTY_CLASSPATH, EMPTY_CLASSPATH, ClassPathSupport.createClassPath(root));               //create(roots[i]);
203
                    ClasspathInfo ci = ClasspathInfo.create( EMPTY_CLASSPATH, EMPTY_CLASSPATH, ClassPathSupport.createClassPath(root));               //create(roots[i]);
185
                    if ( isCanceled ) {
204
                    if ( isCanceled ) {
186
                        return null;
205
                        return;
187
                    }
206
                    }
188
                    else {
207
                    else {
189
                        sources.add( new CacheItem( roots[i], ci, false ) );
208
                        sources.add( new CacheItem( roots[i], ci, false ) );
Lines 202-208 Link Here
202
                for (int i = 0; i < roots.length; i++ ) {
221
                for (int i = 0; i < roots.length; i++ ) {
203
                    try {
222
                    try {
204
                        if ( isCanceled ) {
223
                        if ( isCanceled ) {
205
                            return null;
224
                            return;
206
                        }
225
                        }
207
                        time = System.currentTimeMillis();
226
                        time = System.currentTimeMillis();
208
                        if (!hasBinaryOpen) {
227
                        if (!hasBinaryOpen) {
Lines 223-229 Link Here
223
                    }                   
242
                    }                   
224
                    finally {
243
                    finally {
225
                        if ( isCanceled ) {
244
                        if ( isCanceled ) {
226
                            return null;
245
                            return;
227
                        }
246
                        }
228
                    }
247
                    }
229
                }
248
                }
Lines 239-245 Link Here
239
                    time = System.currentTimeMillis();                
258
                    time = System.currentTimeMillis();                
240
                    ClasspathInfo ci = ClasspathInfo.create(ClassPathSupport.createClassPath(bootRoots[i]), EMPTY_CLASSPATH, EMPTY_CLASSPATH);
259
                    ClasspathInfo ci = ClasspathInfo.create(ClassPathSupport.createClassPath(bootRoots[i]), EMPTY_CLASSPATH, EMPTY_CLASSPATH);
241
                    if ( isCanceled ) {
260
                    if ( isCanceled ) {
242
                        return null;
261
                        return;
243
                    }
262
                    }
244
                    else {
263
                    else {
245
                        sources.add( new CacheItem( bootRoots[i], ci, true ) );
264
                        sources.add( new CacheItem( bootRoots[i], ci, true ) );
Lines 252-258 Link Here
252
                    time = System.currentTimeMillis();                
271
                    time = System.currentTimeMillis();                
253
                    ClasspathInfo ci = ClasspathInfo.create(EMPTY_CLASSPATH, ClassPathSupport.createClassPath(compileRoots[i]), EMPTY_CLASSPATH);
272
                    ClasspathInfo ci = ClasspathInfo.create(EMPTY_CLASSPATH, ClassPathSupport.createClassPath(compileRoots[i]), EMPTY_CLASSPATH);
254
                    if ( isCanceled ) {
273
                    if ( isCanceled ) {
255
                        return null;
274
                        return;
256
                    }
275
                    }
257
                    else {
276
                    else {
258
                        sources.add( new CacheItem( compileRoots[i], ci, true ) );
277
                        sources.add( new CacheItem( compileRoots[i], ci, true ) );
Lines 265-271 Link Here
265
                    time = System.currentTimeMillis();                
284
                    time = System.currentTimeMillis();                
266
                    ClasspathInfo ci = ClasspathInfo.create(EMPTY_CLASSPATH, EMPTY_CLASSPATH, ClassPathSupport.createClassPath(sourceRoots[i]));
285
                    ClasspathInfo ci = ClasspathInfo.create(EMPTY_CLASSPATH, EMPTY_CLASSPATH, ClassPathSupport.createClassPath(sourceRoots[i]));
267
                    if ( isCanceled ) {
286
                    if ( isCanceled ) {
268
                        return null;
287
                        return;
269
                    }
288
                    }
270
                    else {
289
                    else {
271
                        sources.add( new CacheItem( sourceRoots[i], ci, false ) );
290
                        sources.add( new CacheItem( sourceRoots[i], ci, false ) );
Lines 279-291 Link Here
279
                cache = sources;
298
                cache = sources;
280
            }
299
            }
281
            else {
300
            else {
282
                return null;
301
                return;
283
            }
302
            }
284
303
285
        }
304
        }
286
305
287
        ArrayList<JavaTypeDescription> types = new ArrayList<JavaTypeDescription>(cache.size() * 20);
288
289
        for(final CacheItem ci : cache) {
306
        for(final CacheItem ci : cache) {
290
            time = System.currentTimeMillis();
307
            time = System.currentTimeMillis();
291
308
Lines 306-311 Link Here
306
            if (customizer != null) {
323
            if (customizer != null) {
307
                names = customizer.query(ci.classpathInfo, textForQuery, nameKind, EnumSet.of(ci.isBinary ? ClassIndex.SearchScope.DEPENDENCIES : ClassIndex.SearchScope.SOURCE));
324
                names = customizer.query(ci.classpathInfo, textForQuery, nameKind, EnumSet.of(ci.isBinary ? ClassIndex.SearchScope.DEPENDENCIES : ClassIndex.SearchScope.SOURCE));
308
            } else {
325
            } else {
326
                @SuppressWarnings("unchecked")
309
                final Set<ElementHandle<TypeElement>>[] n = new Set[1];
327
                final Set<ElementHandle<TypeElement>>[] n = new Set[1];
310
                JavaSource source = JavaSource.create(ci.classpathInfo, new FileObject[0]);
328
                JavaSource source = JavaSource.create(ci.classpathInfo, new FileObject[0]);
311
                try {
329
                try {
Lines 322-328 Link Here
322
            }
340
            }
323
341
324
            if ( isCanceled ) {
342
            if ( isCanceled ) {
325
                return null;
343
                return;
326
            }
344
            }
327
345
328
            gtn += System.currentTimeMillis() - time;            
346
            gtn += System.currentTimeMillis() - time;            
Lines 334-343 Link Here
334
//                    Removed because of bad performance To reenable see diff between 1.15 and 1.16
352
//                    Removed because of bad performance To reenable see diff between 1.15 and 1.16
335
//                    if (defEntry.includes(convertToSourceName(name.getBinaryName()))) {
353
//                    if (defEntry.includes(convertToSourceName(name.getBinaryName()))) {
336
                    JavaTypeDescription td = new JavaTypeDescription(ci, name );
354
                    JavaTypeDescription td = new JavaTypeDescription(ci, name );
337
                    types.add(td);
355
                    res.addResult(td);
338
//                    }
356
//                    }
339
                if ( isCanceled ) {
357
                if ( isCanceled ) {
340
                    return null;
358
                    return;
341
                }
359
                }
342
            }
360
            }
343
            add += System.currentTimeMillis() - time;
361
            add += System.currentTimeMillis() - time;
Lines 349-358 Link Here
349
            // Collections.sort(types);
367
            // Collections.sort(types);
350
            sort += System.currentTimeMillis() - time;
368
            sort += System.currentTimeMillis() - time;
351
            LOGGER.fine("PERF - " + " GSS:  " + gss + " GSB " + gsb + " CP: " + cp + " SFB: " + sfb + " GTN: " + gtn + "  ADD: " + add + "  SORT: " + sort );
369
            LOGGER.fine("PERF - " + " GSS:  " + gss + " GSB " + gsb + " CP: " + cp + " SFB: " + sfb + " GTN: " + gtn + "  ADD: " + add + "  SORT: " + sort );
352
            return types;
370
            return;
353
        }
371
        }
354
        else {
372
        else {
355
            return null;
373
            return;
356
        }
374
        }
357
    }
375
    }
358
   
376
   

Return to bug 125378