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

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


   
   
    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


  }

 
  @Override
  public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    return detectHyperlinks(textViewer, new CocoRegion(region.getOffset(), region.getLength()), canShowMultipleHyperlinks);
  }
View Full Code Here

      pos++;
    }
    if (pos < offset) {
      start = pos;
    }
    return new CocoRegion(start, offset - start);
  }
View Full Code Here

   * @param endPos the end position.
   */
  public ATGSegment(Type type, String name, int startPos, int endPos) {
    fType = type;
    fName = name;
    fRegion = new CocoRegion(startPos, endPos - startPos);
    fLevel = 0;
    fParent = null;
    fChildren = new ArrayList<ATGSegment>();
  }
View Full Code Here

   * @param end The end point.
   */
  public void setEndPoint(int end) {
      fixupRegion();
    if (0 < fRegion.getOffset()) {
      fRegion = new CocoRegion(fRegion.getOffset(), end - fRegion.getOffset());
    } // else: if we don't know the start, it's useless to know the end.
  }
View Full Code Here

        break;
      }
      ++pos;
    }
    end = pos;
    return new CocoRegion(offset, end - offset);
  }
View Full Code Here

        // just in case our end point won't get set, try to make a good estimate
        int length = 0;
        if (0 < last.fRegion.getOffset()) {
          length = (last.fRegion.getOffset() - offset) + last.fRegion.getLength();
        }
        fRegion = new CocoRegion(offset, length);
      } else System.out.println("fix-up failed: " + fRegion);
    }
  }
View Full Code Here

    end = pos;


    if (start >= -1 && end > -1) {
      if (start == offset && end == offset) {
        return new CocoRegion(offset, 0);
      } else if (start == offset) {
        return new CocoRegion(start, end - start);
      } else {
        return new CocoRegion(start + 1, end - start - 1);
      }
    }
    return null;
  }
View Full Code Here

TOP

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

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.