Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.CompletionRequestor


  }

  public static CompletionProposal[] getProposals(ISourceModule sourceModule,
      int offset) throws ModelException {
    final List<CompletionProposal> proposals = new LinkedList<CompletionProposal>();
    sourceModule.codeComplete(offset, new CompletionRequestor() {
      public void accept(CompletionProposal proposal) {
        proposals.add(proposal);
      }
    });
    return (CompletionProposal[]) proposals
View Full Code Here


  }

  public static CompletionProposal[] getProposals(ISourceModule sourceModule,
      int offset) throws ModelException {
    final List<CompletionProposal> proposals = new LinkedList<CompletionProposal>();
    sourceModule.codeComplete(offset, new CompletionRequestor() {
      public void accept(CompletionProposal proposal) {
        proposals.add(proposal);
      }
    });
    return (CompletionProposal[]) proposals
View Full Code Here

    if (!(context instanceof ClassMemberContext)) {
      return;
    }

    ClassMemberContext concreteContext = (ClassMemberContext) context;
    CompletionRequestor requestor = concreteContext
        .getCompletionRequestor();

    String prefix = concreteContext.getPrefix();
    SourceRange replaceRange = getReplacementRange(concreteContext);

    List<IField> result = new LinkedList<IField>();

    for (IType type : concreteContext.getLhsTypes()) {
      try {
        ITypeHierarchy hierarchy = getCompanion()
            .getSuperTypeHierarchy(type, null);
        IField[] fields = null;

        if (concreteContext instanceof ClassStaticMemberContext
            && concreteContext.getTriggerType() == Trigger.CLASS
            && ((ClassStaticMemberContext) concreteContext)
                .isParent()) {
          List<IField> superTypes = new ArrayList<IField>();
          for (IType currType : hierarchy.getAllSupertypes(type)) {
            superTypes.addAll(Arrays.asList(PHPModelUtils
                .getTypeField(currType, prefix,
                    requestor.isContextInformationMode())));
          }

          fields = superTypes.toArray(new IField[superTypes.size()]);
        } else {
          fields = PHPModelUtils.getTypeHierarchyField(type,
              hierarchy, prefix,
              requestor.isContextInformationMode(), null);
        }

        for (IField field : removeOverriddenElements(Arrays
            .asList(fields))) {
          if (concreteContext.isInUseTraitStatement()) {
View Full Code Here

    if (!(context instanceof PHPDocTagContext)) {
      return;
    }
    PHPDocTagContext tagContext = (PHPDocTagContext) context;
    String tagName = tagContext.getTagName();
    CompletionRequestor requestor = tagContext.getCompletionRequestor();

    SourceRange replaceRange = getReplacementRange(tagContext);
    String suffix = ""; //$NON-NLS-1$

    for (String nextTag : PHPDOC_TAGS) {
      if (CodeAssistUtils.startsWithIgnoreCase(nextTag, tagName)) {
        if (!requestor.isContextInformationMode()
            || nextTag.length() == tagName.length()) {

          // Tags are reported like keywords:
          reporter.reportKeyword(nextTag, suffix, replaceRange);
        }
View Full Code Here

    if (arrayContext.hasQuotes() && !(endsWithQuota)) {
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=401766
      replaceRange = new SourceRange(replaceRange.getOffset(),
          replaceRange.getLength() + 1);
    }
    CompletionRequestor requestor = arrayContext.getCompletionRequestor();

    String prefix = arrayContext.getPrefix();
    ModuleDeclaration moduleDeclaration = SourceParserUtil
        .getModuleDeclaration(arrayContext.getSourceModule());
    try {
      ArrayKeyFinder finder = new ArrayKeyFinder(prefix,
          arrayContext.getOffset());
      moduleDeclaration.traverse(finder);
      Set<String> names = finder.getNames();
      int extraObject = ProposalExtraInfo.DEFAULT;
      if (!arrayContext.hasQuotes()) {
        extraObject |= ProposalExtraInfo.ADD_QUOTES;
      }
      for (String name : names) {

        if (!requestor.isContextInformationMode()) {
          reporter.reportField(new FakeField(
              (ModelElement) arrayContext.getSourceModule(),
              name, 0, 0), "", replaceRange, false, 0, //$NON-NLS-1$
              extraObject); // NON-NLS-1
        }
View Full Code Here

  }

  protected void reportVariables(ICompletionReporter reporter,
      ArrayKeyContext context, String[] variables, String prefix,
      boolean removeDollar) throws BadLocationException {
    CompletionRequestor requestor = context.getCompletionRequestor();
    SourceRange replaceRange = getReplacementRange(context);
    for (String variable : variables) {
      if (removeDollar) {
        variable = variable.substring(1);
      }
      if (variable.startsWith(prefix)) {
        if (!requestor.isContextInformationMode()
            || variable.length() == prefix.length()) {
          reporter.reportField(
              new FakeField((ModelElement) context
                  .getSourceModule(), variable, 0, 0), "", //$NON-NLS-1$
              replaceRange, false); // NON-NLS-1
View Full Code Here

  @SuppressWarnings("unchecked")
  public void apply(ICompletionReporter reporter) throws BadLocationException {

    AbstractCompletionContext abstractContext = (AbstractCompletionContext) getContext();
    CompletionRequestor requestor = abstractContext.getCompletionRequestor();

    int offset = abstractContext.getOffset();

    // find function arguments
    ISourceModule sourceModule = abstractContext.getSourceModule();
    ModuleDeclaration moduleDeclaration = SourceParserUtil.getModuleDeclaration(sourceModule, null);

    Declaration declaration = ASTUtils.findDeclarationAfterPHPdoc(moduleDeclaration, offset);
    if (declaration instanceof MethodDeclaration) {

      String prefix = abstractContext.getPrefix();
      SourceRange replaceRange = getReplacementRange(abstractContext);
      String suffix = ""; //$NON-NLS-1$

      List<Argument> arguments = ((MethodDeclaration) declaration).getArguments();
      for (Argument arg : arguments) {
        String argumentVar = arg.getName();
        if (argumentVar.startsWith(prefix)) {
          if (!requestor.isContextInformationMode() || argumentVar.length() == prefix.length()) {
            reporter.reportField(new FakeField((ModelElement) sourceModule, argumentVar, 0, 0), suffix, replaceRange, false);
          }
        }
      }
    }
View Full Code Here

    if (!(context instanceof MethodNameContext)) {
      return;
    }

    MethodNameContext concreteContext = (MethodNameContext) context;
    CompletionRequestor requestor = concreteContext
        .getCompletionRequestor();

    String prefix = concreteContext.getPrefix();
    boolean exactName = requestor.isContextInformationMode();
    IType declaringClass = concreteContext.getDeclaringClass();

    String suffix = getSuffix(concreteContext);
    SourceRange replaceRange = null;
    if (suffix.equals("")) { //$NON-NLS-1$
      replaceRange = getReplacementRange(concreteContext);
    } else {
      replaceRange = getReplacementRangeWithBraces(concreteContext);
    }

    try {
      ITypeHierarchy hierarchy = getCompanion().getSuperTypeHierarchy(
          declaringClass, null);
      IMethod[] superClassMethods = PHPModelUtils
          .getSuperTypeHierarchyMethod(declaringClass, hierarchy,
              prefix, exactName, null);
      for (IMethod superMethod : superClassMethods) {
        if (declaringClass.getMethod(superMethod.getElementName())
            .exists()) {
          continue;
        }
        int flags = superMethod.getFlags();
        if (!PHPFlags.isFinal(flags) && !PHPFlags.isPrivate(flags)
            && !PHPFlags.isStatic(flags)) {
          reporter.reportMethod(superMethod, CONSTRUCTOR_SUFFIX,
              replaceRange);
        }
      }
    } catch (CoreException e) {
      PHPCorePlugin.log(e);
    }

    PHPVersion phpVersion = concreteContext.getPhpVersion();

    // Add magic methods:
    Set<String> functions = new TreeSet<String>();
    functions.addAll(Arrays.asList(PHPMagicMethods.getMethods(phpVersion)));

    // Add constructors:
    functions.add(declaringClass.getElementName());
    if (phpVersion.isGreaterThan(PHPVersion.PHP4)) {
      functions.add("__construct"); //$NON-NLS-1$
      functions.add("__destruct"); //$NON-NLS-1$
    }

    for (String function : functions) {
      if (CodeAssistUtils.startsWithIgnoreCase(function, prefix)) {
        if (!requestor.isContextInformationMode()
            || function.length() == prefix.length()) {
          FakeMethod fakeMethod = new FakeMethod(
              (ModelElement) declaringClass, function);
          if (function.equals("__construct")) { //$NON-NLS-1$
            fakeMethod.setConstructor(true);
View Full Code Here

  public void apply(ICompletionReporter reporter) throws BadLocationException {

    ICompletionContext context = getContext();

    AbstractCompletionContext abstractContext = (AbstractCompletionContext) context;
    CompletionRequestor requestor = abstractContext
        .getCompletionRequestor();

    if (abstractContext.getPrefixWithoutProcessing().trim().length() == 0) {
      return;
    }

    String prefix = abstractContext.getPrefix();
    if (prefix.startsWith("$")) { //$NON-NLS-1$
      return;
    }

    MatchRule matchRule = MatchRule.PREFIX;
    if (requestor.isContextInformationMode()) {
      matchRule = MatchRule.EXACT;
    }
    IDLTKSearchScope scope = createSearchScope();

    IMethod[] functions = PhpModelAccess.getDefault().findMethods(prefix,
View Full Code Here

 
  @Override
  public void apply(ICompletionReporter reporter) throws BadLocationException {

    TransUnitCompletionContext context = (TransUnitCompletionContext) getContext();
    CompletionRequestor req = context.getCompletionRequestor();
   
   
    if (!req.getClass().getName().contains("Symfony")) {
      return;     
    }
   
    IScriptProject project = context.getSourceModule().getScriptProject();
    SourceRange range = getReplacementRange(context);   
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.core.CompletionRequestor

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.