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

Examples of org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal


    private static void processJavaMethodCompletionProposal(List list,
                                                            boolean settersOnly,
                                                            final Collection set,
                                                            Object o) {
        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
        Object field = ReflectionUtils.getField( o,
                                                 "fProposal" );
        if ( field != null && field instanceof CompletionProposal ) {
            CompletionProposal proposal = (CompletionProposal) field;

            String completion = new String( proposal.getCompletion() );

            String propertyOrMethodName = null;

            boolean isSetter = false;
            boolean isAccessor = false;
            if ( settersOnly ) {
                // get the eventual writable property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
                                                                               proposal.getSignature() );
                //                      if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isSetter = !completion.equals( propertyOrMethodName );

            } else {
                // get the eventual property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
                                                                       proposal.getSignature() );
                //if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isAccessor = !completion.equals( propertyOrMethodName );
            }

            // is the completion for a bean accessor? and do we have already some relevant completion?
            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
                                                                                                              list );
            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {

                //TODO: craft a better JDTish display name than just the property name
                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
                                                                          javaProposal.getReplacementLength(),
                                                                          propertyOrMethodName );
                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
                //set high priority such that the completion for accessors shows up first
                prop.setPriority( 1000 );
                set.add( prop );
View Full Code Here


    private static void processJavaMethodCompletionProposal(List<ICompletionProposal> list,
                                                            boolean settersOnly,
                                                            final Collection<ICompletionProposal> set,
                                                            ICompletionProposal o) {
        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
        Object field = ReflectionUtils.getField(o, "fProposal");
        if ( field != null && field instanceof CompletionProposal ) {
            CompletionProposal proposal = (CompletionProposal) field;

            String completion = new String( proposal.getCompletion() );

            String propertyOrMethodName = null;

            boolean isSetter = false;
            boolean isAccessor = false;
            if ( settersOnly ) {
                // get the eventual writable property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
                                                                               proposal.getSignature() );
                //                      if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isSetter = !completion.equals( propertyOrMethodName );

            } else {
                // get the eventual property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
                                                                       proposal.getSignature() );
                //if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isAccessor = !completion.equals( propertyOrMethodName );
            }

            // is the completion for a bean accessor? and do we have already some relevant completion?
            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
                                                                                                              list );
            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {

                //TODO: craft a better JDTish display name than just the property name
                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
                                                                          javaProposal.getReplacementLength(),
                                                                          propertyOrMethodName );
                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
                //set high priority such that the completion for accessors shows up first
                prop.setPriority( 1000 );
                set.add( prop );
View Full Code Here

    private static void processJavaMethodCompletionProposal(List list,
                                                            boolean settersOnly,
                                                            final Collection set,
                                                            Object o) {
        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
        Object field = ReflectionUtils.getField( o,
                                                 "fProposal" );
        if ( field != null && field instanceof CompletionProposal ) {
            CompletionProposal proposal = (CompletionProposal) field;

            String completion = new String( proposal.getCompletion() );

            String propertyOrMethodName = null;

            boolean isSetter = false;
            boolean isAccessor = false;
            if ( settersOnly ) {
                // get the eventual writable property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
                                                                               proposal.getSignature() );
                //                      if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isSetter = !completion.equals( propertyOrMethodName );

            } else {
                // get the eventual property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
                                                                       proposal.getSignature() );
                //if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isAccessor = !completion.equals( propertyOrMethodName );
            }

            // is the completion for a bean accessor? and do we have already some relevant completion?
            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
                                                                                                              list );
            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {

                //TODO: craft a better JDTish display name than just the property name
                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
                                                                          javaProposal.getReplacementLength(),
                                                                          propertyOrMethodName );
                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
                //set high priority such that the completion for accessors shows up first
                prop.setPriority( 1000 );
                set.add( prop );
View Full Code Here

    private static void processJavaMethodCompletionProposal(List list,
                                                            boolean settersOnly,
                                                            final Collection set,
                                                            Object o) {
        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
        Object field = ReflectionUtils.getField( o,
                                                 "fProposal" );
        if ( field != null && field instanceof CompletionProposal ) {
            CompletionProposal proposal = (CompletionProposal) field;

            String completion = new String( proposal.getCompletion() );

            String propertyOrMethodName = null;

            boolean isSetter = false;
            boolean isAccessor = false;
            if ( settersOnly ) {
                // get the eventual writable property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
                                                                               proposal.getSignature() );
                //                      if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isSetter = !completion.equals( propertyOrMethodName );

            } else {
                // get the eventual property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
                                                                       proposal.getSignature() );
                //if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isAccessor = !completion.equals( propertyOrMethodName );
            }

            // is the completion for a bean accessor? and do we have already some relevant completion?
            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
                                                                                                              list );
            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {

                //TODO: craft a better JDTish display name than just the property name
                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
                                                                          javaProposal.getReplacementLength(),
                                                                          propertyOrMethodName );
                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
                //set high priority such that the completion for accessors shows up first
                prop.setPriority( 1000 );
                set.add( prop );
View Full Code Here

        // parameters
        if ((completion.length() == 0) || ((completion.length() == 1) && completion.charAt(0) == ')') || Signature.getParameterCount(methodProposal.getSignature()) == 0)
            return super.createJavaCompletionProposal(methodProposal);

        IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
        LazyJavaCompletionProposal proposal;
        if (preferenceStore.getBoolean(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS))
            proposal= new ParameterGuessingProposal(methodProposal, getCompilationUnit());
        else
            proposal= new ExperimentalProposal(methodProposal, getCompilationUnit());
View Full Code Here

        char[] completion= typeProposal.getCompletion();
        // don't add parameters for import-completions nor for proposals with an empty completion (e.g. inside the type argument list)
        if (completion.length == 0 || completion[completion.length - 1] == ';')
            return super.createJavaCompletionProposal(typeProposal);

        LazyJavaCompletionProposal newProposal= new GenericJavaTypeProposal(typeProposal, getContext(), cu);
        return newProposal;
    }
View Full Code Here

    private static void processJavaMethodCompletionProposal(List list,
                                                            boolean settersOnly,
                                                            final Collection set,
                                                            Object o) {
        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
        Object field = ReflectionUtils.getField( o,
                                                 "fProposal" );
        if ( field != null && field instanceof CompletionProposal ) {
            CompletionProposal proposal = (CompletionProposal) field;

            String completion = new String( proposal.getCompletion() );

            String propertyOrMethodName = null;

            boolean isSetter = false;
            boolean isAccessor = false;
            if ( settersOnly ) {
                // get the eventual writable property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
                                                                               proposal.getSignature() );
                //                      if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isSetter = !completion.equals( propertyOrMethodName );

            } else {
                // get the eventual property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
                                                                       proposal.getSignature() );
                //if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isAccessor = !completion.equals( propertyOrMethodName );
            }

            // is the completion for a bean accessor? and do we have already some relevant completion?
            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
                                                                                                              list );
            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {

                //TODO: craft a better JDTish display name than just the property name
                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
                                                                          javaProposal.getReplacementLength(),
                                                                          propertyOrMethodName );
                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
                //set high priority such that the completion for accessors shows up first
                prop.setPriority( 1000 );
                set.add( prop );
View Full Code Here

    int kind = -1;
    if(proposal instanceof JavaCompletionProposal){
      JavaCompletionProposal lazy = (JavaCompletionProposal)proposal;
      completion = lazy.getReplacementString();
    }else if(proposal instanceof LazyJavaCompletionProposal){
      LazyJavaCompletionProposal lazy = (LazyJavaCompletionProposal)proposal;
      completion = lazy.getReplacementString();
      Method getProposal = LazyJavaCompletionProposal.class
        .getDeclaredMethod("getProposal");
      getProposal.setAccessible(true);
      CompletionProposal cproposal = (CompletionProposal)getProposal.invoke(lazy);
      if (cproposal != null){
View Full Code Here

    private static void processJavaMethodCompletionProposal(List<ICompletionProposal> list,
                                                            boolean settersOnly,
                                                            final Collection<ICompletionProposal> set,
                                                            ICompletionProposal o) {
        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
        Object field = ReflectionUtils.getField(o, "fProposal");
        if ( field != null && field instanceof CompletionProposal ) {
            CompletionProposal proposal = (CompletionProposal) field;

            String completion = new String( proposal.getCompletion() );

            String propertyOrMethodName = null;

            boolean isSetter = false;
            boolean isAccessor = false;
            if ( settersOnly ) {
                // get the eventual writable property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
                                                                               proposal.getSignature() );
                //                      if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isSetter = !completion.equals( propertyOrMethodName );

            } else {
                // get the eventual property name for that method name and signature
                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
                                                                       proposal.getSignature() );
                //if we got a property name that differs from the orginal method name
                //then this is a bean accessor
                isAccessor = !completion.equals( propertyOrMethodName );
            }

            // is the completion for a bean accessor? and do we have already some relevant completion?
            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
                                                                                                              list );
            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {

                //TODO: craft a better JDTish display name than just the property name
                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
                                                                          javaProposal.getReplacementLength(),
                                                                          propertyOrMethodName );
                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
                //set high priority such that the completion for accessors shows up first
                prop.setPriority( 1000 );
                set.add( prop );
View Full Code Here

        recorder.recordProposal(prop.getImage(), prop.getRelevance(), prop.getDisplayString(),
            replacementString, prop.getJavaElement());
      }
    }
    else if (comProposal instanceof LazyJavaCompletionProposal) {
      LazyJavaCompletionProposal prop = (LazyJavaCompletionProposal) comProposal;
      recorder.recordProposal(prop.getImage(), prop.getRelevance(), prop.getDisplayString(), prop
          .getReplacementString(), prop.getJavaElement());
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal

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.