private static Image getPlainImage(Declaration d) {
   boolean shared = d.isShared();
   if (d instanceof Class) {
     if (shared) {
       return CLASS;
     } else {
       return LOCAL_CLASS;
     }
   } else if (d instanceof Interface) {
     if (shared) {
       return INTERFACE;
     } else {
       return LOCAL_INTERFACE;
     }
   } else if (d instanceof Method) {
     if (shared) {
       return METHOD;
     } else {
       return LOCAL_METHOD;
     }
   } else if (d instanceof Parameter) {
     return PARAMETER;
   } else {
     if (shared) {
       return ATTRIBUTE;
     } else {
       return LOCAL_ATTRIBUTE;
     }
   }
 }
 @Override
 public void visit(Tree.Declaration that) {
   super.visit(that);
   if (result == null || !that.equals(result)) {
     Declaration d = that.getDeclarationModel();
     if (d.isShared()) {
       problem = "a shared declaration";
     } else {
       if (hasOuterRefs(d, scope, statements)) {
         problem = "a declaration used elsewhere";
       }
     }
   }
 }
    @Override
    public void apply(IDocument document) {
      super.apply(document);
      if (withBody && EditorsUI.getPreferenceStore().getBoolean(LINKED_MODE)) {
        final LinkedModeModel linkedModeModel = new LinkedModeModel();
        final Point selection = getSelection(document);
        List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
        for (final Declaration d : p.getMembers()) {
          if (Util.isResolvable(d) && d.isShared()) {
            proposals.add(
                new ICompletionProposal() {
                  @Override
                  public Point getSelection(IDocument document) {
                    return null;
                  }

                  @Override
                  public Image getImage() {
                    return getImageForDeclaration(d);
                  }

                  @Override
                  public String getDisplayString() {
                    return d.getName();
                  }

                  @Override
                  public IContextInformation getContextInformation() {
                    return null;
                  }

                  @Override
                  public String getAdditionalProposalInfo() {
                    return null;
                  }

                  @Override
                  public void apply(IDocument document) {
                    try {
                      document.replace(selection.x, selection.y, d.getName());
                    } catch (BadLocationException e) {
                      e.printStackTrace();
                    }
                    linkedModeModel.exit(ILinkedModeListener.UPDATE_CARET);
                  }
                });
          }
        }
        ProposalPosition linkedPosition =
            new ProposalPosition(
                document, selection.x, selection.y, 0, proposals.toArray(NO_COMPLETIONS));
        try {
          LinkedMode.addLinkedPosition(linkedModeModel, linkedPosition);
          LinkedMode.installLinkedMode(
              (CeylonEditor) EditorUtil.getCurrentEditor(),
              document,
              linkedModeModel,
              this,
              new LinkedMode.NullExitPolicy(),
              -1,
              0);
        } catch (BadLocationException ble) {
          ble.printStackTrace();
        }
      }
    }