public static Collection<CompletionItem> create(
     ClassDefinition def, int startOffset, int caretOffset, CompletionContext context) {
   if (def.getText() == null) return Collections.emptyList();
   int priorityDecrementor = 0;
   if (def.getFileObject().equals(context.getFile())) priorityDecrementor++;
   switch (context.getType()) {
     case NEW_INSTANCE:
       Collection<CompletionItem> items = new ArrayList<CompletionItem>();
       for (MethodDefinition constructor : def.getConstructors()) {
         if (!constructor.getParams().isEmpty())
           items.add(
               new ClassCompletionItem(
                   def.getText() + constructor.getParamString(),
                   def.getText(),
                   def.getFileObject().getNameExt(),
                   startOffset,
                   caretOffset,
                   priorityDecrementor,
                   constructor.getParams()));
       }
       items.add(
           new ClassCompletionItem(
               def.getText(),
               def.getText(),
               def.getFileObject().getNameExt(),
               startOffset,
               caretOffset,
               priorityDecrementor,
               Collections.<Definition>emptyList()));
       return items;
     case EXTENDS:
     case DEFAULT:
       return Collections.<CompletionItem>singletonList(
           new ClassCompletionItem(
               def.getText(),
               def.getText(),
               def.getFileObject().getNameExt(),
               startOffset,
               caretOffset,
               priorityDecrementor,
               Collections.<Definition>emptyList()));
   }
   return Collections.emptyList();
 }
 public static Collection<CompletionItem> create(
     MethodDefinition def, int startOffset, int caretOffset, CompletionContext context) {
   if (def.isAnonymous()) return Collections.emptyList();
   int priorityDecrementor = 0;
   boolean optionalAt = false;
   StringBuilder visibleText = new StringBuilder();
   if (def.getFileObject().equals(context.getFile())) {
     priorityDecrementor++;
     if (def.isClassMember() && def.visible(caretOffset)) {
       optionalAt = true;
     }
   }
   visibleText.append(def.getText()).append(def.getParamString());
   switch (context.getType()) {
     case DEFAULT:
       if (optionalAt) visibleText.insert(0, thisPrefix);
       return Collections.<CompletionItem>singletonList(
           new MethodCompletionItem(
               visibleText.toString(),
               def.getText(),
               def.getFileObject().getNameExt(),
               startOffset,
               caretOffset,
               priorityDecrementor));
     case CLASS_ONLY_ACCESSOR:
       if (def.isClassMember() && def.getClassName().equals(context.getClassName()))
         return Collections.<CompletionItem>singletonList(
             new MethodCompletionItem(
                 visibleText.toString(),
                 def.getText(),
                 def.getFileObject().getNameExt(),
                 startOffset,
                 caretOffset,
                 priorityDecrementor));
       break;
     case NORMAL_ACCESSOR:
       return Collections.<CompletionItem>singletonList(
           new MethodCompletionItem(
               visibleText.toString(),
               def.getText(),
               def.getFileObject().getNameExt(),
               startOffset,
               caretOffset,
               priorityDecrementor));
   }
   return Collections.emptyList();
 }