Examples of PHPVersion


Examples of org.eclipse.php.internal.core.PHPVersion

      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();
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

      // meaning its a class variable and not a function
      return getVariableType(types, propertyName, offset);
    }

    boolean arrayReference = false;
    PHPVersion version = ProjectOptions.getPhpVersion(sourceModule
        .getScriptProject().getProject());
    if (propertyName.endsWith("]") //$NON-NLS-1$
        && version.isGreaterThan(PHPVersion.PHP5_3)) {
      int closeBracketIndex = propertyName.lastIndexOf(')');
      if (closeBracketIndex >= 0) {
        if (propertyName.indexOf('[', closeBracketIndex) > closeBracketIndex) {
          arrayReference = true;
        }
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

    return result.toArray(new IType[result.size()]);
  }

  public static IType[] getTraitsFor(ISourceModule sourceModule,
      TextSequence statementText, int endPosition, int offset) {
    PHPVersion phpVersion = ProjectOptions.getPhpVersion(sourceModule
        .getScriptProject().getProject());
    if (phpVersion.isLessThan(PHPVersion.PHP5_4)) {
      return EMPTY_TYPES;
    }
    endPosition = PHPTextSequenceUtilities.readBackwardSpaces(
        statementText, endPosition); // read whitespace
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

   */
  private static IType[] innerGetClassName(ISourceModule sourceModule,
      TextSequence statementText, int propertyEndPosition,
      boolean isClassTriger, int offset) {

    PHPVersion phpVersion = ProjectOptions.getPhpVersion(sourceModule
        .getScriptProject().getProject());

    int classNameStart = PHPTextSequenceUtilities.readIdentifierStartIndex(
        phpVersion, statementText, propertyEndPosition, true);
    String className = statementText.subSequence(classNameStart,
        propertyEndPosition).toString();
    if (isClassTriger && className != null && className.length() != 0) {
      final String comparable = PHPVersion.PHP5_4.isLessThan(phpVersion) ? className
          .toLowerCase() : className;
      if ("self".equals(comparable) //$NON-NLS-1$
          || "parent".equals(comparable) //$NON-NLS-1$
          || (phpVersion.isGreaterThan(PHPVersion.PHP5) && "static" //$NON-NLS-1$
          .equals(comparable))) {
        IType classData = PHPModelUtils.getCurrentType(sourceModule,
            offset - className.length() - 2); // the offset before
        // "self::",
        // "parent::" or
        // "static::"
        if (classData != null) {
          return new IType[] { classData };
        }
      }
      if (className.length() > 0) {
        if (className.startsWith("$") //$NON-NLS-1$
            && phpVersion.isGreaterThan(PHPVersion.PHP5)) {
          int statementStart = statementText
              .getOriginalOffset(classNameStart);
          return getVariableType(sourceModule, className,
              statementStart);
        } else {
          ModuleDeclaration moduleDeclaration = SourceParserUtil
              .getModuleDeclaration(sourceModule, null);
          FileContext context = new FileContext(sourceModule,
              moduleDeclaration, offset);
          IEvaluatedType type = PHPClassType.fromTypeName(className,
              sourceModule, offset);
          IType[] modelElements = PHPTypeInferenceUtils
              .getModelElements(type, context, offset);
          if (modelElements != null) {
            return modelElements;
          }
          return EMPTY_TYPES;
        }
      }
    }
    if (className.length() == 0) {
      // this can happen if the first char before the property is ']'
      String testedVar = statementText
          .subSequence(0, propertyEndPosition).toString().trim();
      if (testedVar != null && testedVar.length() != 0) {
        // check for $GLOBALS['myVar'] scenario
        Matcher m = globalPattern.matcher(testedVar);
        if (m.matches()) {
          // $GLOBALS['myVar'] => 'myVar'
          String quotedVarName = testedVar.substring(
              testedVar.indexOf('[') + 1, testedVar.indexOf(']'))
              .trim();
          // 'myVar' => $myVar
          className = DOLLAR
              + quotedVarName.substring(1,
                  quotedVarName.length() - 1); //$NON-NLS-1$
          // check for $array[0] scenario
        } else if (testedVar.endsWith("}")) { //$NON-NLS-1$
          className = testedVar;
        } else if (testedVar.endsWith("]")) { //$NON-NLS-1$
          if (statementText.toString().lastIndexOf('[') > 0) {
            int end = statementText.toString().lastIndexOf('[');
            int classNameStart1 = PHPTextSequenceUtilities
                .readIdentifierStartIndex(phpVersion,
                    statementText, end, true);
            className = statementText.subSequence(classNameStart1,
                end).toString();
            // if its object call calc the object type.
            if (className.length() > 0
                && className.charAt(0) == '$') {
              int statementStart = statementText
                  .getOriginalOffset(classNameStart);
              return getArrayVariableType(sourceModule,
                  className, statementStart);
            }
          }
          className = testedVar;
        }
      }
    }
    // if its object call calc the object type.
    if (className.length() > 0 && className.charAt(0) == '$') {
      int statementStart = statementText
          .getOriginalOffset(classNameStart);
      return getVariableType(sourceModule, className, statementStart);
    }
    boolean arrayReference = false;
    if (statementText.charAt(propertyEndPosition - 1) == ']'
        && phpVersion.isGreaterThan(PHPVersion.PHP5_3)) {
      int closeBracketIndex = statementText.toString().lastIndexOf(')');
      if (closeBracketIndex >= 0) {
        if (statementText.toString().indexOf('[', closeBracketIndex) > closeBracketIndex) {
          propertyEndPosition = closeBracketIndex + 1;
          arrayReference = true;
        }
      }
    }
    // if its function call calc the return type.
    if (propertyEndPosition > 0
        && statementText.charAt(propertyEndPosition - 1) == ')') {
      int functionNameEnd = PHPModelUtils.getFunctionNameEndOffset(
          statementText, propertyEndPosition - 1);
      int functionNameStart = PHPTextSequenceUtilities
          .readIdentifierStartIndex(phpVersion, statementText,
              functionNameEnd, false);

      String functionName = statementText.subSequence(functionNameStart,
          functionNameEnd).toString();
      // if its a non class function
      Set<IType> returnTypes = new LinkedHashSet<IType>();
      if (functionNameStart == functionNameEnd
          && statementText.charAt(functionNameStart) == '('
          && propertyEndPosition - 1 > functionNameStart + 1
          && phpVersion.isGreaterThan(PHPVersion.PHP5_3)) {
        TextSequence newClassStatementText = statementText
            .subTextSequence(functionNameStart + 1,
                propertyEndPosition - 1);
        String newClassName = PHPModelUtils
            .getClassNameForNewStatement(newClassStatementText,
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

    // } catch (ModelException e) {
    // PHPCorePlugin.log(e);
    // }
    // }

    PHPVersion phpVersion = context.getPhpVersion();
    if (phpVersion.isGreaterThan(PHPVersion.PHP5_3)) {
      for (String keyword : KEYWORDS) {
        if (keyword.startsWith(prefix)) {
          reporter.reportKeyword(keyword, suffix, replaceRange);
        }
      }
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

  private boolean isDirectSelf;
  private boolean isFunctionParameterContext = false;

  public boolean isValid(ISourceModule sourceModule, int offset,
      CompletionRequestor requestor) {
    PHPVersion phpVersion = ProjectOptions.getPhpVersion(sourceModule);
    if (!super.isValid(sourceModule, offset, requestor)) {
      return false;
    }
    if (getTriggerType() != Trigger.CLASS) {
      return false;
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

        null)) {
      reporter.reportField((IField) element, "", replaceRange, false, //$NON-NLS-1$
          ICompletionReporter.RELEVANCE_ADJUST);
    }

    PHPVersion phpVersion = concreteContext.getPhpVersion();
    for (String variable : PHPVariables.getVariables(phpVersion)) {
      if (variable.startsWith(prefix)) {
        if (!requestor.isContextInformationMode()
            || variable.length() == prefix.length()) {
          reporter.reportField(new FakeField(
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

    AbstractPHPSourceParser parser = createParser(fileName);
    return parser.parse(module, reporter);
  }

  protected AbstractPHPSourceParser createParser(String fileName) {
    PHPVersion phpVersion = ProjectOptions.getPhpVersion(fileName);
    AbstractPHPSourceParser parser = createParser(fileName, phpVersion);
    if (parser == null) {
      throw new IllegalStateException(Messages.PHPSourceParserFactory_0);
    }
    return parser;
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

        };
        try {
          methodContext.getRootNode().traverse(contextFinder);
        } catch (Exception e) {
        }
        PHPVersion phpVersion = ProjectOptions
            .getPhpVersion(methodContext.getSourceModule()
                .getScriptProject().getProject());
        if (lambdas[0] != null
            && (lambdas[0].isStatic() || phpVersion
                .isLessThan(PHPVersion.PHP5_4))) {
          this.results.add(new SimpleType(SimpleType.TYPE_NULL));
        } else {
          IEvaluatedType instanceType = methodContext
              .getInstanceType();
View Full Code Here

Examples of org.eclipse.php.internal.core.PHPVersion

      }
    } 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) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.