Package org.eclipse.php.internal.core.codeassist.contexts

Examples of org.eclipse.php.internal.core.codeassist.contexts.ClassMemberContext


    ICompletionContext context = getContext();
    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()) {
            result.add(field);
          } else if (!isFiltered(field, type, concreteContext)) {
            result.add(field);
          }
        }
      } catch (CoreException e) {
        PHPCorePlugin.log(e);
      }
    }
    if (concreteContext instanceof ClassStaticMemberContext
        && concreteContext.getTriggerType() == Trigger.CLASS
        && !concreteContext.isInUseTraitStatement()
        && PHPVersion.PHP5_4
            .isLessThan(concreteContext.getPhpVersion())
        && (CLASS_KEYWORD.startsWith(prefix.toLowerCase()) || CLASS_KEYWORD
            .equals(prefix.toLowerCase()))) {
      try {
        ITextRegion phpToken = concreteContext.getPhpScriptRegion()
            .getPhpToken(
                concreteContext.getPHPToken().getStart() - 1);
        if (phpToken != null
            && PHPRegionTypes.PHP_PAAMAYIM_NEKUDOTAYIM
                .equals(phpToken.getType())) {
          phpToken = concreteContext
              .getPHPToken(phpToken.getStart() - 1);
        }

        if (phpToken != null && isStaticCall(phpToken.getType())) {
          result.add(new FakeField(new FakeType(
              (ModelElement) concreteContext.getSourceModule(),
              STD_CLASS), CLASS_KEYWORD, Modifiers.AccConstant
              | Modifiers.AccPublic));
        }
      } catch (BadLocationException e) {
        Logger.logException(e);
      }
    }

    for (IField field : result) {
      reporter.reportField(field, getSuffix(), replaceRange,
          concreteContext.getTriggerType() == Trigger.OBJECT);
    }
  }
View Full Code Here


    ICompletionContext context = getContext();
    if (!(context instanceof ClassMemberContext)) {
      return;
    }

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

    String prefix = concreteContext.getPrefix();
    boolean isParentCall = isParentCall(concreteContext);
    String suffix = getSuffix(concreteContext);

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

    PHPVersion phpVersion = concreteContext.getPhpVersion();
    Set<String> magicMethods = new HashSet<String>();
    magicMethods.addAll(Arrays.asList(PHPMagicMethods
        .getMethods(phpVersion)));

    boolean exactName = requestor.isContextInformationMode();
    // for methodName(|),we need set exactName to true
    if (!exactName
        && concreteContext.getOffset() - 1 >= 0
        && concreteContext.getDocument().getChar(
            concreteContext.getOffset() - 1) == '(') {
      exactName = true;
    }
    List<IMethod> result = new LinkedList<IMethod>();
    for (IType type : concreteContext.getLhsTypes()) {
      try {
        ITypeHierarchy hierarchy = getCompanion()
            .getSuperTypeHierarchy(type, null);

        IMethod[] methods = isParentCall ? PHPModelUtils
            .getSuperTypeHierarchyMethod(type, hierarchy, prefix,
                exactName, null) : PHPModelUtils
            .getTypeHierarchyMethod(type, hierarchy, prefix,
                exactName, null);

        boolean inConstructor = isInConstructor(type,
            type.getMethods(), concreteContext);
        for (IMethod method : removeOverriddenElements(Arrays
            .asList(methods))) {

          if (concreteContext.isInUseTraitStatement()) {
            // result.add(method);
            reporter.reportMethod((IMethod) method, "", //$NON-NLS-1$
                replaceRange, ProposalExtraInfo.METHOD_ONLY);
          } else if ((!isConstructor(method) || inConstructor
              && isSuperConstructor(method, type, concreteContext))
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.codeassist.contexts.ClassMemberContext

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.