Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012 Red Hat, Inc. and/or its affiliates.
  *
  * Licensed under the Eclipse Public License version 1.0, available at
  * http://www.eclipse.org/legal/epl-v10.html
  */
 
 package org.jboss.forge.git.gitignore;
 
import  org.jboss.forge.parser.java.util.Strings;
   @Inject
   private Project project;
   
   @Inject
   private Shell shell;
   @Override
   public void complete(CommandCompleterState state)
   {
      Queue<Stringtokens = state.getTokens();
      String peek = tokens.peek();
      List<Stringcandidates = candidates(peek);
      if (!candidates.isEmpty())
      {
         if (!Strings.isNullOrEmpty(peek))
         {
            state.setIndex(state.getBuffer().lastIndexOf(peek));
         }
         state.getCandidates().addAll(candidates);
      }
   }
   
   private List<Stringcandidates(String start)
   {
      List<Stringresult = new LinkedList<String>();
      for (GitIgnoreTemplateGroup group : .getFacet(GitIgnoreFacet.class).list())
      {
         for (String template : group.getTemplates())
         {
            if (Strings.isNullOrEmpty(start) || template.startsWith(start))
            {
               result.add(template);
            }
         }
      }
      return result;
   }
New to GrepCode? Check out our FAQ X