Package at.ssw.coco.lib.model.positions

Examples of at.ssw.coco.lib.model.positions.ICocoRegion


   
   
    ITextSelection selection = (ITextSelection)viewer.getSelectionProvider().getSelection();
    WordFinderAdaptor wordFinder = new WordFinderAdaptor(viewer.getDocument(), fIdentDetector);
    String prefix = wordFinder.getPrefix(offset);
    ICocoRegion region = new CocoRegion(offset - prefix.length(), prefix.length() + selection.getLength());

    String prefixLow = prefix.toLowerCase();
   
    LinkedList<ICompletionProposal> completionProposals = new LinkedList<ICompletionProposal>();
    Set<ICompletionProposal> fieldProposals = new TreeSet<ICompletionProposal>(new PorposalComparator());
    Set<ICompletionProposal> methodProposals = new TreeSet<ICompletionProposal>(new PorposalComparator());
    Set<ICompletionProposal> constructorProposals = new TreeSet<ICompletionProposal>(new PorposalComparator());
    Set<ICompletionProposal> localProposals = new TreeSet<ICompletionProposal>(new PorposalComparator());
   
    ATGLabelProvider labelProvider = new ATGLabelProvider();
   
    if(fields!=null){
      for(VarProposal entry : fields){
        String text = entry.toString();
        if (text.toLowerCase().startsWith(prefixLow)) {
          fieldProposals.add(new StyledCompletionProposal(entry,
              region.getOffset(), region.getLength(), labelProvider));       
        }
      }
    }   
    if(methods!=null){
      for(MethProposal entry : methods){
        String text = entry.toString();
        if (text.toLowerCase().startsWith(prefixLow)) {
          if(entry.getBinding().isConstructor()){
            constructorProposals.add(new StyledCompletionProposal(entry,
                region.getOffset(), region.getLength(), labelProvider));
          }
          else{
            methodProposals.add(new StyledCompletionProposal(entry,
                region.getOffset(), region.getLength(), labelProvider));
          }
        }
      }
    }
    if(locals!=null){
      for(VarProposal entry : locals){
        String text = entry.toString();
        if (text.toLowerCase().startsWith(prefixLow)) {
          fieldProposals.add(new StyledCompletionProposal(entry,
              region.getOffset(), region.getLength(), labelProvider));       
        }
      }
    }   
   
    completionProposals.addAll(constructorProposals);
    completionProposals.addAll(localProposals);
    completionProposals.addAll(fieldProposals);
    completionProposals.addAll(methodProposals);
   
    if(completionProposals.isEmpty()){
      String entry = prefix+"no Default Proposals";
      completionProposals.add(new StyledCompletionProposal (entry,
          region.getOffset(), region.getLength(), labelProvider));
    }
   
    return completionProposals.toArray(new ICompletionProposal[completionProposals.size()]);     
  }
View Full Code Here


          invalidPos = true;
        }
        else{
          //the end of a variable/method name has been found
          //extract the word and set the offset to the correct position for further calculations
          ICocoRegion word = wordFinder.findWord(offset);
          String name = wordFinder.extractWord(word)
          //add the word at the beginning
          SemanticAction sa = new SemanticAction(name, arrayLevel, isMethod);
          wordList.add(0, sa);
          //set the offset to the correct position for the next cycle
          offset = word.getOffset()-1;
        }
      }
      else{
        //invalid start of operation, no proposals should be shown
        return null;
View Full Code Here

    } catch (BadLocationException e) {
      // should not happen
    }

    WordFinderAdaptor wordFinder = new WordFinderAdaptor(textViewer.getDocument(), fIdentDetector);
    ICocoRegion cocoWordRegion = wordFinder.findWord(offset);
    String word = wordFinder.extractWord(cocoWordRegion);
    if (word == null) {
      return null;
    }

    ATGSegment segment = fATGModel.find(word);
    Region wordRegion = new Region(cocoWordRegion.getOffset(), cocoWordRegion.getLength());
    if (segment != null) {
      return new IHyperlink[] { new ATGHyperlink(wordRegion, new Region(segment.getRegion().getOffset(), segment.getRegion().getLength()))};
    }

    return null;
View Full Code Here

  /* (non-Javadoc)
   * @see at.ssw.coco.lib.editor.detectors.WordFinder#getPrefix(int)
   */
  public String getPrefix(int offset) {
    ICocoRegion prefix = locatePrefix(offset);
    String result = "";
    try  {
      result = content.substring(prefix.getOffset(), prefix.getOffset()+prefix.getLength());
    } catch (StringIndexOutOfBoundsException e) {
      //do nothing, because no prefix found
    }
    return result;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see at.ssw.coco.lib.editor.detectors.WordFinder#getSuffix(int)
   */
  public String getSuffix(int offset) {
    ICocoRegion suffix = locateSuffix(offset);
    String result = content.substring(suffix.getOffset(), suffix.getOffset() + suffix.getLength());   
    return result;
  }
View Full Code Here

TOP

Related Classes of at.ssw.coco.lib.model.positions.ICocoRegion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.