Package org.eclipse.jdt.ui.text.java

Examples of org.eclipse.jdt.ui.text.java.CompletionProposalCollector


    this.project = project;
  }
 
  public IContentProposal[] getProposals(String contents, int position) {
    try {
      CompletionProposalCollector collector = new CompletionProposalCollector(project);
      ICompilationUnit unit = FieldAssistUtils.getTemporaryCompilationUnit(project);
      contents = contents.substring(0, position);
      String source = "public class _xxx { public static void hoge(){ " + contents + "}}";
      FieldAssistUtils.setContentsToCU(unit, source);
      unit.codeComplete(source.length() - 2, collector, DefaultWorkingCopyOwner.PRIMARY);
      IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
      List<ContentProposalImpl> result = new ArrayList<ContentProposalImpl>();
     
      for(int j=0;j<proposals.length;j++){
        if(proposals[j].getImage()!=null){
          String replaceString = null;
View Full Code Here


  public IContentProposal[] getProposals(String contents, int position) {
    if(this.project==null){
      return null;
    }
    try {
      CompletionProposalCollector collector = new CompletionProposalCollector(project);
      ICompilationUnit unit = FieldAssistUtils.getTemporaryCompilationUnit(project);
      contents = contents.substring(0, position);
      String source = "package " + contents;
      FieldAssistUtils.setContentsToCU(unit, source);
      unit.codeComplete(source.length(), collector, DefaultWorkingCopyOwner.PRIMARY);
      IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
      List<ContentProposalImpl> result = new ArrayList<ContentProposalImpl>();
     
      for(int j=0;j<proposals.length;j++){
        if(proposals[j].getImage()!=null){
          String replaceString = null;
View Full Code Here

      IJavaProject project = JavaCore.create(file.getProject());
      if(project != null){
        ICompilationUnit unit = HTMLUtil.getTemporaryCompilationUnit(project);
        HTMLUtil.setContentsToCU(unit, result.toString());
       
        CompletionProposalCollector collector = new CompletionProposalCollector(project);
        int headerLength = result.getHeader().length();
        unit.codeComplete(headerLength + offset,
            collector, DefaultWorkingCopyOwner.PRIMARY);
       
        IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
        List<ICompletionProposal> list = new ArrayList<ICompletionProposal>();
        for(int i=0;i<proposals.length;i++){
          if(proposals[i] instanceof AbstractJavaCompletionProposal){
            AbstractJavaCompletionProposal proposal = (AbstractJavaCompletionProposal)proposals[i];
            if(proposal.getDisplayString().endsWith("_xxx")){
View Full Code Here

    if(value.length()==0){
      return new AssistInfo[0];
    }
    try {
      IJavaProject project = JavaCore.create(file.getProject());
      CompletionProposalCollector collector = new CompletionProposalCollector(project);
      ICompilationUnit unit = HTMLUtil.getTemporaryCompilationUnit(project);
      String source = "public class _xxx { public static void hoge(){ " + value + "}}";
      HTMLUtil.setContentsToCU(unit, source);
      unit.codeComplete(source.length() - 2, collector, DefaultWorkingCopyOwner.PRIMARY);
      IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
      List<AssistInfo> result = new ArrayList<AssistInfo>();
     
      for(int j=0;j<proposals.length;j++){
        if(proposals[j].getImage()!=null){
          if(proposals[j] instanceof LazyJavaTypeCompletionProposal){
View Full Code Here

        List result = new ArrayList();
        IJavaProject javaProject = getCurrentJavaProject();
        if ( javaProject == null ) {
            return result;
        }
        CompletionProposalCollector collector = new CompletionProposalCollector( javaProject ) {
            public void accept(CompletionProposal proposal) {
                if ( proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.PACKAGE_REF || proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.TYPE_REF ) {
                    super.accept( proposal );
                }
            }
        };
        collector.acceptContext( new CompletionContext() );
        try {
            IEvaluationContext evalContext = javaProject.newEvaluationContext();
            evalContext.codeComplete( classNameStart,
                                      classNameStart.length(),
                                      collector );
            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
            for ( int i = 0; i < proposals.length; i++ ) {
                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
                    AbstractJavaCompletionProposal javaProposal = (AbstractJavaCompletionProposal) proposals[i];
                    int replacementOffset = documentOffset - (classNameStart.length() - javaProposal.getReplacementOffset());
                    javaProposal.setReplacementOffset( replacementOffset );
View Full Code Here

        IJavaProject javaProject = getCurrentJavaProject();
        if ( javaProject == null ) {
            return;
        }

        CompletionProposalCollector collector = new CompletionProposalCollector( javaProject );
        collector.acceptContext( new CompletionContext() );

        try {
            IEvaluationContext evalContext = javaProject.newEvaluationContext();
            List imports = getImports();
            if ( imports != null && imports.size() > 0 ) {
                evalContext.setImports( (String[]) imports.toArray( new String[imports.size()] ) );
            }
            StringBuffer javaTextWithParams = new StringBuffer();
            Iterator iterator = params.entrySet().iterator();
            while ( iterator.hasNext() ) {
                Map.Entry entry = (Map.Entry) iterator.next();
                // this does not seem to work, so adding variables manually
                // evalContext.newVariable((String) entry.getValue(), (String) entry.getKey(), null);
                javaTextWithParams.append( entry.getValue() + " " + entry.getKey() + ";\n" );
            }
            if (useDrools) {
                javaTextWithParams.append( "org.kie.api.runtime.rule.RuleContext kcontext;" );
            }
            if (useContext) {
                javaTextWithParams.append( "org.kie.api.runtime.process.ProcessContext kcontext;" );
            }
            javaTextWithParams.append( javaText );
            String jtext = javaTextWithParams.toString();
            String fixedText = new KnowledgeHelperFixer().fix( jtext );

            evalContext.codeComplete( fixedText,
                                      fixedText.length(),
                                      collector );
            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
            for ( int i = 0; i < proposals.length; i++ ) {
                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
                    AbstractJavaCompletionProposal javaProposal = (AbstractJavaCompletionProposal) proposals[i];
                    int replacementOffset = documentOffset - (fixedText.length() - javaProposal.getReplacementOffset());
                    javaProposal.setReplacementOffset( replacementOffset );
View Full Code Here

            final List<Tuple<IJavaElement, CompletionProposal>> ret) throws JavaModelException {
        ICompilationUnit unit = type.getCompilationUnit();
        if (unit == null) {
            return;
        }
        CompletionProposalCollector collector = createCollector(filterCompletionName, ret, unit);
        type.codeComplete(com.aptana.shared_core.string.StringUtils.format(contents, name).toCharArray(), -1, 0, new char[0][0], new char[0][0],
                new int[0], false, collector);
    }
View Full Code Here

     * @return the collector that will gather the completions (note that it'll keep the 'ret' placeholder alive unti it's
     * garbage-collected.
     */
    protected CompletionProposalCollector createCollector(final String filterCompletionName,
            final List<Tuple<IJavaElement, CompletionProposal>> ret, ICompilationUnit unit) {
        CompletionProposalCollector collector = new CompletionProposalCollector(unit) {

            /**
             * Override the java proposal creation to always return null, as we'll keep just what we actually need.
             */
            @SuppressWarnings("restriction")
View Full Code Here

        IClasspathEntry entries[] = getClasspathEntries();
        //Using old version for compatibility with eclipse 3.2
        ICompilationUnit unit = new WorkingCopyOwner() {
        }.newWorkingCopy(name, entries, null, new NullProgressMonitor());
        unit.getBuffer().setContents(contents);
        CompletionProposalCollector collector = createCollector(filterCompletionName, ret, unit);

        unit.codeComplete(completionOffset, collector); //fill the completions while searching it
        return ret;
    }
View Full Code Here

 
  public IContentProposal[] getProposals(String contents, int position) {
    try {
      String rawContents = contents;
     
      CompletionProposalCollector collector = new CompletionProposalCollector(project);
      ICompilationUnit unit = FieldAssistUtils.getTemporaryCompilationUnit(project);
     
      contents = contents.substring(0, position);
      if(ClickUtils.isNotEmpty(packageName)){
        contents = packageName + "." + contents;
      }
     
      String source = "public class _xxx { public static void hoge(){ " + contents + "}}";
     
      FieldAssistUtils.setContentsToCU(unit, source);
      unit.codeComplete(source.length() - 2, collector, DefaultWorkingCopyOwner.PRIMARY);
      IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
      List<IContentProposal> result = new ArrayList<IContentProposal>();
     
      for(int j = 0; j < proposals.length; j++){
        if(proposals[j].getImage()!=null){
          String replaceString = null;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.ui.text.java.CompletionProposalCollector

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.