Lines 48-61
Link Here
|
48 |
import java.beans.PropertyChangeListener; |
48 |
import java.beans.PropertyChangeListener; |
49 |
import java.io.IOException; |
49 |
import java.io.IOException; |
50 |
import java.net.URL; |
50 |
import java.net.URL; |
|
|
51 |
import java.util.ArrayList; |
51 |
import java.util.Arrays; |
52 |
import java.util.Arrays; |
52 |
import java.util.Collection; |
53 |
import java.util.Collection; |
53 |
import java.util.Collections; |
54 |
import java.util.Collections; |
54 |
import java.util.EnumSet; |
55 |
import java.util.EnumSet; |
|
|
56 |
import java.util.HashMap; |
55 |
import java.util.HashSet; |
57 |
import java.util.HashSet; |
56 |
import java.util.Iterator; |
58 |
import java.util.Iterator; |
57 |
import java.util.LinkedList; |
59 |
import java.util.LinkedList; |
58 |
import java.util.List; |
60 |
import java.util.List; |
|
|
61 |
import java.util.Map; |
62 |
import java.util.Map.Entry; |
59 |
import java.util.Set; |
63 |
import java.util.Set; |
60 |
import java.util.concurrent.ConcurrentLinkedQueue; |
64 |
import java.util.concurrent.ConcurrentLinkedQueue; |
61 |
import java.util.concurrent.atomic.AtomicBoolean; |
65 |
import java.util.concurrent.atomic.AtomicBoolean; |
Lines 510-515
Link Here
|
510 |
} |
514 |
} |
511 |
|
515 |
|
512 |
/** |
516 |
/** |
|
|
517 |
* Returns descriptions of symbols found on the given classpath and matching the additional criteria. |
518 |
* @param name case sensitive prefix, case insensitive prefix, exact simple name, |
519 |
* camel case or regular expression depending on the kind parameter. |
520 |
* @param kind of the name {@see NameKind} |
521 |
* @param scope to search in {@see SearchScope} |
522 |
* @return iterable of {@link Symbols} describing found symbols matching the specified criteria. |
523 |
* It may return null when the caller is a CancellableTask<CompilationInfo> and is cancelled |
524 |
* inside call of this method. |
525 |
* @since 0.114 |
526 |
*/ |
527 |
public @NullUnknown Iterable<Symbols> getDeclaredSymbols( |
528 |
final @NonNull String name, |
529 |
final @NonNull NameKind kind, |
530 |
final @NonNull Set<? extends SearchScopeType> scope) { |
531 |
Parameters.notNull("name", name); |
532 |
Parameters.notNull("kind", kind); |
533 |
final Map<ElementHandle<TypeElement>,Set<String>> result = new HashMap<ElementHandle<TypeElement>,Set<String>>(); |
534 |
final Iterable<? extends ClassIndexImpl> queries = this.getQueries (scope); |
535 |
final Convertor<Document, ElementHandle<TypeElement>> thConvertor = DocumentUtil.elementHandleConvertor(); |
536 |
try { |
537 |
for (ClassIndexImpl query : queries) { |
538 |
try { |
539 |
query.getDeclaredElements( |
540 |
name, |
541 |
kind, |
542 |
thConvertor, |
543 |
result); |
544 |
} catch (Index.IndexClosedException e) { |
545 |
logClosedIndex (query); |
546 |
} catch (IOException e) { |
547 |
Exceptions.printStackTrace(e); |
548 |
} |
549 |
} |
550 |
if (LOGGER.isLoggable(Level.FINE)) { |
551 |
LOGGER.log( |
552 |
Level.FINE, |
553 |
"ClassIndex.getDeclaredTypes returned {0} elements\n", //NOI18N |
554 |
result.size()); |
555 |
} |
556 |
List<Symbols> finalResult = new ArrayList<Symbols>(); |
557 |
for (Entry<ElementHandle<TypeElement>, Set<String>> e : result.entrySet()) { |
558 |
finalResult.add(new Symbols(e.getKey(), e.getValue())); |
559 |
} |
560 |
return Collections.unmodifiableList(finalResult); |
561 |
} catch (InterruptedException e) { |
562 |
return null; |
563 |
} |
564 |
} |
565 |
|
566 |
/**Description of found symbols (methods, constructors, fields) for one enclosing type. |
567 |
* Returned from {@link #getDeclaredSymbols(java.lang.String, org.netbeans.api.java.source.ClassIndex.NameKind, java.util.Set) }. |
568 |
* |
569 |
* @since 0.114 |
570 |
*/ |
571 |
public static final class Symbols { |
572 |
private final ElementHandle<TypeElement> enclosingType; |
573 |
private final Set<String> symbols; |
574 |
|
575 |
Symbols(ElementHandle<TypeElement> enclosingType, Set<String> symbols) { |
576 |
this.enclosingType = enclosingType; |
577 |
this.symbols = symbols; |
578 |
} |
579 |
|
580 |
/**The type that contains some symbols matching the required criterie. |
581 |
* |
582 |
* @return enclosing type |
583 |
*/ |
584 |
public ElementHandle<TypeElement> getEnclosingType() { |
585 |
return enclosingType; |
586 |
} |
587 |
|
588 |
/**The simple names of all symbols matching the criteria inside the given enclosing type. |
589 |
* |
590 |
* @return simple names of matching symbols |
591 |
*/ |
592 |
public Set<String> getSymbols() { |
593 |
return symbols; |
594 |
} |
595 |
|
596 |
} |
597 |
|
598 |
/** |
513 |
* Returns names af all packages in given classpath starting with prefix. |
599 |
* Returns names af all packages in given classpath starting with prefix. |
514 |
* @param prefix of the package name |
600 |
* @param prefix of the package name |
515 |
* @param directOnly if true treats the packages as folders and returns only |
601 |
* @param directOnly if true treats the packages as folders and returns only |