Source Code Cross Referenced for SearchableEnvironmentRequestor.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » core » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 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;
011:
012:        import org.eclipse.jdt.core.IInitializer;
013:        import org.eclipse.jdt.core.IJavaElement;
014:        import org.eclipse.jdt.core.IJavaProject;
015:        import org.eclipse.jdt.core.IPackageFragment;
016:        import org.eclipse.jdt.core.IType;
017:        import org.eclipse.jdt.core.JavaCore;
018:        import org.eclipse.jdt.core.JavaModelException;
019:        import org.eclipse.jdt.core.compiler.CharOperation;
020:        import org.eclipse.jdt.internal.codeassist.ISearchRequestor;
021:        import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
022:        import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
023:        import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
024:
025:        /**
026:         * Implements <code>IJavaElementRequestor</code>, wrappering and forwarding
027:         * results onto a <code>org.eclipse.jdt.internal.codeassist.api.ISearchRequestor</code>.
028:         */
029:        class SearchableEnvironmentRequestor extends JavaElementRequestor {
030:            /**
031:             * The <code>ISearchRequestor</code> this JavaElementRequestor wraps
032:             * and forwards results to.
033:             */
034:            protected ISearchRequestor requestor;
035:            /**
036:             * The <code>ICompilationUNit</code> this JavaElementRequestor will not
037:             * accept types within.
038:             */
039:            protected ICompilationUnit unitToSkip;
040:
041:            protected IJavaProject project;
042:
043:            protected NameLookup nameLookup;
044:
045:            protected boolean checkAccessRestrictions;
046:
047:            /**
048:             * Constructs a SearchableEnvironmentRequestor that wraps the
049:             * given SearchRequestor.
050:             */
051:            public SearchableEnvironmentRequestor(ISearchRequestor requestor) {
052:                this .requestor = requestor;
053:                this .unitToSkip = null;
054:                this .project = null;
055:                this .nameLookup = null;
056:                this .checkAccessRestrictions = false;
057:
058:            }
059:
060:            /**
061:             * Constructs a SearchableEnvironmentRequestor that wraps the
062:             * given SearchRequestor.  The requestor will not accept types in
063:             * the <code>unitToSkip</code>.
064:             */
065:            public SearchableEnvironmentRequestor(ISearchRequestor requestor,
066:                    ICompilationUnit unitToSkip, IJavaProject project,
067:                    NameLookup nameLookup) {
068:                this .requestor = requestor;
069:                this .unitToSkip = unitToSkip;
070:                this .project = project;
071:                this .nameLookup = nameLookup;
072:                this .checkAccessRestrictions = !JavaCore.IGNORE.equals(project
073:                        .getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE,
074:                                true))
075:                        || !JavaCore.IGNORE.equals(project.getOption(
076:                                JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE,
077:                                true));
078:            }
079:
080:            /**
081:             * Do nothing, a SearchRequestor does not accept initializers
082:             * so there is no need to forward this results.
083:             *
084:             * @see IJavaElementRequestor
085:             */
086:            public void acceptInitializer(IInitializer initializer) {
087:                // implements interface method
088:            }
089:
090:            /**
091:             * @see IJavaElementRequestor
092:             */
093:            public void acceptPackageFragment(IPackageFragment packageFragment) {
094:                this .requestor.acceptPackage(packageFragment.getElementName()
095:                        .toCharArray());
096:            }
097:
098:            /**
099:             * @see IJavaElementRequestor
100:             */
101:            public void acceptType(IType type) {
102:                try {
103:                    if (this .unitToSkip != null
104:                            && this .unitToSkip
105:                                    .equals(type.getCompilationUnit())) {
106:                        return;
107:                    }
108:                    char[] packageName = type.getPackageFragment()
109:                            .getElementName().toCharArray();
110:                    boolean isBinary = type instanceof  BinaryType;
111:
112:                    // determine associated access restriction
113:                    AccessRestriction accessRestriction = null;
114:
115:                    if (this .checkAccessRestrictions
116:                            && (isBinary || !type.getJavaProject().equals(
117:                                    this .project))) {
118:                        PackageFragmentRoot root = (PackageFragmentRoot) type
119:                                .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
120:                        ClasspathEntry entry = (ClasspathEntry) this .nameLookup.rootToResolvedEntries
121:                                .get(root);
122:                        if (entry != null) { // reverse map always contains resolved CP entry
123:                            AccessRuleSet accessRuleSet = entry
124:                                    .getAccessRuleSet();
125:                            if (accessRuleSet != null) {
126:                                // TODO (philippe) improve char[] <-> String conversions to avoid performing them on the fly
127:                                char[][] packageChars = CharOperation.splitOn(
128:                                        '.', packageName);
129:                                char[] fileWithoutExtension = type
130:                                        .getElementName().toCharArray();
131:                                accessRestriction = accessRuleSet
132:                                        .getViolatedRestriction(CharOperation
133:                                                .concatWith(packageChars,
134:                                                        fileWithoutExtension,
135:                                                        '/'));
136:                            }
137:                        }
138:                    }
139:                    this .requestor.acceptType(packageName, type
140:                            .getElementName().toCharArray(), null, type
141:                            .getFlags(), accessRestriction);
142:                } catch (JavaModelException jme) {
143:                    // ignore
144:                }
145:            }
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.