This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 225603
Collapse All | Expand All

(-)a/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java (-4 / +8 lines)
Lines 1346-1355 Link Here
1346
    }
1346
    }
1347
1347
1348
    public VariableScope getVariableScope(int offset) {
1348
    public VariableScope getVariableScope(int offset) {
1349
        return getVariableScope(getFileScope().getElements(), offset);
1350
    }
1351
1352
    private VariableScope getVariableScope(List<? extends ModelElement> elements, int offset) {
1349
        VariableScope retval = null;
1353
        VariableScope retval = null;
1350
        List<ModelElement> elements = new ArrayList<ModelElement>();
1354
        List<ModelElement> subElements = new LinkedList<ModelElement>();
1351
        elements.add(getFileScope());
1352
        elements.addAll(ModelUtils.getElements(getFileScope(), true));
1353
        for (ModelElement modelElement : elements) {
1355
        for (ModelElement modelElement : elements) {
1354
            if (modelElement instanceof VariableScope) {
1356
            if (modelElement instanceof VariableScope) {
1355
                VariableScope varScope = (VariableScope) modelElement;
1357
                VariableScope varScope = (VariableScope) modelElement;
Lines 1364-1374 Link Here
1364
                    if (possibleScope && blockRange.containsInclusive(offset)
1366
                    if (possibleScope && blockRange.containsInclusive(offset)
1365
                            && (retval == null || retval.getBlockRange().overlaps(varScope.getBlockRange()))) {
1367
                            && (retval == null || retval.getBlockRange().overlaps(varScope.getBlockRange()))) {
1366
                        retval = varScope;
1368
                        retval = varScope;
1369
                        subElements.addAll(varScope.getElements());
1367
                    }
1370
                    }
1368
                }
1371
                }
1369
            }
1372
            }
1370
        }
1373
        }
1371
        return retval;
1374
        VariableScope subResult = subElements.isEmpty() ? null : getVariableScope(subElements, offset);
1375
        return subResult == null ? retval : subResult;
1372
    }
1376
    }
1373
1377
1374
    private void buildCodeMarks(final int offset) {
1378
    private void buildCodeMarks(final int offset) {
(-)a/php.editor/src/org/netbeans/modules/php/editor/parser/SemanticAnalysis.java (-4 / +45 lines)
Lines 48-53 Link Here
48
import java.util.List;
48
import java.util.List;
49
import java.util.Map;
49
import java.util.Map;
50
import java.util.Set;
50
import java.util.Set;
51
import java.util.WeakHashMap;
51
import org.netbeans.modules.csl.api.ColoringAttributes;
52
import org.netbeans.modules.csl.api.ColoringAttributes;
52
import org.netbeans.modules.csl.api.OffsetRange;
53
import org.netbeans.modules.csl.api.OffsetRange;
53
import org.netbeans.modules.csl.api.SemanticAnalyzer;
54
import org.netbeans.modules.csl.api.SemanticAnalyzer;
Lines 433-442 Link Here
433
            super.visit(node);
434
            super.visit(node);
434
        }
435
        }
435
436
437
        private final Map<TypeScope, Collection<? extends MethodScope>> typeToMethodCache = new WeakHashMap<TypeScope, Collection<? extends MethodScope>>();
438
        private Collection<? extends MethodScope> getMethods(TypeScope typeScope) {
439
            Collection<? extends MethodScope> methods = typeToMethodCache.get(typeScope);
440
            if (methods == null) {
441
                methods = typeScope.getMethods();
442
                typeToMethodCache.put(typeScope, methods);
443
            }
444
            return methods;
445
        }
446
436
        private boolean isDeprecatedMethodInvocation(Collection<? extends TypeScope> typeScopes, Identifier identifier) {
447
        private boolean isDeprecatedMethodInvocation(Collection<? extends TypeScope> typeScopes, Identifier identifier) {
437
            boolean isDeprecated = false;
448
            boolean isDeprecated = false;
438
            for (TypeScope typeScope : typeScopes) {
449
            for (TypeScope typeScope : typeScopes) {
439
                for (MethodScope methodScope : typeScope.getMethods()) {
450
                for (MethodScope methodScope : getMethods(typeScope)) {
440
                    if (methodScope.getName().equals(identifier.getName()) && methodScope.isDeprecated()) {
451
                    if (methodScope.getName().equals(identifier.getName()) && methodScope.isDeprecated()) {
441
                        isDeprecated = true;
452
                        isDeprecated = true;
442
                        break;
453
                        break;
Lines 540-555 Link Here
540
            super.scan(node.getDispatcher());
551
            super.scan(node.getDispatcher());
541
        }
552
        }
542
553
554
        private final Map<TypeScope, Collection<? extends org.netbeans.modules.php.editor.model.FieldElement>> typeToFieldCache
555
                = new WeakHashMap<TypeScope, Collection<? extends org.netbeans.modules.php.editor.model.FieldElement>>();
556
        private Collection<? extends org.netbeans.modules.php.editor.model.FieldElement> getFields(ClassScope classScope) {
557
            Collection<? extends org.netbeans.modules.php.editor.model.FieldElement> fields = typeToFieldCache.get(classScope);
558
            if (fields == null) {
559
                fields = classScope.getDeclaredFields();
560
                typeToFieldCache.put(classScope, fields);
561
            }
562
            return fields;
563
        }
564
565
        private Collection<? extends org.netbeans.modules.php.editor.model.FieldElement> getFields(TraitScope traitScope) {
566
            Collection<? extends org.netbeans.modules.php.editor.model.FieldElement> fields = typeToFieldCache.get(traitScope);
567
            if (fields == null) {
568
                fields = traitScope.getDeclaredFields();
569
                typeToFieldCache.put(traitScope, fields);
570
            }
571
            return fields;
572
        }
573
543
        private boolean isDeprecatedFieldAccess(Collection<? extends TypeScope> typeScopes, String variableName) {
574
        private boolean isDeprecatedFieldAccess(Collection<? extends TypeScope> typeScopes, String variableName) {
544
            boolean isDeprecated = false;
575
            boolean isDeprecated = false;
545
            for (TypeScope typeScope : typeScopes) {
576
            for (TypeScope typeScope : typeScopes) {
546
                Collection<? extends org.netbeans.modules.php.editor.model.FieldElement> declaredFields = null;
577
                Collection<? extends org.netbeans.modules.php.editor.model.FieldElement> declaredFields = null;
547
                if (typeScope instanceof ClassScope) {
578
                if (typeScope instanceof ClassScope) {
548
                    ClassScope classScope = (ClassScope) typeScope;
579
                    ClassScope classScope = (ClassScope) typeScope;
549
                    declaredFields = classScope.getDeclaredFields();
580
                    declaredFields = getFields(classScope);
550
                } else if (typeScope instanceof TraitScope) {
581
                } else if (typeScope instanceof TraitScope) {
551
                    TraitScope traitScope = (TraitScope) typeScope;
582
                    TraitScope traitScope = (TraitScope) typeScope;
552
                    declaredFields = traitScope.getDeclaredFields();
583
                    declaredFields = getFields(traitScope);
553
                }
584
                }
554
                if (declaredFields != null) {
585
                if (declaredFields != null) {
555
                    for (org.netbeans.modules.php.editor.model.FieldElement fieldElement : declaredFields) {
586
                    for (org.netbeans.modules.php.editor.model.FieldElement fieldElement : declaredFields) {
Lines 659-668 Link Here
659
            super.visit(node);
690
            super.visit(node);
660
        }
691
        }
661
692
693
        private final Map<TypeScope, Collection<? extends ClassConstantElement>> typeToConstantCache = new WeakHashMap<TypeScope, Collection<? extends ClassConstantElement>>();
694
        private Collection<? extends ClassConstantElement> getConstants(TypeScope typeScope) {
695
            Collection<? extends ClassConstantElement> constants = typeToConstantCache.get(typeScope);
696
            if (constants == null) {
697
                constants = typeScope.getDeclaredConstants();
698
                typeToConstantCache.put(typeScope, constants);
699
            }
700
            return constants;
701
        }
702
662
        private boolean isDeprecatedConstantAccess(Collection<? extends TypeScope> typeScopes, String constantName) {
703
        private boolean isDeprecatedConstantAccess(Collection<? extends TypeScope> typeScopes, String constantName) {
663
            boolean isDeprecated = false;
704
            boolean isDeprecated = false;
664
            for (TypeScope typeScope : typeScopes) {
705
            for (TypeScope typeScope : typeScopes) {
665
                for (ClassConstantElement constantElement : typeScope.getDeclaredConstants()) {
706
                for (ClassConstantElement constantElement : getConstants(typeScope)) {
666
                    if (constantElement.getName().equals(constantName) && constantElement.isDeprecated()) {
707
                    if (constantElement.getName().equals(constantName) && constantElement.isDeprecated()) {
667
                        isDeprecated = true;
708
                        isDeprecated = true;
668
                        break;
709
                        break;

Return to bug 225603