001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.modelimpl.csm.core;
043:
044: import java.io.*;
045: import java.util.*;
046: import org.netbeans.modules.cnd.api.model.CsmFile;
047: import org.netbeans.modules.cnd.api.model.CsmProject;
048: import org.netbeans.modules.cnd.api.model.CsmUID;
049: import org.netbeans.modules.cnd.api.project.NativeFileItem;
050: import org.netbeans.modules.cnd.apt.support.APTPreprocHandler;
051: import org.netbeans.modules.cnd.modelimpl.debug.DiagnosticExceptoins;
052: import org.netbeans.modules.cnd.utils.cache.FilePathCache;
053: import org.netbeans.modules.cnd.modelimpl.debug.TraceFlags;
054: import org.netbeans.modules.cnd.repository.spi.Key;
055:
056: /**
057: * @author Vladimir Kvasihn
058: */
059: public final class LibProjectImpl extends ProjectBase {
060:
061: private final String includePath;
062:
063: private LibProjectImpl(ModelImpl model, String includePathName) {
064: super (model, includePathName, includePathName);
065: this .includePath = includePathName;
066: this .projectRoots.fixFolder(includePathName);
067: assert this .includePath != null;
068: }
069:
070: public static LibProjectImpl createInstance(ModelImpl model,
071: String includePathName) {
072: ProjectBase instance = null;
073: assert includePathName != null;
074: if (TraceFlags.PERSISTENT_REPOSITORY) {
075: try {
076: instance = readInstance(model, includePathName,
077: includePathName);
078: } catch (Exception e) {
079: // just report to console;
080: // the code below will create project "from scratch"
081: cleanRepository(includePathName, true);
082: DiagnosticExceptoins.register(e);
083: }
084: }
085: if (instance == null) {
086: instance = new LibProjectImpl(model, includePathName);
087: }
088: if (instance instanceof LibProjectImpl) {
089: assert ((LibProjectImpl) instance).includePath != null;
090: }
091: return (LibProjectImpl) instance;
092:
093: }
094:
095: protected String getPath() {
096: return includePath;
097: }
098:
099: @Override
100: protected void ensureFilesCreated() {
101: }
102:
103: protected boolean isStableStatus() {
104: return true;
105: }
106:
107: @Override
108: protected Collection<Key> getLibrariesKeys() {
109: return Collections.EMPTY_SET;
110: }
111:
112: /** override parent to avoid inifinite recursion */
113: @Override
114: public Collection<CsmProject> getLibraries() {
115: return Collections.EMPTY_SET;
116: }
117:
118: public void onFileRemoved(FileImpl file) {
119: }
120:
121: public void onFileRemoved(List<NativeFileItem> file) {
122: }
123:
124: public void onFileAdded(NativeFileItem file) {
125: }
126:
127: public void onFileAdded(List<NativeFileItem> file) {
128: }
129:
130: public void onFilePropertyChanged(NativeFileItem nativeFile) {
131: }
132:
133: public void onFilePropertyChanged(List<NativeFileItem> nativeFiles) {
134: }
135:
136: protected void scheduleIncludedFileParsing(FileImpl csmFile,
137: APTPreprocHandler.State state) {
138: // add library file to the tail
139: ParserQueue.instance().addLast(csmFile, state);
140: }
141:
142: public boolean isArtificial() {
143: return true;
144: }
145:
146: @Override
147: public NativeFileItem getNativeFileItem(CsmUID<CsmFile> file) {
148: return null;
149: }
150:
151: @Override
152: protected void putNativeFileItem(CsmUID<CsmFile> file,
153: NativeFileItem nativeFileItem) {
154: }
155:
156: @Override
157: protected void removeNativeFileItem(CsmUID<CsmFile> file) {
158: }
159:
160: @Override
161: protected void clearNativeFileContainer() {
162: }
163:
164: ////////////////////////////////////////////////////////////////////////////
165: // impl of persistent
166:
167: @Override
168: public void write(DataOutput aStream) throws IOException {
169: super .write(aStream);
170: assert this .includePath != null;
171: aStream.writeUTF(this .includePath);
172: }
173:
174: public LibProjectImpl(DataInput aStream) throws IOException {
175: super(aStream);
176: this.includePath = FilePathCache.getString(aStream.readUTF())
177: .toString();
178: assert this.includePath != null;
179: setPlatformProject(this.includePath);
180: }
181: }
|