Package org.eclipse.dltk.ti

Examples of org.eclipse.dltk.ti.IContext


    if (inherit != null && inherit.length == 1) {
      IType type = method.getDeclaringType();

      if (type != null) {
        try {
          IContext context = goal.getContext();
          IModelAccessCache cache = null;
          if (context instanceof IModelCacheContext) {
            cache = ((IModelCacheContext) context).getCache();
          }
          IType[] superClasses = PHPModelUtils.getSuperClasses(
View Full Code Here


  }

  public IGoal[] init() {
    GlobalVariableReferencesGoal typedGoal = (GlobalVariableReferencesGoal) goal;

    IContext context = goal.getContext();
    ISourceModuleContext sourceModuleContext = null;
    IScriptProject scriptProject = null;
    if (context instanceof ISourceModuleContext) {
      sourceModuleContext = (ISourceModuleContext) context;
      scriptProject = sourceModuleContext.getSourceModule()
          .getScriptProject();
    }

    String variableName = typedGoal.getVariableName();

    boolean exploreOtherFiles = true;

    // Find all global variables from mixin

    IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);

    IField[] elements = PhpModelAccess.getDefault().findFields(
        variableName, MatchRule.EXACT, Modifiers.AccGlobal,
        Modifiers.AccConstant, scope, null);

    // if no element found, return empty array.
    if (elements == null) {
      return new IGoal[] {};
    }

    Map<ISourceModule, SortedSet<ISourceRange>> offsets = new HashMap<ISourceModule, SortedSet<ISourceRange>>();

    Comparator<ISourceRange> sourceRangeComparator = new Comparator<ISourceRange>() {
      public int compare(ISourceRange o1, ISourceRange o2) {
        return o1.getOffset() - o2.getOffset();
      }
    };

    for (IModelElement element : elements) {
      if (element instanceof SourceField) {
        SourceField sourceField = (SourceField) element;
        ISourceModule sourceModule = sourceField.getSourceModule();
        if (!offsets.containsKey(sourceModule)) {
          offsets.put(sourceModule, new TreeSet<ISourceRange>(
              sourceRangeComparator));
        }
        try {
          offsets.get(sourceModule).add(sourceField.getSourceRange());
        } catch (ModelException e) {
          if (DLTKCore.DEBUG) {
            e.printStackTrace();
          }
        }
      }
    }

    List<IGoal> subGoals = new LinkedList<IGoal>();
    for (Entry<ISourceModule, SortedSet<ISourceRange>> entry : offsets
        .entrySet()) {
      ISourceModule sourceModule = entry.getKey();
      if (exploreOtherFiles
          || (sourceModuleContext != null && sourceModuleContext
              .getSourceModule().equals(sourceModule))) {

        ModuleDeclaration moduleDeclaration = SourceParserUtil
            .getModuleDeclaration(sourceModule);
        SortedSet<ISourceRange> fileOffsets = entry.getValue();

        if (!fileOffsets.isEmpty()) {
          GlobalReferenceDeclSearcher varSearcher = new GlobalReferenceDeclSearcher(
              sourceModule, fileOffsets, variableName);
          try {
            moduleDeclaration.traverse(varSearcher);

            DeclarationScope[] scopes = varSearcher.getScopes();
            for (DeclarationScope s : scopes) {
              for (Declaration decl : s
                  .getDeclarations(variableName)) {

                IContext context2 = s.getContext();
                if (context2 instanceof IModelCacheContext
                    && this.goal.getContext() instanceof IModelCacheContext) {
                  ((IModelCacheContext) context2)
                      .setCache(((IModelCacheContext) this.goal
                          .getContext()).getCache());
View Full Code Here

    return "parent".equals(name); //$NON-NLS-1$
  }

  public IGoal[] init() {
    final IContext context = goal.getContext();
    String className = typeReference.getName();

    if (isSelfOrStatic()) {
      if (context instanceof MethodContext) {
        MethodContext methodContext = (MethodContext) context;
View Full Code Here

    SimpleReference type = parameter.getParameterType();
    if (type != null && "array".equals(type.getName()) == false) { //$NON-NLS-1$
      result = PHPClassType.fromSimpleReference(type);
    } else {
      IContext context = typedGoal.getContext();
      if (context instanceof MethodContext) {
        MethodContext methodContext = (MethodContext) context;
        PHPMethodDeclaration methodDeclaration = (PHPMethodDeclaration) methodContext
            .getMethodNode();
        PHPDocBlock[] docBlocks = new PHPDocBlock[0];
View Full Code Here

          e.printStackTrace();
        }
      }
      // final boolean found[] = new boolean[1];
      if (decl != null) {
        final IContext innerContext = ASTUtils.findContext(
            sourceModule, module, decl);
        if (innerContext instanceof MethodContext) {
          MethodContext mc = (MethodContext) innerContext;
          mc.setCurrentType(mat.types[i]);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ti.IContext

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.