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; |