public IGoal[] init() { PHPDocClassVariableGoal typedGoal = (PHPDocClassVariableGoal) goal; TypeContext context = (TypeContext) typedGoal.getContext(); String variableName = typedGoal.getVariableName(); int offset = typedGoal.getOffset(); IModelAccessCache cache = context.getCache(); IType[] types = PHPTypeInferenceUtils.getModelElements(context.getInstanceType(), context, offset, cache); Map<PHPDocBlock, IField> docs = new HashMap<PHPDocBlock, IField>(); // remove array index from field name if (variableName.endsWith("]")) { // $NON-NLS-1$ int index = variableName.indexOf("["); // $NON-NLS-1$ if (index != -1) { variableName = variableName.substring(0, index); } } if (types != null) { for (IType type : types) { try { // we look in whole hiearchy ITypeHierarchy superHierarchy; if (cache != null) { superHierarchy = cache.getSuperTypeHierarchy(type, null); } else { superHierarchy = type.newSupertypeHierarchy(null); } IType[] superTypes = superHierarchy.getAllTypes(); for (IType superType : superTypes) { IField[] typeField = PHPModelUtils.getTypeField(superType, variableName, true); if (typeField.length > 0) { PHPDocBlock docBlock = PHPModelUtils.getDocBlock(typeField[0]); if (docBlock != null) { docs.put(docBlock, typeField[0]); } } } } catch (ModelException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); } } } } for (Entry<PHPDocBlock, IField> entry : docs.entrySet()) { PHPDocBlock doc = entry.getKey(); IField typeField = entry.getValue(); IType currentNamespace = PHPModelUtils.getCurrentNamespace(typeField); IModelElement space = currentNamespace != null ? currentNamespace : typeField.getSourceModule(); for (PHPDocTag tag : doc.getTags(PHPDocTag.VAR)) { // do it like for // PHPDocumentationContentAccess#handleBlockTags(List tags): // variable name can be optional, but if present keep only // the good ones if (tag.getVariableReference() != null && !tag.getVariableReference().getName().equals(variableName)) { continue; } evaluated.addAll( Arrays.asList( PHPEvaluationUtils.evaluatePHPDocType( tag.getTypeReferences(), space, tag.sourceStart(), null))); } } return IGoal.NO_GOALS; }
/** @deprecated will be removed in Mars */ public static MultiTypeType getArrayType(String type, IType currentNamespace, int offset) { return PHPEvaluationUtils.getArrayType(type, currentNamespace, offset); }