|
From: <caw...@us...> - 2007-03-07 21:40:26
|
Revision: 2105
http://svn.sourceforge.net/rubyeclipse/?rev=2105&view=rev
Author: cawilliams
Date: 2007-03-07 13:40:23 -0800 (Wed, 07 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathEntry.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathAttribute.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathAttribute.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathAttribute.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathAttribute.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathAttribute.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.core;
+
+/**
+ * A classpath attribute defines a name/value pair that can be persisted with a classpath entry. Such an attribute
+ * can be created using the factory method {@link JavaCore#newClasspathAttribute(String, String) newClasspathAttribute(String name, String value)}.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ *
+ * @see JavaCore#newContainerEntry(
+ * org.eclipse.core.runtime.IPath containerPath,
+ * IAccessRule[] accessRules,
+ * IClasspathAttribute[] extraAttributes,
+ * boolean isExported)
+ * @see JavaCore#newLibraryEntry(
+ * org.eclipse.core.runtime.IPath path,
+ * org.eclipse.core.runtime.IPath sourceAttachmentPath,
+ * org.eclipse.core.runtime.IPath sourceAttachmentRootPath,
+ * IAccessRule[] accessRules,
+ * IClasspathAttribute[] extraAttributes,
+ * boolean isExported)
+ * @see JavaCore#newProjectEntry(
+ * org.eclipse.core.runtime.IPath path,
+ * IAccessRule[] accessRules,
+ * boolean combineAccessRestrictions,
+ * IClasspathAttribute[] extraAttributes,
+ * boolean isExported)
+ * @see JavaCore#newSourceEntry(
+ * org.eclipse.core.runtime.IPath path,
+ * org.eclipse.core.runtime.IPath[] inclusionPatterns,
+ * org.eclipse.core.runtime.IPath[] exclusionPatterns,
+ * org.eclipse.core.runtime.IPath specificOutputLocation,
+ * IClasspathAttribute[] extraAttributes)
+ * @see JavaCore#newVariableEntry(
+ * org.eclipse.core.runtime.IPath variablePath,
+ * org.eclipse.core.runtime.IPath variableSourceAttachmentPath,
+ * org.eclipse.core.runtime.IPath variableSourceAttachmentRootPath,
+ * IAccessRule[] accessRules,
+ * IClasspathAttribute[] extraAttributes,
+ * boolean isExported)
+ * @since 3.1
+ */
+public interface ILoadpathAttribute {
+
+ /**
+ * Constant for the name of the optional attribute. The possible values
+ * for this attribute are <code>"true"</code> or <code>"false"</code>.
+ * When not present, <code>"false"</code> is assumed.
+ * If the value of this attribute is <code>"true"</code>, the classpath entry
+ * is optional. If the underlying resource or jar file doesn't exist, no error
+ * is reported and the classpath entry is ignored.
+ *
+ * @since 3.2
+ */
+ String OPTIONAL = "optional"; //$NON-NLS-1$
+
+ /**
+ * Returns the name of this classpath attribute.
+ *
+ * @return the name of this classpath attribute.
+ * @since 3.1
+ */
+ String getName();
+
+ /**
+ * Returns the value of this classpath attribute.
+ *
+ * @return the value of this classpath attribute.
+ * @since 3.1
+ */
+ String getValue();
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathEntry.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathEntry.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathEntry.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -359,4 +359,12 @@
*/
boolean isExported();
+ /**
+ * Returns the extra classpath attributes for this classpath entry. Returns an empty array if this entry
+ * has no extra attributes.
+ *
+ * @return the possibly empty list of extra classpath attributes for this classpath entry
+ * @since 1.0.0
+ */
+ ILoadpathAttribute[] getExtraAttributes();
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -41,6 +41,8 @@
public abstract IProject getProject();
public String[] getRequiredProjectNames() throws RubyModelException;
+
+ public ILoadpathEntry[] readRawLoadpath();
/**
* Returns the first type found following this project's classpath with the
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -5,8 +5,10 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.core.RubyModelStatus;
import org.rubypeople.rdt.internal.core.util.Messages;
@@ -106,4 +108,8 @@
// TODO Actually do some validation
return RubyModelStatus.VERIFIED_OK;
}
+
+ public static IRubyModelStatus validateLoadpath(IRubyProject rubyProject, ILoadpathEntry[] rawCLoadpath, IPath projectOutputLocation) {
+ return LoadpathEntry.validateLoadpath(rubyProject, rawCLoadpath, projectOutputLocation);
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -43,6 +43,7 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.rubypeople.rdt.internal.core.BatchOperation;
+import org.rubypeople.rdt.internal.core.LoadpathAttribute;
import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.core.RubyCorePreferenceInitializer;
import org.rubypeople.rdt.internal.core.RubyModel;
@@ -306,10 +307,15 @@
*/
public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
+ /**
+ * Name of the User Library Container id.
+ * @since 1.0.0
+ */
+ public static final String USER_LIBRARY_CONTAINER_ID= "org.rubypeople.rdt.USER_LIBRARY"; //$NON-NLS-1$
+
+
private static final boolean VERBOSE = false;
-
-
private SymbolIndex symbolIndex;
private ISymbolFinder symbolFinder;
@@ -724,8 +730,7 @@
* @see #newSourceEntry(IPath, IPath[], IPath[])
*/
public static ILoadpathEntry newSourceEntry(IPath path) {
-
- return newSourceEntry(path, LoadpathEntry.INCLUDE_ALL, LoadpathEntry.EXCLUDE_NONE);
+ return newSourceEntry(path, LoadpathEntry.INCLUDE_ALL, LoadpathEntry.EXCLUDE_NONE, LoadpathEntry.NO_EXTRA_ATTRIBUTES);
}
/**
@@ -749,7 +754,7 @@
* @return a new source classpath entry
* @since 3.0
*/
- public static ILoadpathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns) {
+ public static ILoadpathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, ILoadpathAttribute[] extraAttributes) {
if (path == null) Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
if (!path.isAbsolute()) Assert.isTrue(false, "Path for ILoadpathEntry must be absolute"); //$NON-NLS-1$
if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
@@ -760,10 +765,11 @@
path,
inclusionPatterns,
exclusionPatterns,
+ extraAttributes,
false);
}
- public static ILoadpathEntry newLibraryEntry(IPath path, boolean isExported) {
+ public static ILoadpathEntry newLibraryEntry(IPath path, ILoadpathAttribute[] extraAttributes, boolean isExported) {
if (path == null) Assert.isTrue(false, "Library path cannot be null"); //$NON-NLS-1$
if (!path.isAbsolute()) Assert.isTrue(false, "Path for ILoadpathEntry must be absolute"); //$NON-NLS-1$
@@ -773,11 +779,12 @@
RubyProject.canonicalizedPath(path),
LoadpathEntry.INCLUDE_ALL, // inclusion patterns
LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ extraAttributes,
isExported);
}
- public static ILoadpathEntry newProjectEntry(IPath path, boolean isExported) {
+ public static ILoadpathEntry newProjectEntry(IPath path, ILoadpathAttribute[] extraAttributes, boolean isExported) {
if (!path.isAbsolute()) Assert.isTrue(false, "Path for ILoadpathEntry must be absolute"); //$NON-NLS-1$
return new LoadpathEntry(
@@ -785,10 +792,11 @@
path,
LoadpathEntry.INCLUDE_ALL, // inclusion patterns
LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ extraAttributes,
isExported);
}
- public static ILoadpathEntry newVariableEntry(IPath variablePath, boolean isExported) {
+ public static ILoadpathEntry newVariableEntry(IPath variablePath, ILoadpathAttribute[] extraAttributes, boolean isExported) {
if (variablePath == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
if (variablePath.segmentCount() < 1) {
Assert.isTrue(
@@ -801,10 +809,11 @@
variablePath,
LoadpathEntry.INCLUDE_ALL, // inclusion patterns
LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ extraAttributes,
isExported);
}
- public static ILoadpathEntry newContainerEntry(IPath containerPath,
+ public static ILoadpathEntry newContainerEntry(IPath containerPath, ILoadpathAttribute[] extraAttributes,
boolean isExported) {
if (containerPath == null) {
Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
@@ -818,6 +827,7 @@
containerPath,
LoadpathEntry.INCLUDE_ALL, // inclusion patterns
LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ extraAttributes,
isExported);
}
@@ -845,11 +855,13 @@
// internal project
return RubyCore.newProjectEntry(
resolvedPath,
+ entry.getExtraAttributes(),
entry.isExported());
case IResource.FOLDER :
// internal binary folder
return RubyCore.newLibraryEntry(
resolvedPath,
+ entry.getExtraAttributes(),
entry.isExported());
}
}
@@ -858,10 +870,10 @@
if (target instanceof File) {
File externalFile = RubyModel.getFolder(target);
if (externalFile != null) {
- return RubyCore.newLibraryEntry(resolvedPath, entry.isExported());
+ return RubyCore.newLibraryEntry(resolvedPath, entry.getExtraAttributes(), entry.isExported());
} else { // external binary folder
if (resolvedPath.isAbsolute()){
- return RubyCore.newLibraryEntry(resolvedPath, entry.isExported());
+ return RubyCore.newLibraryEntry(resolvedPath, entry.getExtraAttributes(), entry.isExported());
}
}
}
@@ -1317,19 +1329,45 @@
}
public static ILoadpathEntry newProjectEntry(IPath fullPath) {
- return newProjectEntry(fullPath, false);
+ return newProjectEntry(fullPath, LoadpathEntry.NO_EXTRA_ATTRIBUTES, false);
}
public static ILoadpathEntry newVariableEntry(IPath path) {
- return newVariableEntry(path, false);
+ return newVariableEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, false);
}
public static ILoadpathEntry newContainerEntry(IPath path) {
- return newContainerEntry(path, false);
+ return newContainerEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, false);
}
public static ILoadpathEntry newLibraryEntry(IPath p) {
- return newLibraryEntry(p, false);
+ return newLibraryEntry(p, LoadpathEntry.NO_EXTRA_ATTRIBUTES, false);
}
+ /**
+ * Creates and returns a new loadpath attribute with the given name and the given value.
+ *
+ * @return a new loadpath attribute
+ * @since 0.9.0
+ */
+ public static ILoadpathAttribute newLoadpathAttribute(String name, String value) {
+ return new LoadpathAttribute(name, value);
+ }
+
+ public static ILoadpathEntry newLibraryEntry(IPath path, boolean isExported) {
+ return newLibraryEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, isExported);
+ }
+
+ public static ILoadpathEntry newVariableEntry(IPath path, boolean isExported) {
+ return newVariableEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, isExported);
+ }
+
+ public static ILoadpathEntry newProjectEntry(IPath path, boolean isExported) {
+ return newProjectEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, isExported);
+ }
+
+ public static ILoadpathEntry newContainerEntry(IPath path, boolean isExported) {
+ return newContainerEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, isExported);
+ }
+
}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathAttribute.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathAttribute.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathAttribute.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -0,0 +1,38 @@
+package org.rubypeople.rdt.internal.core;
+
+import org.rubypeople.rdt.core.ILoadpathAttribute;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+public class LoadpathAttribute implements ILoadpathAttribute {
+
+ private String name;
+ private String value;
+
+ public LoadpathAttribute(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof LoadpathAttribute)) return false;
+ LoadpathAttribute other = (LoadpathAttribute) obj;
+ return this.name.equals(other.name) && this.value.equals(other.value);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public int hashCode() {
+ return Util.combineHashCodes(this.name.hashCode(), this.value.hashCode());
+ }
+
+ public String toString() {
+ return this.name + "=" + this.value; //$NON-NLS-1$
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -11,6 +11,7 @@
import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.core.ILoadpathAttribute;
import org.rubypeople.rdt.core.ILoadpathEntry;
import org.rubypeople.rdt.core.IRubyModelStatus;
import org.rubypeople.rdt.core.IRubyProject;
@@ -33,6 +34,10 @@
public static final String TAG_EXPORTED = "exported"; //$NON-NLS-1$
public static final String TAG_INCLUDING = "including"; //$NON-NLS-1$
public static final String TAG_EXCLUDING = "excluding"; //$NON-NLS-1$
+ public static final String TAG_ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ public static final String TAG_ATTRIBUTE = "attribute"; //$NON-NLS-1$
+ public static final String TAG_ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
+ public static final String TAG_ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
static class UnknownXmlElements {
String[] attributes;
@@ -55,6 +60,10 @@
private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray()}; //$NON-NLS-1$
/*
+ * Default extra attributes
+ */
+ public final static ILoadpathAttribute[] NO_EXTRA_ATTRIBUTES = {};
+ /*
* Default inclusion pattern set
*/
public final static IPath[] INCLUDE_ALL = {};
@@ -70,18 +79,23 @@
* The export flag
*/
private boolean isExported;
+
+ /*
+ * The extra attributes
+ */
+ ILoadpathAttribute[] extraAttributes;
public LoadpathEntry(IProject project) {
- this(ILoadpathEntry.CPE_PROJECT, project.getFullPath(), INCLUDE_ALL, EXCLUDE_NONE, true);
+ this(ILoadpathEntry.CPE_PROJECT, project.getFullPath(), INCLUDE_ALL, EXCLUDE_NONE, NO_EXTRA_ATTRIBUTES, true);
this.project = project;
}
- public LoadpathEntry(int entryKind, IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, boolean isExported) {
+ public LoadpathEntry(int entryKind, IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, ILoadpathAttribute[] extraAttributes, boolean isExported) {
this.path = path;
this.entryKind = entryKind;
this.inclusionPatterns = inclusionPatterns;
this.exclusionPatterns = exclusionPatterns;
-
+ this.extraAttributes = extraAttributes;
if (inclusionPatterns != INCLUDE_ALL && inclusionPatterns.length > 0) {
this.fullInclusionPatternChars = UNINIT_PATTERNS;
}
@@ -223,6 +237,7 @@
getPath(),
this.inclusionPatterns,
this.exclusionPatterns,
+ this.extraAttributes,
referringEntry.isExported() || this.isExported); // duplicate container entry for tagging it as exported
}
// no need to clone
@@ -256,6 +271,10 @@
IPath[] exclusionPatterns = decodePatterns(attributes, TAG_EXCLUDING);
if (exclusionPatterns == null) exclusionPatterns = EXCLUDE_NONE;
+// extra attributes (optional)
+ NodeList attributeList = getChildAttributes(TAG_ATTRIBUTES, children, foundChildren);
+ ILoadpathAttribute[] extraAttributes = decodeExtraAttributes(attributeList);
+
String[] unknownAttributes = null;
ArrayList unknownChildren = null;
@@ -295,38 +314,43 @@
path,
LoadpathEntry.INCLUDE_ALL, // inclusion patterns
LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ extraAttributes,
isExported);
break;
case ILoadpathEntry.CPE_LIBRARY :
entry = RubyCore.newLibraryEntry(
path,
+ extraAttributes,
isExported);
break;
case ILoadpathEntry.CPE_SOURCE :
// must be an entry in this project or specify another project
String projSegment = path.segment(0);
if (projSegment != null && projSegment.equals(project.getElementName())) { // this project
- entry = RubyCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns);
+ entry = RubyCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, extraAttributes);
} else {
if (path.segmentCount() == 1) {
// another project
entry = RubyCore.newProjectEntry(
path,
+ extraAttributes,
isExported);
} else {
// an invalid source folder
- entry = RubyCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns);
+ entry = RubyCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, extraAttributes);
}
}
break;
case ILoadpathEntry.CPE_VARIABLE :
entry = RubyCore.newVariableEntry(
path,
+ extraAttributes,
isExported);
break;
case ILoadpathEntry.CPE_CONTAINER :
entry = RubyCore.newContainerEntry(
path,
+ extraAttributes,
isExported);
break;
default :
@@ -343,6 +367,39 @@
return entry;
}
+ public static NodeList getChildAttributes(String childName, NodeList children, boolean[] foundChildren) {
+ for (int i = 0, length = foundChildren.length; i < length; i++) {
+ Node node = children.item(i);
+ if (childName.equals(node.getNodeName())) {
+ foundChildren[i] = true;
+ return node.getChildNodes();
+ }
+ }
+ return null;
+ }
+
+ static ILoadpathAttribute[] decodeExtraAttributes(NodeList attributes) {
+ if (attributes == null) return NO_EXTRA_ATTRIBUTES;
+ int length = attributes.getLength();
+ if (length == 0) return NO_EXTRA_ATTRIBUTES;
+ ILoadpathAttribute[] result = new ILoadpathAttribute[length];
+ int index = 0;
+ for (int i = 0; i < length; ++i) {
+ Node node = attributes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element attribute = (Element)node;
+ String name = attribute.getAttribute(TAG_ATTRIBUTE_NAME);
+ if (name == null) continue;
+ String value = attribute.getAttribute(TAG_ATTRIBUTE_VALUE);
+ if (value == null) continue;
+ result[index++] = new LoadpathAttribute(name, value);
+ }
+ }
+ if (index != length)
+ System.arraycopy(result, 0, result = new ILoadpathAttribute[index], 0, index);
+ return result;
+ }
+
private static void decodeUnknownNode(Node node, StringBuffer buffer, IRubyProject project) {
ByteArrayOutputStream s = new ByteArrayOutputStream();
OutputStreamWriter writer;
@@ -451,17 +508,21 @@
}
public boolean isOptional() {
- // TODO Actually take in extra attributes that specifies whether this could be optional
+ for (int i = 0, length = this.extraAttributes.length; i < length; i++) {
+ ILoadpathAttribute attribute = this.extraAttributes[i];
+ if (ILoadpathAttribute.OPTIONAL.equals(attribute.getName()) && "true".equals(attribute.getValue())) //$NON-NLS-1$
+ return true;
+ }
return false;
}
- public static IRubyModelStatus validateLoadpathEntry(RubyProject project2,
+ public static IRubyModelStatus validateLoadpathEntry(IRubyProject project,
ILoadpathEntry rawEntry, boolean b, boolean c) {
// TODO Actually do some checking of the entry
return RubyModelStatus.VERIFIED_OK;
}
- public static IRubyModelStatus validateLoadpath(RubyProject project2,
+ public static IRubyModelStatus validateLoadpath(IRubyProject project,
ILoadpathEntry[] resolvedPath, IPath projectOutputLocation) {
// FIXME Remove outputLocation
// TODO Actually do some checking of the loadpath
@@ -508,7 +569,7 @@
parameters.put(tagName, tagValue);
}
- boolean hasExtraAttributes = false;
+ boolean hasExtraAttributes = this.extraAttributes.length != 0;
ArrayList unknownChildren = unknownXmlElements != null ? unknownXmlElements.children : null;
boolean hasUnknownChildren = unknownChildren != null;
writer.printTag(
@@ -517,14 +578,28 @@
indent,
newLine,
!hasUnknownChildren/*close tag if no unknown children*/);
-
+ if (hasExtraAttributes)
+ encodeExtraAttributes(writer, indent, newLine);
if (hasUnknownChildren) {
encodeUnknownChildren(writer, indent, newLine, unknownChildren);
+ if (hasExtraAttributes || hasUnknownChildren)
writer.endTag(TAG_LOADPATHENTRY, indent, true/*insert new line*/);
}
}
+ void encodeExtraAttributes(XMLWriter writer, boolean indent, boolean newLine) {
+ writer.startTag(TAG_ATTRIBUTES, indent);
+ for (int i = 0; i < this.extraAttributes.length; i++) {
+ ILoadpathAttribute attribute = this.extraAttributes[i];
+ HashMap parameters = new HashMap();
+ parameters.put(TAG_ATTRIBUTE_NAME, attribute.getName());
+ parameters.put(TAG_ATTRIBUTE_VALUE, attribute.getValue());
+ writer.printTag(TAG_ATTRIBUTE, parameters, indent, newLine, true);
+ }
+ writer.endTag(TAG_ATTRIBUTES, indent, true/*insert new line*/);
+ }
+
/**
* Encode some patterns into XML parameter tag
*/
@@ -545,4 +620,8 @@
writer.printString(child, indent, false/*don't insert new line*/);
}
}
+
+ public ILoadpathAttribute[] getExtraAttributes() {
+ return extraAttributes;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -62,6 +62,7 @@
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException;
+import org.rubypeople.rdt.core.ILoadpathAttribute;
import org.rubypeople.rdt.core.ILoadpathContainer;
import org.rubypeople.rdt.core.ILoadpathEntry;
import org.rubypeople.rdt.core.IParent;
@@ -2255,9 +2256,10 @@
IPath[] inclusionPatterns = loadPaths();
IPath[] exclusionPatterns = loadPaths();
boolean isExported = loadBoolean();
+ ILoadpathAttribute[] extraAttributes = loadAttributes();
ILoadpathEntry entry = new LoadpathEntry(entryKind,
- path, inclusionPatterns, exclusionPatterns, isExported);
+ path, inclusionPatterns, exclusionPatterns, extraAttributes, isExported);
ILoadpathEntry[] array = this.allLoadpathEntries;
@@ -2275,7 +2277,28 @@
return entry;
}
+
+ private ILoadpathAttribute[] loadAttributes() throws IOException {
+ int count = loadInt();
+ if (count == 0)
+ return LoadpathEntry.NO_EXTRA_ATTRIBUTES;
+
+ ILoadpathAttribute[] attributes = new ILoadpathAttribute[count];
+
+ for (int i = 0; i < count; ++i)
+ attributes[i] = loadAttribute();
+
+ return attributes;
+ }
+
+ private ILoadpathAttribute loadAttribute() throws IOException {
+ String name = loadString();
+ String value = loadString();
+
+ return new LoadpathAttribute(name, value);
+ }
+
private void loadContainers(IRubyProject project) throws IOException {
boolean projectIsAccessible = project.getProject().isAccessible();
int count = loadInt();
@@ -2475,9 +2498,23 @@
savePaths(entry.getInclusionPatterns());
savePaths(entry.getExclusionPatterns());
this.out.writeBoolean(entry.isExported());
+ saveAttributes(entry.getExtraAttributes());
}
}
+
+ private void saveAttribute(ILoadpathAttribute attribute) throws IOException {
+ saveString(attribute.getName());
+ saveString(attribute.getValue());
+ }
+ private void saveAttributes(ILoadpathAttribute[] attributes) throws IOException {
+ int count = attributes == null ? 0 : attributes.length;
+
+ saveInt(count);
+ for (int i = 0; i < count; ++i)
+ saveAttribute(attributes[i]);
+ }
+
private void saveContainers(IRubyProject project, Map containerMap)
throws IOException {
saveInt(containerMap.size());
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -947,6 +947,14 @@
return new ILoadpathEntry[] { RubyCore.newSourceEntry(this.project.getFullPath()) };
}
+
+ /**
+ * @see IRubyProject
+ */
+ public ILoadpathEntry[] readRawLoadpath() {
+ // Read loadpath file without creating markers nor logging problems
+ return this.readLoadpathFile(false, false);
+ }
/**
* Reads the .classpath file from disk and returns the list of entries it
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java 2007-03-07 21:40:13 UTC (rev 2104)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java 2007-03-07 21:40:23 UTC (rev 2105)
@@ -201,4 +201,12 @@
public static String bind(String message, Object[] bindings) {
return MessageFormat.format(message, bindings);
}
+
+ public static String format(String message, String[] bindings) {
+ return bind(message, bindings);
+ }
+
+ public static String format(String message, String binding) {
+ return bind(message, binding);
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|