diff --git a/cnd.makeproject/nbproject/project.xml b/cnd.makeproject/nbproject/project.xml
--- a/cnd.makeproject/nbproject/project.xml
+++ b/cnd.makeproject/nbproject/project.xml
@@ -15,6 +15,15 @@
+ org.netbeans.api.java.classpath
+
+
+
+ 1
+ 1.19
+
+
+
org.netbeans.api.progress
@@ -85,6 +94,14 @@
+ org.netbeans.modules.parsing.api
+
+
+
+ 1.9
+
+
+
org.netbeans.modules.project.ant
diff --git a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java
--- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java
+++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java
@@ -51,12 +51,19 @@
import java.util.Set;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.LinkedList;
import java.util.TreeSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.Icon;
+import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.classpath.GlobalPathRegistry;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.queries.FileEncodingQuery;
import org.netbeans.modules.cnd.api.compilers.CompilerSet;
import org.netbeans.modules.cnd.api.compilers.ToolchainProject;
@@ -75,6 +82,10 @@
import org.netbeans.modules.cnd.makeproject.ui.MakeLogicalViewProvider;
import org.netbeans.modules.cnd.utils.MIMEExtensions;
import org.netbeans.modules.cnd.utils.MIMENames;
+import org.netbeans.spi.java.classpath.ClassPathFactory;
+import org.netbeans.spi.java.classpath.ClassPathImplementation;
+import org.netbeans.spi.java.classpath.PathResourceImplementation;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.SubprojectProvider;
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
@@ -93,12 +104,14 @@
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataLoaderPool;
import org.openide.loaders.DataObject;
import org.openide.util.Lookup;
import org.openide.util.Mutex;
import org.openide.util.NbBundle;
+import org.openide.util.WeakListeners;
import org.openide.util.lookup.Lookups;
import org.openidex.search.SearchInfo;
import org.w3c.dom.Element;
@@ -136,6 +149,9 @@
private Set cppExtensions = MakeProject.createExtensionSet();
private String sourceEncoding = null;
+ private final MakeSources sources;
+ private final MutableCP sourcepath;
+
public MakeProject(AntProjectHelper helper) throws IOException {
this.helper = helper;
eval = createEvaluator();
@@ -143,6 +159,8 @@
refHelper = new ReferenceHelper(helper, aux, eval);
projectDescriptorProvider = new ConfigurationDescriptorProvider(helper.getProjectDirectory());
genFilesHelper = new GeneratedFilesHelper(helper);
+ sources = new MakeSources(this, helper);
+ sourcepath = new MutableCP(sources);
lookup = createLookup(aux);
helper.addAntProjectListener(this);
thisMP = this;
@@ -223,7 +241,7 @@
new ProjectXmlSavedHookImpl(),
new ProjectOpenedHookImpl(),
new MakeSharabilityQuery(FileUtil.toFile(getProjectDirectory())),
- new MakeSources(this, helper),
+ sources,
new AntProjectHelperProvider(),
projectDescriptorProvider,
new MakeProjectConfigurationProvider(this, projectDescriptorProvider),
@@ -766,6 +784,8 @@
openedTasks = null;
}
+ GlobalPathRegistry.getDefault().register(MakeProjectPaths.SOURCES, sourcepath.getClassPath());
+
// /* Don't do this for two reasons: semantically it is wrong (IZ 115314) and it is dangerous (IZ 118575)
// ConfigurationDescriptor projectDescriptor = null;
// int count = 15;
@@ -809,6 +829,8 @@
projectDescriptorProvider.getConfigurationDescriptor().save(NbBundle.getMessage(MakeProject.class, "ProjectNotSaved"));
projectDescriptorProvider.getConfigurationDescriptor().closed();
}
+
+ GlobalPathRegistry.getDefault().unregister(MakeProjectPaths.SOURCES, sourcepath.getClassPath());
}
}
@@ -884,4 +906,72 @@
return null;
}
}
+
+ private final class MutableCP implements ClassPathImplementation, ChangeListener {
+
+ private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ private final MakeSources sources;
+ private List resources = null;
+ private long eventId = 0;
+ private ClassPath [] classpath = null;
+
+ public MutableCP(MakeSources sources) {
+ this.sources = sources;
+ this.sources.addChangeListener(WeakListeners.change(this, this.sources));
+ }
+
+ public List extends PathResourceImplementation> getResources() {
+ final long currentEventId;
+ synchronized (this) {
+ if (resources != null) {
+ return resources;
+ }
+ currentEventId = eventId;
+ }
+
+ List list = new LinkedList();
+ SourceGroup [] groups = sources.getSourceGroups("generic");
+ for(SourceGroup g : groups) {
+ try {
+ list.add(ClassPathSupport.createResource(g.getRootFolder().getURL()));
+ } catch (FileStateInvalidException ex) {
+ Logger.getLogger(MakeProject.class.getName()).log(Level.WARNING, null, ex);
+ }
+ }
+
+ synchronized (this) {
+ if (currentEventId == eventId) {
+ resources = list;
+ return resources;
+ } else {
+ return list;
+ }
+ }
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void stateChanged(ChangeEvent e) {
+ synchronized (this) {
+ resources = null;
+ eventId++;
+ }
+
+ pcs.firePropertyChange(PROP_RESOURCES, null, null);
+ }
+
+ public synchronized ClassPath [] getClassPath() {
+ if (classpath == null) {
+ classpath = new ClassPath [] { ClassPathFactory.createClassPath(this) };
+ }
+ return classpath;
+ }
+ } // End of ClassPathImplementation class
+
}
\ No newline at end of file
diff --git a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProjectPaths.java b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProjectPaths.java
new file mode 100644
--- /dev/null
+++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProjectPaths.java
@@ -0,0 +1,89 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.cnd.makeproject;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author vita
+ */
+@ServiceProvider(service=org.netbeans.modules.parsing.spi.indexing.PathRecognizer.class)
+public class MakeProjectPaths extends PathRecognizer {
+
+ public static final String SOURCES = "org.netbeans.modules.cnd.makeproject/SOURCES"; //NOI18N
+
+ // -----------------------------------------------------------------------
+ // PathRecognizer implementation
+ // -----------------------------------------------------------------------
+
+ @Override
+ public Set getSourcePathIds() {
+ return Collections.singleton(SOURCES);
+ }
+
+ @Override
+ public Set getLibraryPathIds() {
+ return null;
+ }
+
+ @Override
+ public Set getBinaryLibraryPathIds() {
+ return null;
+ }
+
+ @Override
+ public Set getMimeTypes() {
+ return MIME_TYPES;
+ }
+
+ // -----------------------------------------------------------------------
+ // private implementation
+ // -----------------------------------------------------------------------
+
+ private static final Set MIME_TYPES = new HashSet(Arrays.asList(new String[] {
+ "text/c", "text/c++", "text/h"
+ }));
+}