Examples of ArrayKeyContext


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

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

    ArrayKeyContext arrayContext = (ArrayKeyContext) context;
    String prefix = arrayContext.getPrefix();
    CompletionRequestor requestor = arrayContext.getCompletionRequestor();
    IModelElement enclosingElement;
    try {
      enclosingElement = arrayContext.getSourceModule().getElementAt(
          arrayContext.getOffset());
      while (enclosingElement instanceof IField) {
        enclosingElement = enclosingElement.getParent();
      }
      if (!(enclosingElement instanceof IMethod)) {
        return;
View Full Code Here

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

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

    SourceRange replaceRange = getReplacementRange(context);
    ArrayKeyContext arrayContext = (ArrayKeyContext) context;
    boolean endsWithQuota = arrayContext.getNextChar() == '\''
        || arrayContext.getNextChar() == '\"';
    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

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

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

    ArrayKeyContext arrayContext = (ArrayKeyContext) context;
    CompletionRequestor requestor = arrayContext.getCompletionRequestor();
    String arrayVarName = arrayContext.getArrayVarName();

    String prefix = arrayContext.getPrefix();

    int extraObject = ProposalExtraInfo.DEFAULT;
    if (!arrayContext.hasQuotes()) {
      extraObject |= ProposalExtraInfo.ADD_QUOTES;
    }
    // report server variables:
    if (arrayVarName.equals("$_SERVER") //$NON-NLS-1$
        || arrayVarName.equals("$HTTP_SERVER_VARS")) { // NON-NLS-1 //$NON-NLS-1$
      // //NON-NLS-2
      reportVariables(reporter, arrayContext, SERVER_VARS, prefix,
          extraObject);
    }
    // report session variables:
    else if (arrayVarName.equals("$_SESSION") //$NON-NLS-1$
        || arrayVarName.equals("$HTTP_SESSION_VARS")) { // NON-NLS-1 //$NON-NLS-1$
      // //NON-NLS-2
      reportVariables(reporter, arrayContext, SESSION_VARS, prefix,
          extraObject);
    }
    // report global variables in special globals array:
    else if (arrayVarName.equals("$GLOBALS")) { // NON-NLS-1 //$NON-NLS-1$

      MatchRule matchRule = MatchRule.PREFIX;
      if (requestor.isContextInformationMode()) {
        matchRule = MatchRule.EXACT;
      }
      IDLTKSearchScope scope = createSearchScope();
      IField[] elements = PhpModelAccess.getDefault().findFields(
          "$" + prefix, matchRule, Modifiers.AccGlobal, //$NON-NLS-1$
          Modifiers.AccConstant, scope, null);
      List<IField> list = new ArrayList<IField>();

      if (!prefix.startsWith("$")) { //$NON-NLS-1$
        elements = PhpModelAccess.getDefault().findFields("$" + prefix, //$NON-NLS-1$
            matchRule, Modifiers.AccGlobal, Modifiers.AccConstant,
            scope, null);
        list.addAll(Arrays.asList(elements));
        elements = list.toArray(new IField[list.size()]);
      }

      SourceRange replaceRange = getReplacementRange(arrayContext);
      for (IModelElement element : elements) {
        IField field = (IField) element;
        try {
          ISourceRange sourceRange = field.getSourceRange();
          FakeField fakeField = new FakeField(
              (ModelElement) field.getParent(), field
                  .getElementName().substring(1),
              sourceRange.getOffset(), sourceRange.getLength());
          reporter.reportField(fakeField, "", replaceRange, true, 0, //$NON-NLS-1$
              extraObject); // NON-NLS-1
        } catch (ModelException e) {
          PHPCorePlugin.log(e);
        }
      }

      PHPVersion phpVersion = arrayContext.getPhpVersion();
      reportVariables(reporter, arrayContext,
          PHPVariables.getVariables(phpVersion), prefix, true,
          extraObject);
    }
  }
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.