Source Code Cross Referenced for LocalVariableLocator.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » core » search » matching » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.internal.core.search.matching 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.core.search.matching;
011:
012:        import org.eclipse.core.runtime.CoreException;
013:        import org.eclipse.jdt.core.IJavaElement;
014:        import org.eclipse.jdt.internal.compiler.ast.*;
015:        import org.eclipse.jdt.internal.compiler.lookup.Binding;
016:        import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
017:        import org.eclipse.jdt.internal.core.LocalVariable;
018:
019:        public class LocalVariableLocator extends VariableLocator {
020:
021:            public LocalVariableLocator(LocalVariablePattern pattern) {
022:                super (pattern);
023:            }
024:
025:            public int match(LocalDeclaration node, MatchingNodeSet nodeSet) {
026:                int referencesLevel = IMPOSSIBLE_MATCH;
027:                if (this .pattern.findReferences)
028:                    // must be a write only access with an initializer
029:                    if (this .pattern.writeAccess && !this .pattern.readAccess
030:                            && node.initialization != null)
031:                        if (matchesName(this .pattern.name, node.name))
032:                            referencesLevel = ((InternalSearchPattern) this .pattern).mustResolve ? POSSIBLE_MATCH
033:                                    : ACCURATE_MATCH;
034:
035:                int declarationsLevel = IMPOSSIBLE_MATCH;
036:                if (this .pattern.findDeclarations)
037:                    if (matchesName(this .pattern.name, node.name))
038:                        if (node.declarationSourceStart == getLocalVariable().declarationSourceStart)
039:                            declarationsLevel = ((InternalSearchPattern) this .pattern).mustResolve ? POSSIBLE_MATCH
040:                                    : ACCURATE_MATCH;
041:
042:                return nodeSet.addMatch(node,
043:                        referencesLevel >= declarationsLevel ? referencesLevel
044:                                : declarationsLevel); // use the stronger match
045:            }
046:
047:            private LocalVariable getLocalVariable() {
048:                return ((LocalVariablePattern) this .pattern).localVariable;
049:            }
050:
051:            protected void matchReportReference(ASTNode reference,
052:                    IJavaElement element, Binding elementBinding, int accuracy,
053:                    MatchLocator locator) throws CoreException {
054:                int offset = -1;
055:                int length = -1;
056:                if (reference instanceof  SingleNameReference) {
057:                    offset = reference.sourceStart;
058:                    length = reference.sourceEnd - offset + 1;
059:                } else if (reference instanceof  QualifiedNameReference) {
060:                    QualifiedNameReference qNameRef = (QualifiedNameReference) reference;
061:                    long sourcePosition = qNameRef.sourcePositions[0];
062:                    offset = (int) (sourcePosition >>> 32);
063:                    length = ((int) sourcePosition) - offset + 1;
064:                } else if (reference instanceof  LocalDeclaration) {
065:                    LocalVariable localVariable = getLocalVariable();
066:                    offset = localVariable.nameStart;
067:                    length = localVariable.nameEnd - offset + 1;
068:                    element = localVariable;
069:                }
070:                if (offset >= 0) {
071:                    match = locator.newLocalVariableReferenceMatch(element,
072:                            accuracy, offset, length, reference);
073:                    locator.report(match);
074:                }
075:            }
076:
077:            protected int matchContainer() {
078:                return METHOD_CONTAINER;
079:            }
080:
081:            protected int matchLocalVariable(LocalVariableBinding variable,
082:                    boolean matchName) {
083:                if (variable == null)
084:                    return INACCURATE_MATCH;
085:
086:                if (matchName
087:                        && !matchesName(this .pattern.name, variable
088:                                .readableName()))
089:                    return IMPOSSIBLE_MATCH;
090:
091:                return variable.declaration.declarationSourceStart == getLocalVariable().declarationSourceStart ? ACCURATE_MATCH
092:                        : IMPOSSIBLE_MATCH;
093:            }
094:
095:            protected int referenceType() {
096:                return IJavaElement.LOCAL_VARIABLE;
097:            }
098:
099:            public int resolveLevel(ASTNode possiblelMatchingNode) {
100:                if (this .pattern.findReferences)
101:                    if (possiblelMatchingNode instanceof  NameReference)
102:                        return resolveLevel((NameReference) possiblelMatchingNode);
103:                if (possiblelMatchingNode instanceof  LocalDeclaration)
104:                    return matchLocalVariable(
105:                            ((LocalDeclaration) possiblelMatchingNode).binding,
106:                            true);
107:                return IMPOSSIBLE_MATCH;
108:            }
109:
110:            public int resolveLevel(Binding binding) {
111:                if (binding == null)
112:                    return INACCURATE_MATCH;
113:                if (!(binding instanceof  LocalVariableBinding))
114:                    return IMPOSSIBLE_MATCH;
115:
116:                return matchLocalVariable((LocalVariableBinding) binding, true);
117:            }
118:
119:            protected int resolveLevel(NameReference nameRef) {
120:                return resolveLevel(nameRef.binding);
121:            }
122:        }
w__w___w___.___ja_v_a__2___s_._co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.