Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jem.workbench/workbench/org/eclipse')
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMAdaptor.java351
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMClassFinder.java94
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMSearchHelper.java370
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaClassJDOMAdaptor.java703
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaFieldJDOMAdaptor.java291
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaJDOMAdapterFactory.java233
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaMethodJDOMAdaptor.java364
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaModelListener.java44
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaReflectionSynchronizer.java323
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/IJavaProjectInfo.java20
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaEMFNature.java180
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaPlugin.java66
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaProjectInfo.java50
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ASTBoundResolver.java117
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/IJavaEMFNature.java26
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JavaModelListener.java384
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JemProjectUtilities.java746
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/NoASTResolver.java51
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ParseTreeCreationFromAST.java570
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/WorkbenchUtilityMessages.java32
-rw-r--r--plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/messages.properties15
21 files changed, 0 insertions, 5030 deletions
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMAdaptor.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMAdaptor.java
deleted file mode 100644
index 372b8399a..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMAdaptor.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JDOMAdaptor.java,v $
- * $Revision: 1.8 $ $Date: 2005/10/18 14:58:18 $
- */
-
-import java.io.File;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jem.java.*;
-import org.eclipse.jem.internal.java.adapters.JavaReflectionAdaptor;
-import org.eclipse.jem.internal.java.adapters.nls.ResourceHandler;
-import org.eclipse.jem.java.internal.impl.JavaRefFactoryImpl;
-/**
- * Insert the type's description here.
- * Creation date: (6/6/2000 4:42:50 PM)
- * @author: Administrator
- */
-public abstract class JDOMAdaptor extends JavaReflectionAdaptor {
-
- protected final static JavaRefPackage JAVA_PACK = JavaRefFactoryImpl.getPackage();
- protected IJavaProject sourceProject;
- final public static int INVALID_LINENO = -1;
- final protected Integer fLINENOLock = new Integer(INVALID_LINENO);
- // This object is not static, as it is used as synchronization element.
- private int fResolvedLineNo = INVALID_LINENO; // Line offset in source file
- private int fResolvedColNo = INVALID_LINENO; // Column offset in source file
- public JDOMAdaptor(Notifier target, IJavaProject workingProject) {
- super(target);
- setSourceProject(workingProject);
- }
- protected void clearSource() {
- // To be overidden if needed.
- }
-
- /**
- * Called by subclasses in canReflect(). If the target is not in a resource, or the
- * resource is not loaded, then it can't reflect. Mustn't reflect if the target
- * has been unloaded.
- *
- * @return
- */
- protected boolean isResourceLoaded() {
- Resource res = ((EObject) getTarget()).eResource();
- return res != null && res.isLoaded();
- }
-
- /**
- * Scan for CRs and LFs within a character buffer
- * Creation date: (8/17/2001 2:14:13 PM)
- * @return int LineNo at charOffset
- * @param charOffset int
- * @param buffer org.eclipse.jdt.core.IBuffer
- */
- private void computeLineOffset(int charOffset, IBuffer buffer) {
-
- fResolvedColNo = fResolvedLineNo = INVALID_LINENO;
-
- if (buffer == null)
- return;
-
- char[] charBuff = buffer.getCharacters();
-
- if (charBuff == null)
- return;
-
- int LineCount = 0;
- int ColNo = 0;
- for (int i = 0; i <= charOffset; i++) {
- ColNo++;
- if (charBuff[i] == '\r') {
- LineCount++;
- ColNo = 0;
- if (charBuff[i + 1] == '\n')
- i++; // skip LineFeed followed a CR
- } else if (charBuff[i] == '\n') {
- LineCount++;
- ColNo = 0;
- }
-
- }
- fResolvedColNo = ColNo;
- fResolvedLineNo = LineCount;
- }
- /**
- * computeMethodID - generate the unique ID to be used to identify a method.
- * Similar to a Signature, but hopefully more readable.
- * The name format will be:
- * simpleTypeName.methodName(my.package.Parm_Type1,parmType2
- * Note: This implementation is tightly coupled with ReflectionAdapter.getTypeNamesFromMethodID().
- */
- public static String computeMethodID(IMethod jdomMethod) {
- return computeMethodID(jdomMethod, jdomMethod.getDeclaringType(), null);
- }
- /**
- * computeMethodID - generate the unique ID to be used to identify a method.
- * Similar to a Signature, but hopefully more readable.
- * The name format will be:
- * simpleTypeName.methodName(my.package.Parm_Type1,parmType2
- * Note: This implementation is tightly coupled with ReflectionAdapter.getTypeNamesFromMethodID().
- */
- public static String computeMethodID(IMethod jdomMethod, IType type, Map typeCache) {
- StringBuffer out = new StringBuffer();
- out.append(type.getTypeQualifiedName());
- out.append(C_CLASS_MEMBER_DELIMITER);
- out.append(jdomMethod.getElementName());
- out.append(C_METHOD_PARM_DELIMITER);
- String[] parmTypeNames = jdomMethod.getParameterTypes();
- String parmName;
- for (int i = 0; i < parmTypeNames.length; i++) {
- parmName = convertJDOMtypeName(parmTypeNames[i]);
- parmName = JDOMSearchHelper.getResolvedTypeName(parmName, type, typeCache);
- out.append(parmName);
- if (i < (parmTypeNames.length - 1))
- out.append(C_PARM_PARM_DELIMITER);
- }
- try {
- if (jdomMethod.isConstructor())
- out.append(S_CONSTRUCTOR_TOKEN);
- } catch (JavaModelException e) {
- }
- return out.toString();
- }
- /**
- * computeMethodName - generate the name to be used to identify a method.
- * For the moment, names are simple, and UUID's are complex.
- */
- public static String computeMethodName(IMethod jdomMethod) {
- return jdomMethod.getElementName();
- }
- /**
- * Java content has changed, but no structural changes that require
- * to reflectValues(); e.g., the body of a method has changed.
- * Creation date: (8/17/2001 10:47:58 AM)
- */
- public void contentChanged() {
- synchronized (fLINENOLock) {
- fResolvedLineNo = INVALID_LINENO;
- fResolvedColNo = INVALID_LINENO;
- }
- }
- /**
- * computeMethodID - generate the unique ID to be used to identify a method.
- * Similar to a Signature, but hopefully more readable.
- * The name format will be:
- * methodName_parmType1_parmType2
- */
- public static String convertJDOMtypeName(String jdomTypeName) {
- return signatureToString(jdomTypeName);
- }
- /**
- * createJavaField - instantiate a Java Field based on the passed Java Model IField
- * We are deferring field contents assuming that its adaptor will reflect its details.
- */
- public Field createJavaField(IField jdomField, XMIResource resource) {
- String name = jdomField.getElementName();
- Field newField = getJavaFactory().createField();
- newField.setName(name);
- resource.setID(newField, ((JavaClass) getTarget()).getName() + C_CLASS_MEMBER_DELIMITER + name);
- return newField;
- }
- /**
- * createJavaMethod - instantiate a Java Method based on the passed Java Model IMethod
- * We are deferring method contents assuming that its adaptor will reflect its details.
- * We need to store enough info in the empty Method to find its Java source.
- * The UUID will eventually hold enough info to identify the source, so we use it.
- */
- public Method createJavaMethod(IMethod jdomMethod, XMIResource resource) {
- Method newMethod = getJavaFactory().createMethod();
- // We use a simple name, but a complex ID
- newMethod.setName(computeMethodName(jdomMethod));
- resource.setID(newMethod, computeMethodID(jdomMethod, getType(), getTypeResolutionCache()));
- return newMethod;
- }
- protected IPath getBinaryPathFromQualifiedName(String qualifiedName) {
- return new Path(qualifiedName.replace('.', File.separatorChar) + ".class"); //$NON-NLS-1$
- }
- public IType getBinaryType(String qualifiedName) {
- try {
- if (getSourceProject() != null) {
- IJavaElement found = getSourceProject().findElement(getBinaryPathFromQualifiedName(qualifiedName));
- if (found != null)
- return ((IClassFile) found).getType();
- }
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] { qualifiedName, jme.getMessage()}))); //$NON-NLS-1$ = "Error looking up type: "
- }
- return null;
- }
- /**
- * Compute a column number from the ISourceRange offset
- * Cache the line number thereafter. Source change will
- * Invoke the contentChanged() method.
- * Creation date: (8/17/2001 11:16:51 AM)
- * @return int
- */
- public int getColNo() {
-
- synchronized (fLINENOLock) {
- if (fResolvedColNo == INVALID_LINENO)
- resolveLineColNo();
- }
- return fResolvedColNo;
- }
- /**
- * Compute a line number from the ISourceRange offset
- * Cache the line number thereafter. Source change will
- * Invoke the contentChanged() method.
- * Creation date: (8/17/2001 11:16:51 AM)
- * @return int
- */
- public int getLineNo() {
-
- synchronized (fLINENOLock) {
- if (fResolvedLineNo == INVALID_LINENO)
- resolveLineColNo();
- }
- return fResolvedLineNo;
- }
- /**
- * Insert the method's description here.
- * Creation date: (8/17/2001 1:18:29 PM)
- */
- public abstract Object getReflectionSource();
- /*
- * Resolve a type name in the context of a Type.
- * (Borrowed from org.eclipse.jdt.ui.codemanipulation.StubUtility.getResolvedTypeName())
- * The input is a simple or qualified name, NOT a signature
- * The output will be a qualified name, NOT a signature
- */
- public static String getResolvedTypeName(String typeName, IType declaringType) {
- String name = typeName;
- try {
- name = JDOMSearchHelper.resolveSimpleTypeName(declaringType, typeName);
- } catch (JavaModelException e) {
- // ignore
- }
- return name;
- }
-
- protected IJavaProject getSourceProject() {
- return sourceProject;
- }
- protected abstract IType getType();
- protected abstract Map getTypeResolutionCache();
-
- public void releaseSourceType() {
- flushReflectedValuesIfNecessary(true); // induce clients to get Notified.
- }
-
- public Notification releaseSourceTypeNoNotification() {
- return flushReflectedValuesIfNecessaryNoNotification(true); // induce clients to get Notified.
- }
- /**
- * Insert the method's description here.
- * Creation date: (8/21/2001 8:09:34 AM)
- */
- private void resolveLineColNo() {
-
- IMember rs = (IMember) getReflectionSource();
- if (rs != null) {
- int offset = INVALID_LINENO;
- try {
- ISourceRange sr = rs.getNameRange();
- if (sr.getLength() <= 0)
- return;
- offset = sr.getOffset();
- } catch (JavaModelException je) {
- return;
- }
- ICompilationUnit cu = rs.getCompilationUnit();
- if (cu != null) {
- try {
- IBuffer buffer = cu.getBuffer();
- computeLineOffset(offset, buffer);
- } catch (JavaModelException je) {
- }
- }
- }
- }
- protected void setSourceProject(IJavaProject workingProject) {
- sourceProject = workingProject;
- }
- /**
- * Converts a type signature to a readable string.
- *
- * Uses Signature.toString(), then tries to undo bad replacement for inner classes.
- *
- */
- public static String signatureToString(String signature) throws IllegalArgumentException {
- boolean hasDollar = (signature.indexOf(Signature.C_DOLLAR) != -1);
- String result = Signature.toString(signature);
- if (hasDollar) {
- int newPos = result.lastIndexOf("."); //$NON-NLS-1$
- if (newPos != -1) {
- result = result.substring(0, newPos) + "$" + result.substring(newPos + 1); //$NON-NLS-1$
- }
- }
- return result;
- }
- /**
- * setType - set our type here
- */
- protected String typeNameFromSignature(String sig) {
- return typeNameFromSignature(sig, getType());
- }
- /**
- * setType - set our type here
- */
- protected String typeNameFromSignature(String sig, IType parent) {
- return typeNameFromSignature(sig, parent, getTypeResolutionCache());
- }
- /**
- * setType - set our type here
- */
- public static String typeNameFromSignature(String sig, IType parent, Map typeCache) {
- String result;
- String componentSignature = Signature.getElementType(sig);
- int arrayDimensions = Signature.getArrayCount(sig);
- result = JDOMSearchHelper.getResolvedTypeName(signatureToString(componentSignature), parent, typeCache);
- for (int i = 0; i < arrayDimensions; i++) {
- result = result + "[]"; //$NON-NLS-1$
- }
- return result;
- }
- /**
- * @deprecated
- * @see org.eclipse.jem.internal.adapters.jdom.JDOMSearchHelper#findType(String, boolean, IJavaProject, JDOMAdaptor)
- */
- public IType getType(String qualifiedName) {
- return JDOMSearchHelper.findType(qualifiedName, false, getSourceProject(), this);
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMClassFinder.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMClassFinder.java
deleted file mode 100644
index 012f6995a..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMClassFinder.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JDOMClassFinder.java,v $
- * $Revision: 1.3 $ $Date: 2005/08/24 21:13:53 $
- */
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jem.internal.java.adapters.nls.ResourceHandler;
-/**
- * Insert the type's description here.
- * Creation date: (8/16/2000 11:06:46 PM)
- * @author: Administrator
- */
-public class JDOMClassFinder {
-
- private static JDOMClassFinder instance;
-/**
- * JDOMClassFinder constructor comment.
- */
-public JDOMClassFinder() {
- super();
-}
-protected IPath getBinaryPathFromQualifiedName(String qualifiedName) {
- return new Path(qualifiedName.replace('.', File.separatorChar) + ".class");//$NON-NLS-1$
-}
-public IType getBinaryType(String qualifiedName) {
- try {
- IJavaElement found = getJavaElement(qualifiedName);
- return ((IClassFile) found).getType();
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] {qualifiedName, jme.getMessage()}))); //$NON-NLS-1$ = "Error looking up type: "
- }
- return null;
-}
-public IJavaElement getJavaElement(String qualifiedName) {
- try {
- if (getSourceProject() != null)
- return getSourceProject().findElement(getPathFromQualifiedName(qualifiedName));
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] {qualifiedName, jme.getMessage()}))); //$NON-NLS-1$ = "Error looking up type: "
- }
- return null;
-}
-protected IPath getPathFromQualifiedName(String qualifiedName) {
- return new Path(qualifiedName.replace('.', File.separatorChar) + ".java");//$NON-NLS-1$
-}
-protected IJavaProject getSourceProject() {
- //return (IJavaProject) ((JavaRefPackage)EPackage.Registry.INSTANCE.getEPackage(JavaRefPackage.eNS_URI)).getJavaRefFactory().getJavaContext();
- return null;
-}
-public IType getType(String qualifiedName) {
- try {
- IJavaElement found = getJavaElement(qualifiedName);
- if (found != null)
- if (found instanceof IClassFile)
- return ((IClassFile) found).getType();
- else
- if (found instanceof ICompilationUnit) {
- ICompilationUnit foundCU = (ICompilationUnit) found;
- // strip the ".java", lifted from CompilationUnit.getMainTypeName()
- String cuMainTypeName = foundCU.getElementName();
- cuMainTypeName = cuMainTypeName.substring(0, cuMainTypeName.length() - 5);
- return foundCU.getType(cuMainTypeName);
- }
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] {qualifiedName, jme.getMessage()}))); //$NON-NLS-1$ = "Error looking up type: "
- }
- return null;
-}
-/**
- * Insert the method's description here.
- * Creation date: (8/16/2000 11:19:48 PM)
- * @return com.ibm.etools.java.adapters.JDOMClassFinder
- */
-public static JDOMClassFinder instance() {
- if (instance == null)
- instance = new JDOMClassFinder();
- return instance;
-}
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMSearchHelper.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMSearchHelper.java
deleted file mode 100644
index 2f2f36257..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JDOMSearchHelper.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JDOMSearchHelper.java,v $
- * $Revision: 1.7 $ $Date: 2006/02/24 00:19:15 $
- */
-
-import java.io.File;
-import java.util.*;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.*;
-
-import org.eclipse.jem.internal.java.adapters.nls.ResourceHandler;
-/**
- * Insert the type's description here.
- * Creation date: (9/26/2001 11:09:30 AM)
- * @author: Administrator
- */
-public class JDOMSearchHelper {
-
- private static final String RESOLVED_NAME = " :: RESOLVED_NAME :: "; //$NON-NLS-1$
- private static final String PERIOD = "."; //$NON-NLS-1$
- private static final String BOOLEAN = "boolean"; //$NON-NLS-1$
- private static final String BYTE = "byte"; //$NON-NLS-1$
- private static final String CHAR = "char"; //$NON-NLS-1$
- private static final String SHORT = "short"; //$NON-NLS-1$
- private static final String INT = "int"; //$NON-NLS-1$
- private static final String LONG = "long"; //$NON-NLS-1$
- private static final String FLOAT = "float"; //$NON-NLS-1$
- private static final String DOUBLE = "double"; //$NON-NLS-1$
- private static final String VOID = "void"; //$NON-NLS-1$
- /**
- * JDOMSearchHelper constructor comment.
- */
- public JDOMSearchHelper() {
- super();
- }
- /**
- * If the @simpleName is an inner class, we need to resolve only the declaring class.
- */
- private static String[][] getTypeNameInfo(IType type, String simpleName, boolean isForReflection) throws JavaModelException {
- String[][] result = null;
- String declaringName, typeName;
- typeName = simpleName;
- if (type != null) {
- if (isForReflection)
- typeName = typeName.replace('.', '$');
- int index = typeName.indexOf("$"); //$NON-NLS-1$
- if (index > 0) {
- declaringName = typeName.substring(0, index);
- result = type.resolveType(declaringName);
- if (result != null) {
- if (isForReflection)
- result[0][1] = result[0][1].replace('.', '$');
- result[0][1] += typeName.substring(index, typeName.length());
- }
- } else {
- index = typeName.indexOf("["); //$NON-NLS-1$
- if (index > 0) {
- declaringName = typeName.substring(0, index);
- result = type.resolveType(declaringName);
- if (result != null)
- result[0][1] = result[0][1] + typeName.substring(index);
- } else
- result = type.resolveType(typeName);
- }
- }
- return result;
- }
- /**
- * Returns true if the type is a primitive.
- */
- public final static boolean isPrimitive(String type) {
- return (BOOLEAN.equals(type) || INT.equals(type) || CHAR.equals(type) || SHORT.equals(type) || LONG.equals(type) || FLOAT.equals(type) || DOUBLE.equals(type) || BYTE.equals(type));
- }
- /**
- * Returns true if the type is a primitive.
- */
- public final static boolean isPrimitiveOrVoid(String type) {
- return isPrimitive(type) || isVoid(type);
- }
- /**
- * Returns true if the type is a primitive.
- */
- public final static boolean isVoid(String type) {
- return VOID.equals(type);
- }
- /**
- * Returns true if the two signatures match within the scope of the specified type.
- */
- public static boolean matchTypeSignatures(IType type, String signature1, String signature2) throws JavaModelException {
- return matchTypeSignatures(type, signature1, signature2, null);
- }
- /**
- * Returns true if the two signatures match within the scope of the specified type.
- */
- public static boolean matchTypeSignatures(IType type, String signature1, String signature2, Map resolvedNameCache) throws JavaModelException {
- boolean result = false;
- String sig1 = signature1;
- String sig2 = signature2;
- // First check array count.
- if (Signature.getArrayCount(sig1) == Signature.getArrayCount(sig2)) {
- // We have the same array count, get the element types for consideration.
- sig1 = Signature.getElementType(sig1);
- sig2 = Signature.getElementType(sig2);
-
- // There are three cases:
- // 1) Both are unqualified (both being primitive will fall into this),
- // 2) Both are qualified, and
- // 3) One is qualified and the other is not (one could be primitive).
-
- // For the first two cases a compare of the readable names will always do.
- if (!((sig1.indexOf('.') == -1) ^ (sig2.indexOf('.') == -1))) {
- result = Signature.toString(sig1).equals(Signature.toString(sig2));
- } else {
- // This is case 3.
- // First root out one being primitive.
- if (((sig1.charAt(0) == 'Q') || (sig1.charAt(0) == 'L')) && ((sig2.charAt(0) == 'Q') || (sig2.charAt(0) == 'L'))) {
- // Get the readable name of the qualified signature
- // and the simple name of the other.
- String qualifiedName = null;
- String simpleName = null;
- if (sig1.indexOf('.') == -1) {
- qualifiedName = Signature.toString(sig2);
- simpleName = Signature.toString(sig1);
- } else {
- qualifiedName = Signature.toString(sig1);
- simpleName = Signature.toString(sig2);
- }
-
- // If the simple name resolves to the qualified name, we have a match.
- result = qualifiedName.equals(resolveSimpleTypeName(type, simpleName, resolvedNameCache));
- }
- }
- }
-
- return result;
- }
- private static boolean needsToResolveName(IType type, String simpleName, boolean isForReflection) {
- return !(type.isBinary() || (!isForReflection && simpleName.indexOf(PERIOD) > -1) || isPrimitiveOrVoid(simpleName));
- }
- /**
- * Returns the qualified name for the simple name within the scope of the type.
- * Returns null if the name can not be resolved.
- */
- public static String resolveSimpleTypeName(IType type, String simpleName) throws JavaModelException {
- return resolveSimpleTypeName(type, simpleName, null);
- }
- /**
- * Returns the qualified name for the simple name within the scope of the type.
- * Returns null if the name can not be resolved.
- */
- public static String resolveSimpleTypeName(IType type, String simpleName, Map resolvedNameCache) throws JavaModelException {
- return resolveSimpleTypeName(type, simpleName, resolvedNameCache, false);
- }
-
- /**
- * Returns the qualified name for the simple name within the scope of the type.
- * Returns null if the name can not be resolved.
- */
- public static String resolveSimpleTypeName(IType type, String simpleName, Map resolvedNameCache, boolean isForReflection) throws JavaModelException {
- if (!needsToResolveName(type, simpleName, isForReflection))
- return simpleName;
- String key = null, qualifiedName = null;
- if (resolvedNameCache != null) {
- key = type.getFullyQualifiedName() + RESOLVED_NAME + simpleName;
- qualifiedName = (String) resolvedNameCache.get(key);
- }
- if (qualifiedName == null) {
- String[][] result = getTypeNameInfo(type, simpleName, isForReflection);
- if (result != null) {
- String packName = result[0][0];
- if (packName.length() == 0) {
- qualifiedName = result[0][1];
- if (isForReflection)
- qualifiedName = qualifiedName.replace('.', '$');
- } else {
- StringBuffer b = new StringBuffer();
- b.append(result[0][0]).append(PERIOD);
- String typeName = result[0][1];
- if (isForReflection)
- typeName = typeName.replace('.', '$');
- b.append(typeName);
- qualifiedName = b.toString();
- }
- } else {
- qualifiedName = simpleName;
- }
- if (resolvedNameCache != null)
- resolvedNameCache.put(key, qualifiedName);
- }
- return qualifiedName;
- }
- /**
- * Searches for a matching method and sets it in the
- * descriptor if found.
- */
- public static IMethod searchForMatchingMethod(IType type, String methodName, String[] parmSigs) throws JavaModelException {
- return searchForMatchingMethod(type, methodName, parmSigs, null);
- }
- /**
- * Searches for a matching method and sets it in the
- * descriptor if found.
- */
- public static IMethod searchForMatchingMethod(IType type, String methodName, String[] parmSigs, Map resolvedNameCache) throws JavaModelException {
-
- // First get all the methods by this name and with this many parms.
- IMethod[] allMethods = type.getMethods();
- List candidateMethods = new ArrayList();
- for (int i = 0; i < allMethods.length; i++) {
- int parmSigsLength = (parmSigs != null ? parmSigs.length : 0);
- if ((allMethods[i].getElementName().equals(methodName)) && (allMethods[i].getNumberOfParameters() == parmSigsLength))
- candidateMethods.add(allMethods[i]);
- }
-
- // For each candidate consider each parm for a match.
- // Take the first one that matches on all parms.
- IMethod next = null;
- String[] nextParmSigs = null;
- boolean found = false;
- Iterator candidateIter = candidateMethods.iterator();
- while (!found && (candidateIter.hasNext())) {
- next = (IMethod) candidateIter.next();
- nextParmSigs = next.getParameterTypes();
- found = true;
- for (int i = 0;(found && (i < nextParmSigs.length)); i++)
- found &= matchTypeSignatures(type, parmSigs[i], nextParmSigs[i], resolvedNameCache);
- }
- return found ? next : null;
- }
-
- /**
- * The returned Object[] will contain two entries. The
- * first will be the IJavaElement that was found and the
- * second will be the qualifiedName used to find it.
- */
- protected static Object[] findActualJavaElement(String qualifiedName, IJavaProject javaProject, JDOMAdaptor adaptor) {
- Object[] result = new Object[2];
- if (adaptor == null)
- result[1] = qualifiedName;
- else
- //Ensure the name is qualified
- result[1] = getResolvedTypeName(qualifiedName, adaptor.getType(), adaptor.getTypeResolutionCache());
-
- result[0] = findJavaElement((String) result[1], javaProject, adaptor);
- if (result[0] == null)
- findInnerJavaElement(result, javaProject, adaptor);
- return result;
- }
-
- /**
- * The returned Object[] will contain two entries. The
- * first will be the IJavaElement that was found and the
- * second will be the qualifiedName used to find it.
- */
- protected static void findInnerJavaElement(Object[] info, IJavaProject javaProject, JDOMAdaptor adaptor) {
- String qualifiedName, innerName;
- qualifiedName = (String) info[1];
- int index = qualifiedName.lastIndexOf("."); //$NON-NLS-1$
- if (index > 0) {
- innerName = qualifiedName.substring(0, index);
- innerName += "$"; //$NON-NLS-1$
- innerName += qualifiedName.substring(index + 1, qualifiedName.length());
- if (adaptor != null) {
- //Ensure the name is qualified which it may not be if an inner class
- innerName = getResolvedTypeName(innerName, adaptor.getType(), adaptor.getTypeResolutionCache());
- }
- info[1] = innerName;
- info[0] = findJavaElement(innerName, javaProject, adaptor);
- if (info[0] == null)
- findInnerJavaElement(info, javaProject, adaptor);
- }
- }
-
- protected static IJavaElement findJavaElement(String qualifiedName, IJavaProject javaProject, JDOMAdaptor adaptor) {
- try {
- if (javaProject != null) {
- return javaProject.findType(qualifiedName);
- }
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] { qualifiedName, jme.getMessage()}))); //$NON-NLS-1$ = "Error looking up type: "
- }
- return null;
- }
-
- protected static IPath getPathFromQualifiedName(String qualifiedName) {
- return new Path(qualifiedName.replace('.', File.separatorChar) + ".java"); //$NON-NLS-1$
- }
- /*
- * Resolve a type name in the context of a Type.
- * (Borrowed from org.eclipse.jdt.ui.codemanipulation.StubUtility.getResolvedTypeName())
- * The input is a simple or qualified name, NOT a signature
- * The output will be a qualified name, NOT a signature
- */
- public static String getResolvedTypeName(String typeName, IType declaringType, Map typeCache) {
- String name = typeName;
- try {
- name = JDOMSearchHelper.resolveSimpleTypeName(declaringType, typeName, typeCache, true);
- } catch (JavaModelException e) {
- // ignore
- }
- return name;
- }
-
- public static IType findType(String qualifiedName, boolean useAdvancedForInners, IJavaProject javaProject, JDOMAdaptor adaptor) {
- try {
- IJavaElement found = null;
- String resolvedName = qualifiedName;
- if (useAdvancedForInners) {
- Object[] result = findActualJavaElement(qualifiedName, javaProject, adaptor);
- found = (IJavaElement) result[0];
- resolvedName = (String) result[1];
- } else
- found = findJavaElement(qualifiedName, javaProject, adaptor);
- if (found != null)
- if (found instanceof IClassFile)
- return ((IClassFile) found).getType();
- else if (found instanceof ICompilationUnit) {
- ICompilationUnit foundCU = (ICompilationUnit) found;
- // strip the ".java", lifted from CompilationUnit.getMainTypeName()
- String cuMainTypeName = foundCU.getElementName();
- cuMainTypeName = cuMainTypeName.substring(0, cuMainTypeName.length() - 5);
- return foundCU.getType(cuMainTypeName);
- } else if (found instanceof IType) {
- IType type = ((IType) found);
- if (!type.getFullyQualifiedName('$').equals(resolvedName)) {
- // I don't know why this is here. Sometime in the past for an inner class, the
- // IType returned was for the outer class, so you would need to search again
- // for the inner class against the outer class. I don't know how this now can
- // happen. The code followed above is extremelly complicated, especially when
- // it is an inner class that isn't fully-qualified that is inside a source file.
- // It goes through some gyrations for that. I don't know what it would
- // return in that case. But just in case, the test is here to be safe.
- int index = resolvedName.lastIndexOf('$'); //$NON-NLS-1$
- if (index > -1)
- return type.getType(resolvedName.substring(index + 1, resolvedName.length()));
- else
- return type;
- } else
- return type;
- }
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] { qualifiedName, jme.getMessage()}))); //$NON-NLS-1$ = "Error looking up type: "
- }
- return null;
- }
-
- public static IType findType(String packageName, String qualifiedTypeName, IJavaProject javaProject) {
- try {
- if (javaProject != null) {
- return javaProject.findType(packageName, qualifiedTypeName.replace('$', '.'));
- }
- } catch (JavaModelException jme) {
- System.out.println(ResourceHandler.getString("Error_Looking_Up_Type_ERROR_", (new Object[] { packageName + "." + qualifiedTypeName, jme.getMessage()}))); //$NON-NLS-1$ //$NON-NLS-2$ = "Error looking up type: "
- }
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaClassJDOMAdaptor.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaClassJDOMAdaptor.java
deleted file mode 100644
index dbc1605e2..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaClassJDOMAdaptor.java
+++ /dev/null
@@ -1,703 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JavaClassJDOMAdaptor.java,v $
- * $Revision: 1.24 $ $Date: 2006/01/26 15:21:53 $
- */
-
-import java.util.*;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.jdt.core.*;
-
-
-import org.eclipse.jem.internal.java.adapters.*;
-import org.eclipse.jem.internal.java.adapters.nls.ResourceHandler;
-import org.eclipse.jem.internal.plugin.JavaPlugin;
-import org.eclipse.jem.java.*;
-import org.eclipse.jem.java.internal.impl.JavaClassImpl;
-import org.eclipse.jem.util.TimerTests;
-import org.eclipse.jem.util.UIContextDetermination;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-public class JavaClassJDOMAdaptor extends JDOMAdaptor implements IJavaClassAdaptor {
- private static final String OBJECT_TYPE_NAME = "java.lang.Object"; //$NON-NLS-1$
-
- /*
- * Step ids used for TimerTests of performance testing.
- */
- public static final String REFLECT_CLASS = "Reflect JDOM Class"; //$NON-NLS-1$
- public static final String REFLECT_METHODS = "Reflect all JDOM methods for a class"; //$NON-NLS-1$
- public static final String REFLECT_FIELDS = "Reflect all JDOM fields for a class"; //$NON-NLS-1$
-
-
- protected IType sourceType = null;
- protected JavaReflectionAdapterFactory adapterFactory;
- private Map typeResolutionCache = new HashMap(25);
- private boolean hasReflectedFields, isReflectingFields;
- private boolean hasReflectedMethods, isReflectingMethods;
-
- public JavaClassJDOMAdaptor(Notifier target, IJavaProject workingProject, JavaReflectionAdapterFactory inFactory) {
- super(target, workingProject);
- setAdapterFactory(inFactory);
- }
-
- private Map existingFields = new HashMap();
- /*
- * addFields - reflect our fields
- */
- protected boolean addFields() {
-
- // The algorithm we will use is:
- // 1) Pass through the IField's of this class
- // a) If it is in existingFields, then add to newExisting the entry from
- // oldExisting (deleting from oldExisting at the same time), and flush the field. This is so next we re-get any changed parts of it.
- // b) else not existing, then create new field and add to the new fields list.
- // 2) Remove from the fields list any still left in oldExisting. These are ones that no longer exist.
- // 3) Add all of the news ones to the fields.
- //
- IField[] fields = null;
- try {
- fields = getSourceType().getFields();
- } catch (JavaModelException e) {
- Logger.getLogger().log(e, Level.WARNING);
- return false;
- }
- XMIResource resource = (XMIResource) getJavaClassTarget().eResource();
- Field field = null;
- JavaFieldJDOMAdaptor adapter = null;
- Map newExisting = new HashMap(fields.length);
- List newFields = new ArrayList();
- for (int i = 0; i < fields.length; i++) {
- IField ifield = fields[i];
- field = (Field) existingFields.remove(ifield); // Get the existing field (which is the value) from the collection keyed by IField.
- if (field != null) {
- // It is an existing method. So just put over to newExisting. Then flush it.
- newExisting.put(ifield, field);
- // Since this is a new method, it is not attached to a resource, so we need to explicitly create the adapter.
- adapter = (JavaFieldJDOMAdaptor) EcoreUtil.getExistingAdapter(field, ReadAdaptor.TYPE_KEY);
- if (adapter == null)
- adapter = (JavaFieldJDOMAdaptor) getAdapterFactory().adaptNew(field, ReadAdaptor.TYPE_KEY);
- else
- adapter.flushReflectedValuesIfNecessaryNoNotification(true);
- adapter.setSourceField(ifield); // Give it this new IField
- } else {
- // It is a new method. Create the new method, add to newExisting, and add to newMethods list.
- field = createJavaField(ifield, resource);
- newExisting.put(ifield, field);
- newFields.add(field);
- adapter = (JavaFieldJDOMAdaptor) getAdapterFactory().adaptNew(field, ReadAdaptor.TYPE_KEY);
- if (adapter != null)
- adapter.setSourceField(ifield);
- }
- }
-
- BasicEList fieldsList = (BasicEList) getJavaClassTarget().getFieldsGen();
- if (!existingFields.isEmpty()) {
- // Now any still left in old existing are deleted. So we make them proxies and then remove them from fields list.
- URI baseURI = resource.getURI();
- Collection toDelete = existingFields.values();
- for (Iterator itr = toDelete.iterator(); itr.hasNext();) {
- InternalEObject m = (InternalEObject) itr.next();
- String id = resource.getID(m);
- if (id != null)
- m.eSetProxyURI(baseURI.appendFragment(id));
- }
- fieldsList.removeAll(toDelete);
- }
-
- if (!newFields.isEmpty()) {
- // Now add in the news ones
- fieldsList.addAllUnique(newFields);
- }
-
- // Finally set current existing to the new map we created.
- existingFields = newExisting;
- return true;
- }
-
- private Map existingMethods = new HashMap();
- /*
- * addMethods - reflect our methods. Merge in with the previous.
- */
- protected boolean addMethods() {
- // The algorithm we will use is:
- // 1) Pass through the IMethod's of this class
- // a) If it is in existingMethods, then add to newExisting the entry from
- // oldExisting (deleting from oldExisting at the same time), and flush the method. This is so next we re-get any changed parts of it.
- // b) else not existing, then create new method and add to the new methods list.
- // 2) Remove from the methods list any still left in oldExisting. These are ones that no longer exist.
- // 3) Add all of the news ones to the methods.
- //
- IMethod[] methods = null;
- try {
- methods = getSourceType().getMethods();
- } catch (JavaModelException e) {
- Logger.getLogger().log(e, Level.WARNING);
- return false;
- }
- XMIResource resource = (XMIResource) getJavaClassTarget().eResource();
- Method method = null;
- JavaMethodJDOMAdaptor adapter = null;
- Map newExisting = new HashMap(methods.length);
- List newMethods = new ArrayList();
- for (int i = 0; i < methods.length; i++) {
- IMethod im = methods[i];
- method = (Method) existingMethods.remove(im); // Get the existing method (which is the value) from the collection keyed by IMethod.
- if (method != null) {
- // It is an existing method. So just put over to newExisting. Then flush it.
- newExisting.put(im, method);
- adapter = (JavaMethodJDOMAdaptor) retrieveAdaptorFrom(method);
- if (adapter != null) {
- adapter.flushReflectedValuesIfNecessaryNoNotification(true);
- adapter.setSourceMethod(im); // Give it this new IMethod
- }
- } else {
- // It is a new method. Create the new method, add to newExisting, and add to newMethods list.
- method = createJavaMethod(im, resource);
- newExisting.put(im, method);
- newMethods.add(method);
- // Since this is a new method, it is not attached to a resource, so we need to explicitly create the adapter.
- adapter = (JavaMethodJDOMAdaptor) getAdapterFactory().adaptNew(method, ReadAdaptor.TYPE_KEY);
- if (adapter != null)
- adapter.setSourceMethod(methods[i]);
- }
- }
-
- BasicEList methodsList = (BasicEList) getJavaClassTarget().getMethodsGen();
- if (!existingMethods.isEmpty()) {
- // Now any still left in old existing are deleted. So we make them proxies and then remove them from methods list.
- URI baseURI = resource.getURI();
- Collection toDelete = existingMethods.values();
- for (Iterator itr = toDelete.iterator(); itr.hasNext();) {
- InternalEObject m = (InternalEObject) itr.next();
- String id = resource.getID(m);
- if (id != null)
- m.eSetProxyURI(baseURI.appendFragment(id));
- }
- methodsList.removeAll(toDelete);
- }
-
- if (!newMethods.isEmpty()) {
- // Now add in the news ones
- methodsList.addAllUnique(newMethods);
- }
-
- // Finally set current existing to the new map we created.
- existingMethods = newExisting;
- return true;
- }
- /**
- * Clear source Type ;
- */
- protected void clearSource() {
- sourceType = null;
- }
-
- /**
- * Clear the reflected fields list.
- */
- protected boolean flushFields() {
- // First turn them all into proxies so that any holders will re-resolve to maybe the new one if class comes back.
- existingFields.clear();
- XMIResource res = (XMIResource) getJavaClassTarget().eResource();
- URI baseURI = res.getURI();
- List fields = getJavaClassTarget().getFieldsGen();
- int msize = fields.size();
- for (int i = 0; i < msize; i++) {
- InternalEObject f = (InternalEObject) fields.get(i);
- String id = res.getID(f);
- if (id != null)
- f.eSetProxyURI(baseURI.appendFragment(id));
- }
- fields.clear(); // Now we can clear it.
- return true;
- }
- /**
- * Clear the implements list.
- */
- protected boolean flushImplements() {
- getJavaClassTarget().getImplementsInterfacesGen().clear();
- return true;
- }
- /**
- * Clear the reflected methods list.
- */
- protected boolean flushMethods() {
- // First turn them all into proxies so that any holders will re-resolve to maybe the new one if class comes back.
- existingMethods.clear();
- XMIResource res = (XMIResource) getJavaClassTarget().eResource();
- URI baseURI = res.getURI();
- List methods = getJavaClassTarget().getMethodsGen();
- int msize = methods.size();
- for (int i = 0; i < msize; i++) {
- InternalEObject m = (InternalEObject) methods.get(i);
- String id = res.getID(m);
- if (id != null)
- m.eSetProxyURI(baseURI.appendFragment(id));
- }
- methods.clear(); // Now we can clear it.
- return true;
- }
- protected boolean flushModifiers() {
- JavaClass javaClassTarget = (JavaClass) getTarget();
- javaClassTarget.setAbstract(false);
- javaClassTarget.setFinal(false);
- javaClassTarget.setPublic(false);
- javaClassTarget.setKind(TypeKind.UNDEFINED_LITERAL);
- return true;
- }
- protected boolean flushInnerClasses() {
- getJavaClassTarget().getDeclaredClassesGen().clear();
- return true;
- }
-
- protected boolean flushAndClearCachedModelObject;
-
- /**
- * Clear the reflected values.
- */
- protected boolean flushReflectedValues(boolean clearCachedModelObject) {
- flushAndClearCachedModelObject = clearCachedModelObject;
- return true;
- }
-
- /*
- * This is called before a reflect if a real flush is needed.
- */
- private void flushNow() {
- if (flushAndClearCachedModelObject)
- setSourceType(null);
- typeResolutionCache.clear();
- flushModifiers();
- flushSuper();
- flushImplements();
- if (flushAndClearCachedModelObject) {
- // Don't flush these yet. We will try to reuse them on the next reflush. If clear model too, then flush them. This usually means class has been deleted, so why keep them around.
- flushMethods();
- flushFields();
- }
- // Even if we didn't flush the fields/methods, we do need to mark as not reflected so on next usage we will merge in the changes.
- hasReflectedMethods = false;
- hasReflectedFields = false;
-
- flushInnerClasses();
- flushAndClearCachedModelObject = false;
- }
-
-
- /**
- * @see com.ibm.etools.java.adapters.JavaReflectionAdaptor#postFlushReflectedValuesIfNecessary()
- */
- protected void postFlushReflectedValuesIfNecessary(boolean isExisting) {
- getJavaClassTarget().setReflected(false);
- super.postFlushReflectedValuesIfNecessary(isExisting);
- }
-
- /**
- * Set the supertype to be null.
- */
- protected boolean flushSuper() {
- List targetSupers = getJavaClassTarget().primGetESuperTypes();
- targetSupers.clear();
- return true;
- }
- protected JavaReflectionAdapterFactory getAdapterFactory() {
- return adapterFactory;
- }
- /**
- * getBinaryType - return the IType which describes our existing Java class file
- */
- protected IType getBinaryType() {
- return this.getBinaryType(((JavaClass) getTarget()).getQualifiedName());
- }
- /**
- * Return the target typed to a JavaClass.
- */
- protected JavaClassImpl getJavaClassTarget() {
- return (JavaClassImpl) getTarget();
- }
- public Object getReflectionSource() {
- return getSourceType();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdaptor#hasReflectionSource()
- */
- public boolean hasCachedReflectionSource() {
- return sourceType != null;
- }
- /**
- * getSourceType - return the IType which describes our existing Java class or source file
- */
- public IType getSourceType() {
- if (sourceType == null) {
- JavaClassImpl javaClass = (JavaClassImpl) getTarget();
- sourceType = JDOMSearchHelper.findType(javaClass.getJavaPackage().getName(), javaClass.primGetName(), getSourceProject());
- }
- return sourceType;
- }
- /**
- * getSourceType - return the IType which describes our existing Java class or source file
- */
- protected IType getType() {
- return getSourceType();
- }
- protected Map getTypeResolutionCache() {
- return typeResolutionCache;
- }
- /**
- * getValueIn method comment.
- */
- public Object getValueIn(EObject object, EObject attribute) {
- // At this point, this adapter does not dynamically compute any values,
- // all values are pushed back into the target on the initial call.
- return super.getValueIn(object, attribute);
- }
- /**
- * Return true if the sourceType is null or if
- * it is a binary type.
- */
- public boolean isSourceTypeFromBinary() {
- if (getSourceType() == null)
- return false; //must be new?
- return getSourceType().isBinary();
- }
-
-
- protected JavaClass reflectJavaClass(String qualifiedName) {
- IType type = JDOMSearchHelper.findType(qualifiedName, true, getSourceProject(), this);
- if (type != null)
- return reflectJavaClass(type);
- else
- return createJavaClassRef(qualifiedName);
- }
- protected JavaClass reflectJavaClass(IType aType) {
- if (aType != null) {
- JavaClass javaClass = (JavaClass) JavaRefFactory.eINSTANCE.reflectType(aType.getFullyQualifiedName(), (EObject) getTarget());
- if (javaClass != null) {
- JavaClassJDOMAdaptor adaptor = (JavaClassJDOMAdaptor) EcoreUtil.getAdapter(javaClass.eAdapters(), ReadAdaptor.TYPE_KEY);
- if (adaptor != null)
- adaptor.setSourceType(aType);
- }
- return javaClass;
- }
- return null;
- }
- /**
- * reflectValues - template method, subclasses override to pump values into target.
- * on entry: name, containing package (and qualified name), and document must be set.
- * Return true always and the JavaReflectionSynchronizer will flush with the type can
- * be found again. In headless mode, return true only if the type is found. This is
- * needed becauce most headless tasks are done under one operation and the JavaReflectionSynchronizer
- * may not have a chance to flush a bad reflection before the real type needs to be found and can be found.
- * JavaClass adaptor:
- * - set modifiers
- * - set name
- * - set reference to super
- * - create methods
- * - create fields
- * - add imports
- */
- public boolean reflectValues() {
- if (hasFlushed) {
- // We flush sometime in the past since last reflect. So now do the actual flush.
- flushNow();
- }
- super.reflectValues();
- boolean isHeadless = UIContextDetermination.getCurrentContext() == UIContextDetermination.HEADLESS_CONTEXT;
- if (canReflect()) {
- TimerTests.basicTest.startCumulativeStep(REFLECT_CLASS);
- try {
- ICompilationUnit cu = getSourceType().getCompilationUnit();
- boolean isWC = cu != null ? cu.isWorkingCopy() : false;
- IResource res = isWC ? getSourceType().getResource() : null;
- // We are only interested in physical classes. If still just in working copy and not yet put out to
- // disk, we don't should treat as not exist. Anything else is considered existing because we got past
- // getSourceType.exists. This will return the truth for non-wc. But for wc types it will return true,
- // even though not physically on disk (such as just creating it and hadn't saved it yet). So for wc types
- // we need to test the actual resource.
- // Test is OK if not wc, or if wc, then there is a res. and it is accessible.
- if (!isWC || (res != null && res.isAccessible())) {
- setModifiers();
- setNaming();
- try {
- setSuper();
- } catch (InheritanceCycleException e) {
- JavaPlugin.getDefault().getLogger().log(e);
- }
- setImplements();
- reflectInnerClasses();
- setDeclaringClass();
- //addImports();
- if (isHeadless) {
- registerWithFactory();
- return true;
- }
- }
- } finally {
- TimerTests.basicTest.stopCumulativeStep(REFLECT_CLASS);
- }
- }
- if (isHeadless)
- return false;
- else {
- registerWithFactory();
- return true;
- }
- }
-
- protected void setDeclaringClass() {
- IType declaringType = getSourceType().getDeclaringType();
- if (declaringType != null) {
- // Need to get it and reflect it so that the declared type of this target is set correctly. We can just
- // set it ourselves directly because ECore would try to add it to the list of inner classes of the declaring type. This
- // would cause it to be added twice, once from the reflection caused by the inverse setting, and once from our doing
- // the inverse setting itself.
- ResourceSet set = getTargetResource().getResourceSet();
- String packageName = declaringType.getPackageFragment().getElementName();
- JavaClassImpl declaringClass = (JavaClassImpl) JavaRefFactory.eINSTANCE.reflectType(packageName, declaringType.getTypeQualifiedName(), set);
- declaringClass.getDeclaredClasses(); // This will cause it to put us into its list and also set our declaring class to this declaring type.
- }
- }
-
-
- /**
- * @return
- */
- private boolean canReflect() {
- return isResourceLoaded() && getSourceProject() != null && getSourceType() != null && getSourceType().exists();
- }
- public synchronized boolean reflectFieldsIfNecessary() {
- if (reflectValuesIfNecessary() && canReflect()) {
- if (!hasReflectedFields && !isReflectingFields) {
- isReflectingFields = true;
- try {
- TimerTests.basicTest.startCumulativeStep(REFLECT_FIELDS);
- addFields();
- hasReflectedFields = true;
- } catch (Throwable e) {
- hasReflectedFields = false;
- Logger logger = Logger.getLogger();
- if (logger.isLoggingLevel(Level.WARNING)) {
- logger.log(ResourceHandler.getString("Failed_reflecting_values_ERROR_"), Level.WARNING); //$NON-NLS-1$ = "Failed reflecting values!!!"
- logger.logWarning(e);
- }
- } finally {
- isReflectingFields = false;
- TimerTests.basicTest.stopCumulativeStep(REFLECT_FIELDS);
- }
- }
- return hasReflectedFields;
- } else
- return false; // Couldn't reflect the base values, so couldn't do fields either
- }
- public synchronized boolean reflectMethodsIfNecessary() {
- if (reflectValuesIfNecessary() && canReflect()) {
- if (!hasReflectedMethods && !isReflectingMethods) {
- isReflectingMethods = true;
- try {
- TimerTests.basicTest.startCumulativeStep(REFLECT_METHODS);
- hasReflectedMethods = addMethods();
- } catch (Throwable e) {
- hasReflectedMethods = false;
- Logger logger = Logger.getLogger();
- if (logger.isLoggingLevel(Level.WARNING)) {
- logger.log(ResourceHandler.getString("Failed_reflecting_values_ERROR_"), Level.WARNING); //$NON-NLS-1$ = "Failed reflecting values!!!"
- logger.logWarning(e);
- }
- } finally {
- isReflectingMethods = false;
- if (!hasReflected)
- flushMethods(); // Something bad happened, so we will do a complete flush to be on safe side.
- TimerTests.basicTest.stopCumulativeStep(REFLECT_METHODS);
- }
- }
- return hasReflectedMethods;
- } else
- return false; // Couldn't reflect the base values, so couldn't do fields either
- }
-
- private void registerWithFactory() {
- getAdapterFactory().registerReflection(getJavaClassTarget().getQualifiedNameForReflection(), this);
- }
-
- /**
- * @see com.ibm.etools.java.adapters.ReflectionAdaptor#notifyChanged(new ENotificationImpl((InternalEObject)Notifier, int,(EStructuralFeature) EObject, Object, Object, int))
- */
- public void notifyChanged(Notification notification) {
- if (notification.getEventType() == Notification.REMOVING_ADAPTER
- && notification.getOldValue() == this
- && notification.getNotifier() == getTarget())
- getAdapterFactory().unregisterReflection(getJavaClassTarget().getQualifiedNameForReflection());
-
- }
-
- protected void setAdapterFactory(JavaReflectionAdapterFactory inFactory) {
- adapterFactory = inFactory;
- }
- /**
- * setImplements - set our implemented/super interfaces here
- * For an interface, these are superclasses.
- * For a class, these are implemented interfaces.
- */
- protected void setImplements() {
- try {
- String[] interfaceNames = getSourceType().getSuperInterfaceNames();
- JavaClass ref;
- // needs work, the names above will be simple names if we are relfecting from a source file
- List list = getJavaClassTarget().getImplementsInterfacesGen();
- for (int i = 0; i < interfaceNames.length; i++) {
- ref = reflectJavaClass(interfaceNames[i]);
- list.add(ref);
- }
- } catch (JavaModelException npe) {
- // name stays null and we carry on
- }
- }
- /**
- * setModifiers - set the attribute values related to modifiers here
- */
- protected void setModifiers() {
- JavaClass javaClassTarget = (JavaClass) getTarget();
- try {
- javaClassTarget.setAbstract(Flags.isAbstract(getSourceType().getFlags()));
- javaClassTarget.setFinal(Flags.isFinal(getSourceType().getFlags()));
- javaClassTarget.setPublic(Flags.isPublic(getSourceType().getFlags()));
- // Set type to class or interface, not yet handling EXCEPTION
- if (getSourceType().isClass())
- javaClassTarget.setKind(TypeKind.CLASS_LITERAL);
- else
- javaClassTarget.setKind(TypeKind.INTERFACE_LITERAL);
- } catch (JavaModelException npe) {
- Logger logger = JavaPlugin.getDefault().getLogger();
- if (logger.isLoggingLevel(Level.WARNING))
- logger.log(ResourceHandler.getString("Error_Introspecting_Flags_ERROR_", new Object[] { javaClassTarget.getQualifiedName(), npe.getMessage()}), Level.WARNING); //$NON-NLS-1$ = "error introspecting flags on {0}"
- }
- }
- /**
- * setNaming - set the naming values here
- * - qualified name (package name + name) must be set first, that is the path to the real Java class
- * - ID - simple name, identity within a package document
- * - null UUID
- */
- protected void setNaming() {
- /* Naming has been provided by the JavaReflectionKey
- JavaClass javaClassTarget = (JavaClass) getTarget();
- String packageName = getSourceType().getPackageFragment().getElementName();
- javaClassTarget.refSetUUID((String)null);
- ((XMIResource)javaClassTarget.eResource()).setID(javaClassTarget,getSourceType().getElementName());
- */
- }
- protected void setSourceType(IType aType) {
- sourceType = aType;
- }
- /**
- * setSuper - set our supertype here, implemented interface are handled separately
- */
- protected void setSuper() throws InheritanceCycleException {
- String superName = null;
- IType superType = null;
- try {
- if (!getSourceType().isInterface()) {
- superName = getSourceType().getSuperclassName();
- // binary types will always have fully-qualified super names, so no need to do any searching.
- if (!getSourceType().isBinary() && superName != null && isTargetInner()) {
- IType declaringType = getSourceType().getDeclaringType();
- if (declaringType != null) {
- //Get all parent InnerTypes
- IType[] inners = declaringType.getTypes();
- for (int i = 0; i < inners.length; i++) {
- IType type = inners[i];
- if (superName.equals(type.getElementName())) {
- superName = declaringType.getElementName() + '.' + superName;
- reflectInnerClasses(declaringType);
- superType = type;
- break;
- }
- }
- }
- }
-
- //Source files return null if extends does not exist.
- if (superName == null && !getSourceType().getFullyQualifiedName().equals(OBJECT_TYPE_NAME))
- superName = OBJECT_TYPE_NAME;
- if (superName != null) {
- JavaClass javaClassTarget = (JavaClass) getTarget();
- if (superType != null)
- javaClassTarget.setSupertype(reflectJavaClass(superType));
- else
- javaClassTarget.setSupertype(reflectJavaClass(superName));
- }
- }
- } catch (JavaModelException npe) {
- }
- }
- private boolean isTargetInner() {
- JavaClassImpl javaClass = (JavaClassImpl) getTarget();
- return (javaClass.getName().indexOf('$') != -1);
- }
- /**
- * Return true if the sourceType can be found.
- */
- public boolean sourceTypeExists() {
- return getSourceType() != null;
- }
- protected void reflectInnerClasses() {
- IType[] innerClasses = null;
- try {
- innerClasses = getSourceType().getTypes();
- } catch (JavaModelException e) {
- }
- if (innerClasses != null && innerClasses.length != 0) {
- List declaredClasses = getJavaClassTarget().getDeclaredClassesGen();
- JavaClass inner;
- ResourceSet set = getTargetResource().getResourceSet();
- String packageName = getSourceType().getPackageFragment().getElementName();
- for (int i = 0; i < innerClasses.length; i++) {
- inner = (JavaClass) JavaRefFactory.eINSTANCE.reflectType(packageName, innerClasses[i].getTypeQualifiedName(), set);
- declaredClasses.add(inner);
- }
- }
- }
- protected void reflectInnerClasses(IType aType) {
- IType[] innerClasses = null;
- try {
- innerClasses = aType.getTypes();
- } catch (JavaModelException e) {
- }
- if (innerClasses != null && innerClasses.length != 0) {
- ResourceSet set = getTargetResource().getResourceSet();
- String packageName = aType.getPackageFragment().getElementName();
- JavaClassImpl parentType = (JavaClassImpl) JavaRefFactory.eINSTANCE.reflectType(packageName, aType.getTypeQualifiedName(), set);
- List declaredClasses = parentType.getDeclaredClassesGen();
- JavaClass inner;
-
-
- for (int i = 0; i < innerClasses.length; i++) {
- inner = (JavaClass) JavaRefFactory.eINSTANCE.reflectType(packageName, innerClasses[i].getTypeQualifiedName(), set);
- declaredClasses.add(inner);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaFieldJDOMAdaptor.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaFieldJDOMAdaptor.java
deleted file mode 100644
index df005d6f1..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaFieldJDOMAdaptor.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JavaFieldJDOMAdaptor.java,v $
- * $Revision: 1.13 $ $Date: 2005/10/18 14:58:18 $
- */
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.jdt.core.*;
-
-import org.eclipse.jem.internal.java.adapters.ReadAdaptor;
-import org.eclipse.jem.internal.java.adapters.nls.ResourceHandler;
-import org.eclipse.jem.java.*;
-import org.eclipse.jem.java.internal.impl.FieldImpl;
-/**
- * Insert the type's description here.
- * Creation date: (6/6/2000 4:42:50 PM)
- * @author: Administrator
- */
-public class JavaFieldJDOMAdaptor extends JDOMAdaptor {
- private static final String BEGIN_COMMENT = "/*"; //$NON-NLS-1$
- private static final String END_COMMENT = "*/"; //$NON-NLS-1$
- protected IField sourceField = null;
- protected IType parentType = null;
- public JavaFieldJDOMAdaptor(Notifier target, IJavaProject workingProject) {
- super(target, workingProject);
- }
- protected void clearSource() {
- sourceField = null;
- }
-
- protected boolean flushReflectedValues(boolean clearCachedModelObject) {
- if (clearCachedModelObject)
- clearSource();
- FieldImpl field = getTargetField();
- field.setInitializer(null);
- field.setFinal(false);
- field.setStatic(false);
- field.setTransient(false);
- field.setVolatile(false);
- field.setJavaVisibility(JavaVisibilityKind.PUBLIC_LITERAL);
- field.setEType(null);
- return true;
- }
-
- protected void postFlushReflectedValuesIfNecessary(boolean isExisting) {
- getTargetField().setReflected(false);
- super.postFlushReflectedValuesIfNecessary(isExisting);
- }
- /**
- * Return a String for the source starting after the field's name to the end of
- * the source range. This will be the source after the name which could include comments.
- */
- protected String getFieldInitializerSource() {
- IOpenable openable = getSourceField().getOpenable();
- try {
- ISourceRange nameRange, sourceRange;
- int start = -1, length = 0;
- IBuffer buffer = openable.getBuffer();
- if (buffer == null) {
- return ""; //$NON-NLS-1$
- }
- nameRange = getSourceField().getNameRange();
- start = nameRange.getOffset() + nameRange.getLength();
- if (start != -1) {
- sourceRange = getSourceField().getSourceRange();
- if (sourceRange.getOffset() != -1)
- length = sourceRange.getOffset() + sourceRange.getLength() - start;
- return buffer.getText(start, length);
- }
- return null;
- } catch (JavaModelException e) {
- return ""; //$NON-NLS-1$
- }
- }
- /**
- * Return the field source string without comments
- */
- protected String getFieldInitializerSourceWithoutComments() {
- String s = getFieldInitializerSource();
- int start = 0;
- int startComment = -1;
- int endComment = -1;
- while (start < s.length()) {
- startComment = s.indexOf(BEGIN_COMMENT, start);
- if (startComment > 0) {
- String newString;
- endComment = s.indexOf(END_COMMENT, start);
- newString = s.substring(start, startComment);
- s = newString + s.substring(endComment + END_COMMENT.length(), s.length());
- start = 0;
- startComment = -1;
- endComment = -1;
- } else {
- start = s.length();
- }
- }
- return s;
- }
- /**
- * getFieldInitializerString - parse the source for our source field
- * and return the initialization string.
- * Return null if no initialization string or constant value is present.
- * i.e. - public String foo = "foo default"; should return "foo default" (including quotes)
- */
- protected String getFieldInitializerString() {
- String result = null;
- try {
- if (!getParentType().isBinary()) {
- String source = getFieldInitializerSourceWithoutComments();
- if (source != null && source.length() != 0) {
- int equalsPos = source.indexOf('=');//$NON-NLS-1$
- int endPos = source.indexOf(',');//$NON-NLS-1$
- if (endPos == -1)
- endPos = source.length() - 1;
- if (equalsPos != -1) {
- // Copy from after "=" to before ";" or ","
- result = source.substring(equalsPos + 1, endPos);
- result = result.trim();
- }
- }
- } else {
- // Binary type, see if we can use the constant
- // it's not clear from the API's, but this is probably only
- // available for statics.
- Object constantValue = getSourceField().getConstant();
- // Need to convert the constant to a String
- if (constantValue != null) {
- result = constantValue.toString();
- if (constantValue instanceof String) {
- result = "\"" + result + "\""; //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- } catch (JavaModelException e) {
- // punt
- }
- return result;
- }
- /**
- * getParentType - return the IType which corresponds to our parent JavaClass
- * we're going to do this a lot, so cache it.
- */
- protected IType getParentType() {
- if (parentType == null) {
- Field targetField = (Field) getTarget();
- JavaClass parentJavaClass = targetField.getJavaClass();
- if (parentJavaClass != null) {
- JavaClassJDOMAdaptor pa = (JavaClassJDOMAdaptor) EcoreUtil.getAdapter(parentJavaClass.eAdapters(), ReadAdaptor.TYPE_KEY);
- if (pa != null)
- parentType = pa.getSourceType();
- }
- }
- return parentType;
- }
- public Object getReflectionSource() {
- return getSourceField();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdaptor#hasReflectionSource()
- */
- public boolean hasCachedReflectionSource() {
- return sourceField != null;
- }
-
- /*
- * Used by Java Class JDOM adapter to create and set with a source field
- */
- public void setSourceField(IField field) {
- sourceField = field;
- }
- /**
- * getSourceField - return the IField which describes our implementing field
- */
- protected IField getSourceField() {
- if (sourceField == null || !sourceField.exists()) {
- IType parent = this.getParentType();
- if (parent != null)
- sourceField = parent.getField(((Field) getTarget()).getName());
- }
- return sourceField;
- }
- public FieldImpl getTargetField() {
- return (FieldImpl) getTarget();
- }
- protected IType getType() {
- return getParentType();
- }
- protected Map getTypeResolutionCache() {
- Field field = getTargetField();
- if (field != null) {
- JavaClass javaClass = field.getJavaClass();
- if (javaClass != null) {
- JDOMAdaptor classAdaptor = (JDOMAdaptor) retrieveAdaptorFrom(javaClass);
- if (classAdaptor != null)
- return classAdaptor.getTypeResolutionCache();
- }
- }
- return null;
- }
- /**
- * getValueIn method comment.
- */
- public Object getValueIn(EObject object, EObject attribute) {
- // At this point, this adapter does not dynamically compute any values,
- // all values are pushed back into the target on the initial call.
- return super.getValueIn(object, attribute);
- }
- /**
- * reflectValues - template method, subclasses override to pump values into target.
- * on entry: name, containing package (and qualified name), and document must be set.
- * JavaClass adaptor:
- * - set modifiers
- * - set name
- * - set type
- */
- public boolean reflectValues() {
- super.reflectValues();
- if (isResourceLoaded() && getSourceProject() != null && getSourceField() != null) {
- setModifiers();
- // setNaming();
- setType();
- return true;
- }
- return false;
- }
- /**
- * setModifiers - set the attribute values related to modifiers here
- */
- protected void setModifiers() {
- Field javaFieldTarget = (Field) getTarget();
- try {
- String initializer = getFieldInitializerString();
- if (initializer != null)
- javaFieldTarget.setInitializer(createBlock(javaFieldTarget.getName(), initializer));
- int flags = getSourceField().getFlags();
- javaFieldTarget.setFinal(Flags.isFinal(flags));
- javaFieldTarget.setStatic(Flags.isStatic(flags));
- javaFieldTarget.setTransient(Flags.isTransient(flags));
- javaFieldTarget.setVolatile(Flags.isVolatile(flags));
- // Set visibility
- if (Flags.isPublic(flags))
- javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PUBLIC_LITERAL);
- else if (Flags.isPrivate(flags))
- javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PRIVATE_LITERAL);
- else if (Flags.isProtected(flags))
- javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PROTECTED_LITERAL);
- else
- javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PACKAGE_LITERAL);
- } catch (JavaModelException npe) {
- System.out.println(ResourceHandler.getString("Error_Introspecting_Flags_ERROR_", new Object[] {((XMIResource) javaFieldTarget.eResource()).getID(javaFieldTarget), npe.getMessage()})); //$NON-NLS-1$ = "error introspecting flags on {0}"
- }
- }
- /**
- * setNaming - set the naming values here
- * - qualified name must be set first, that is the path to the real Java class
- * - ID
- * - null UUID
- */
- protected void setNaming() {
- Field javaFieldTarget = (Field) getTarget();
- JavaClass parent = javaFieldTarget.getContainingJavaClass();
- ((XMIResource) javaFieldTarget.eResource()).setID(javaFieldTarget, parent.getName() + "_" + javaFieldTarget.getName()); //$NON-NLS-1$
- }
- /**
- * setType - set our type here
- */
- protected void setType() {
- String typeName = null;
- try {
- typeName = typeNameFromSignature(getSourceField().getTypeSignature());
- } catch (JavaModelException npe) {
- // name stays null and we carry on
- }
- setFieldType(getTargetField(), typeName);
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaJDOMAdapterFactory.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaJDOMAdapterFactory.java
deleted file mode 100644
index f0f7da014..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaJDOMAdapterFactory.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JavaJDOMAdapterFactory.java,v $
- * $Revision: 1.7 $ $Date: 2005/12/02 18:41:27 $
- */
-import java.util.*;
-
-import org.eclipse.emf.common.notify.*;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jem.internal.java.adapters.*;
-import org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory;
-import org.eclipse.jem.internal.java.adapters.ReflectionAdaptor;
-/**
- * Insert the type's description here.
- * Creation date: (6/13/2000 1:20:31 PM)
- * @author: Administrator
- */
-public class JavaJDOMAdapterFactory extends JavaReflectionAdapterFactory {
-
- protected JavaReflectionSynchronizer synchronizer;
- protected IJavaProject javaProject;
-/**
- * JavaJDOMAdapterFactory constructor comment.
- */
-public JavaJDOMAdapterFactory() {
- super();
-}
-/**
- * JavaJDOMAdapterFactory constructor comment.
- */
-public JavaJDOMAdapterFactory(IJavaProject aJavaProject) {
- this();
- setJavaProject(aJavaProject);
-}
-protected ReflectionAdaptor createJavaClassAdaptor(Notifier target) {
- return new JavaClassJDOMAdaptor(target, getJavaProject(), this);
-}
-protected ReflectionAdaptor createJavaFieldAdaptor(Notifier target) {
- return new JavaFieldJDOMAdaptor(target, getJavaProject());
-}
-protected ReflectionAdaptor createJavaMethodAdaptor(Notifier target) {
- return new JavaMethodJDOMAdaptor(target, getJavaProject());
-}
-/**
- * Flush ALL adapters, worst case
- * We also want to ensure that the source types are also cleared
- * in this worst case scenario.
- */
-public void flushAll() {
- doFlush(reflected.values(),true, true);
-}
-
-public List flushAllNoNotification() {
- return doFlush(reflected.values(),true, false);
-}
-
-public void flushPackage(String packageName, boolean noFlushIfSourceFound) {
- List adaptors = getReflectedForPackage(packageName, noFlushIfSourceFound);
- doFlush(adaptors, true, true);
-}
-public List flushPackageNoNotification(String packageName, boolean noFlushIfSourceFound) {
- List adaptors = getReflectedForPackage(packageName, noFlushIfSourceFound);
- return doFlush(adaptors, true, false);
-}
-/**
- * Return a List of reflection adaptors that belong to
- * the packageName.
- * @param packageName
- * @return
- */
-private List getReflectedForPackage(String packageName, boolean filterFoundTypes) {
- if (packageName != null && !reflected.isEmpty()) {
- isBusyIteratingReflected = true;
- List result = null;
- try {
- Iterator it = reflected.entrySet().iterator();
- Map.Entry entry;
- String key;
- JavaClassJDOMAdaptor adaptor;
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- adaptor = (JavaClassJDOMAdaptor) entry.getValue();
- if (filterFoundTypes && adaptor.sourceType != null)
- continue;
- key = (String) entry.getKey();
- if (key.startsWith(packageName) && key.indexOf('.', packageName.length() + 1) < 0) {
- if (result == null)
- result = new ArrayList();
- result.add(entry.getValue());
- }
- }
- } finally {
- finishedIteratingReflected();
- }
- if (result != null)
- return result;
- }
- return Collections.EMPTY_LIST;
-}
-private List doFlush(Collection adaptors, boolean clearSourceType, boolean doNotify) {
- if (!adaptors.isEmpty()) {
- isBusyIteratingReflected = true;
- List notifications = doNotify ? null : new ArrayList(adaptors.size());
- try {
- Notification notification;
- Iterator i = adaptors.iterator();
- JDOMAdaptor adaptor;
- while (i.hasNext()) {
- adaptor = (JDOMAdaptor) i.next();
- if (doNotify)
- adaptor.flushReflectedValuesIfNecessary(clearSourceType);
- else {
- notification = adaptor.flushReflectedValuesIfNecessaryNoNotification(clearSourceType);
- if (notification != null)
- notifications.add(notification);
- }
- }
- } finally {
- finishedIteratingReflected();
- }
- return notifications;
- }
- return Collections.EMPTY_LIST;
-}
-// Flush the adapter for a source object
-public void flushReflection(String source) {
- JDOMAdaptor a = (JDOMAdaptor) reflected.get(source);
- if (a != null)
- a.flushReflectedValuesIfNecessary();
-}
-public Notification flushReflectionNoNotification(String source) {
- JDOMAdaptor a = (JDOMAdaptor) reflected.get(source);
- if (a != null)
- return a.flushReflectedValuesIfNecessaryNoNotification(false);
- return null;
-}
-
-public Notification flushReflectionPlusInnerNoNotification(String source) {
- isBusyIteratingReflected = true;
- Notification notification = null;
- try {
- String innerName = source + '$';
- Iterator it = reflected.entrySet().iterator();
- Map.Entry entry;
- String key;
- JavaReflectionAdaptor adaptor;
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- key = (String) entry.getKey();
- if (key.equals(source) || key.startsWith(innerName)) {
- adaptor = (JavaReflectionAdaptor) reflected.get(key);
- if (adaptor != null) {
- if (notification == null)
- notification = adaptor.flushReflectedValuesIfNecessaryNoNotification(false);
- else
- ((NotificationChain) notification).add(adaptor.flushReflectedValuesIfNecessaryNoNotification(false));
- }
- }
- }
- } finally {
- finishedIteratingReflected();
- }
- return notification;
-
-}
-/**
- * Insert the method's description here.
- * Creation date: (11/2/2000 3:02:31 PM)
- * @return org.eclipse.jdt.core.api.IJavaProject
- */
-public IJavaProject getJavaProject() {
- return javaProject;
-}
-/**
- * Create a Java Model listener which will flush invalidated adaptors.
- * This will cause those adapters to re-reflect their target object's contents.
- */
-protected void initializeSynchronizer() {
- synchronizer = new JavaReflectionSynchronizer(this);
-}
-/**
- * Notify all JDOMAdapters which use the same target ICompilationUnit
- * Creation date: (8/17/2001 4:45:43 PM)
- */
-public void notifyContentChanged(ICompilationUnit targetCU) {
-
- if (targetCU == null || reflected.values()==null) return ;
- isBusyIteratingReflected = true;
- try {
- Iterator i = reflected.values().iterator();
- while (i.hasNext()) {
- Object a = i.next() ;
- if (a instanceof JDOMAdaptor) {
- JDOMAdaptor adaptor = (JDOMAdaptor) a;
- IMember reflectionSource = (IMember) adaptor.getReflectionSource();
- ICompilationUnit adapterCU = null ;
- if (reflectionSource != null) {
- try {
- adapterCU = reflectionSource.getCompilationUnit();
- } catch (Throwable e) {}
- }
- if (adapterCU != null && targetCU.equals(adapterCU)) {
- adaptor.contentChanged();
- }
- }
- }
- } finally {
- finishedIteratingReflected();
- }
-}
-/**
- * Insert the method's description here.
- * Creation date: (11/2/2000 3:02:31 PM)
- * @param newJavaProject org.eclipse.jdt.core.IJavaProject
- */
-public void setJavaProject(IJavaProject newJavaProject) {
- javaProject = newJavaProject;
- if (newJavaProject != null && synchronizer == null)
- initializeSynchronizer();
-}
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaMethodJDOMAdaptor.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaMethodJDOMAdaptor.java
deleted file mode 100644
index 5497877eb..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaMethodJDOMAdaptor.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: JavaMethodJDOMAdaptor.java,v $
- * $Revision: 1.14 $ $Date: 2005/10/18 14:58:18 $
- */
-package org.eclipse.jem.internal.adapters.jdom;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.jdt.core.*;
-
-import org.eclipse.jem.internal.java.adapters.IJavaMethodAdapter;
-import org.eclipse.jem.internal.java.adapters.ReadAdaptor;
-import org.eclipse.jem.internal.java.adapters.nls.ResourceHandler;
-import org.eclipse.jem.java.*;
-import org.eclipse.jem.java.internal.impl.MethodImpl;
-import org.eclipse.jem.util.TimerTests;
-
-/**
- * Java Method Reflection Adapter for JDOM (i.e. JDT model)
- * Creation date: (6/6/2000 4:42:50 PM)
- * @author: Administrator
- */
-public class JavaMethodJDOMAdaptor extends JDOMAdaptor implements IJavaMethodAdapter {
-
- /*
- * Step ids used for TimerTests of performance testing.
- */
- public static final String REFLECT_METHOD = "Reflect JDOM Method"; //$NON-NLS-1$
-
- protected IMethod sourceMethod = null;
-
- protected IType parentType = null;
-
- public JavaMethodJDOMAdaptor(Notifier target, IJavaProject workingProject) {
- super(target, workingProject);
- }
-
-
- protected boolean flushReflectedValues(boolean clearCachedModelObject) {
- if (clearCachedModelObject)
- clearSource();
- MethodImpl method = (MethodImpl) getTarget();
- method.setIsGenerated(false);
- method.setFinal(false);
- method.setNative(false);
- method.setStatic(false);
- method.setSynchronized(false);
- method.setConstructor(false);
- method.setAbstract(false);
- method.setJavaVisibility(JavaVisibilityKind.PUBLIC_LITERAL);
- method.setEType(null);
- method.getParametersGen().clear();
- method.getJavaExceptionsGen().clear();
- parentType = null;
- return true;
- }
-
- protected void postFlushReflectedValuesIfNecessary(boolean isExisting) {
- ((MethodImpl) getTarget()).setReflected(false);
- super.postFlushReflectedValuesIfNecessary(isExisting);
- }
- /**
- * addExceptions - reflect our exception list
- */
- protected void addExceptions() {
- try {
- IMethod sourceMethod = getSourceMethod();
- String[] exceptionNames = sourceMethod.getExceptionTypes();
- List exceptions = ((MethodImpl) getTarget()).getJavaExceptionsGen();
- for (int i = 0; i < exceptionNames.length; i++) {
- exceptions.add(createJavaClassRef(typeNameFromSignature(exceptionNames[i])));
- }
- } catch (JavaModelException npe) {
- // name stays null and we carry on
- }
- }
-
-
- protected String[] getParameterNames() {
- String[] parmNames = new String[0], parmTypeNames = getSourceMethod().getParameterTypes();
- try {
- parmNames = getSourceMethod().getParameterNames();
- } catch (JavaModelException npe) {
- // name stays null and we carry on
- }
- // Temp hack to work around a JavaModel bug, above call on a Binary method may return null
- if (parmNames == null || parmNames.length == 0) {
- parmNames = new String[parmTypeNames.length];
- for (int i = 0; i < parmTypeNames.length; i++) {
- parmNames[i] = "arg" + i;//$NON-NLS-1$
- }
- }
- return parmNames;
- }
-
- /**
- * addParameters - reflect our parms
- */
- protected void addParameters() {
- String[] parmTypeNames = getSourceMethod().getParameterTypes();
- MethodImpl javaMethodTarget = (MethodImpl) getTarget();
- List params = javaMethodTarget.getParametersGen();
- for (int i = 0; i < parmTypeNames.length; i++) {
- params.add(createJavaParameter(javaMethodTarget, null, typeNameFromSignature(parmTypeNames[i])));
- }
- }
-
- protected void clearSource() {
- sourceMethod = null;
- }
-
- protected JavaClass getContainingJavaClass() {
- return ((Method) getTarget()).getContainingJavaClass();
- }
-
- /**
- * getParentType - return the IType which corresponds to our parent JavaClass we're going to do this a lot, so cache it.
- */
- protected IType getParentType() {
- if (parentType == null) {
- Method targetMethod = (Method) getTarget();
- JavaClass parentJavaClass = targetMethod.getContainingJavaClass();
- JavaClassJDOMAdaptor pa = (JavaClassJDOMAdaptor) EcoreUtil.getAdapter(parentJavaClass.eAdapters(), ReadAdaptor.TYPE_KEY);
- if (pa != null)
- parentType = pa.getSourceType();
- }
- return parentType;
- }
-
- /**
- * getParmTypeSignatures - return an array of Strings (in Signature format) for our parameter types For reflection purposes, we can only rely on
- * our UUID, since our parms may not yet be known. see org.eclipse.jdt.core.SourceMapper.convertTypeNamesToSigs()
- */
- protected String[] getParmTypeSignatures() {
- Method javaMethodTarget = (Method) getTarget();
- String[] typeNames = getTypeNamesFromMethodID(((XMIResource) javaMethodTarget.eResource()).getID(javaMethodTarget));
- if (typeNames == null)
- return emptyStringArray;
- int n = typeNames.length;
- if (n == 0)
- return emptyStringArray;
- String[] typeSigs = new String[n];
- try {
- for (int i = 0; i < n; ++i) {
- typeSigs[i] = Signature.createTypeSignature(new String(typeNames[i]), getParentType().isBinary());
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- }
- return typeSigs;
- }
-
- public Object getReflectionSource() {
- return getSourceMethod();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdaptor#hasReflectionSource()
- */
- public boolean hasCachedReflectionSource() {
- return sourceMethod != null;
- }
-
- /*
- * Used by Java Class JDOM adapter to create and set with a source method/
- */
- public void primSetMethod(IMethod method) {
- sourceMethod = method;
- }
- /**
- * getsourceMethod - return the IMethod which describes our implementing method
- */
- public IMethod getSourceMethod() {
- if ((sourceMethod == null) || (!sourceMethod.exists())) {
- try {
- IType parent = this.getParentType();
- if (parent != null) {
- String[] parmNames = this.getParmTypeSignatures();
- sourceMethod = JDOMSearchHelper.searchForMatchingMethod(parent, ((Method) getTarget()).getName(), parmNames);
- }
- } catch (JavaModelException e) {
- //do nothing
- }
- }
- return sourceMethod;
- }
-
- protected IType getType() {
- return getParentType();
- }
-
- protected Map getTypeResolutionCache() {
- Method method = (Method) getTarget();
- if (method != null) {
- JavaClass javaClass = method.getJavaClass();
- if (javaClass != null) {
- JDOMAdaptor classAdaptor = (JDOMAdaptor) retrieveAdaptorFrom(javaClass);
- if (classAdaptor != null)
- return classAdaptor.getTypeResolutionCache();
- }
- }
- return null;
- }
-
- /**
- * getValueIn method comment.
- */
- public Object getValueIn(EObject object, EObject attribute) {
- // At this point, this adapter does not dynamically compute any values,
- // all values are pushed back into the target on the initial call.
- return super.getValueIn(object, attribute);
- }
-
- /**
- * reflectValues - template method, subclasses override to pump values into target. on entry: UUID, name, containing package (and qualified name),
- * and document must be set. Method adaptor: - set modifiers - set name - set return type - add parameters - add exceptions
- */
- public boolean reflectValues() {
- super.reflectValues();
- try {
- TimerTests.basicTest.startCumulativeStep(REFLECT_METHOD);
- if (isResourceLoaded() && getSourceProject() != null && getSourceMethod() != null && sourceMethod.exists()) {
- setModifiers();
- setNaming();
- setReturnType();
- addParameters();
- addExceptions();
- return true;
- }
- } finally {
- TimerTests.basicTest.stopCumulativeStep(REFLECT_METHOD);
- }
- return false;
- }
-
- /**
- * Set the generated flag if @generated is found in the source.
- */
- protected void setGeneratedFlag() {
- Method methodTarget = (Method) getTarget();
- try {
- String source = getSourceMethod().getSource();
- if (source != null) {
- int index = source.indexOf(Method.GENERATED_COMMENT_TAG);
- if (index > 0)
- methodTarget.setIsGenerated(true);
- }
- } catch (JavaModelException npe) {
- //System.out.println(ResourceHandler.getString("Error_Setting_GenFlag_ERROR_", new Object[]
- // {((XMIResource)methodTarget.eResource()).getID(methodTarget), npe.getMessage()})); //$NON-NLS-1$ = "error setting the generated flag on
- // {0}, exception: {1}"
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.internal.java.adapters.IJavaMethodAdapter#reflectGeneratedIfNecessary()
- */
- public boolean reflectGeneratedIfNecessary() {
- if (reflectValuesIfNecessary()) {
- setGeneratedFlag();
- return true;
- }
- return false;
- }
-
- public boolean reflectParamNamesIfNecessary() {
- if (reflectValuesIfNecessary()) {
- String [] paramNames = getParameterNames();
- List param = ((MethodImpl)getTarget()).getParameters();
- for (int i = 0; i < paramNames.length; i++) {
- ((JavaParameter)param.get(i)).setName(paramNames[i]);
- }
- return true;
- }
- return false;
- }
- /**
- * setModifiers - set the attribute values related to modifiers here
- */
- protected void setModifiers() {
- Method methodTarget = (Method) getTarget();
- try {
- methodTarget.setFinal(Flags.isFinal(getSourceMethod().getFlags()));
- methodTarget.setNative(Flags.isNative(getSourceMethod().getFlags()));
- methodTarget.setStatic(Flags.isStatic(getSourceMethod().getFlags()));
- methodTarget.setSynchronized(Flags.isSynchronized(getSourceMethod().getFlags()));
- methodTarget.setConstructor(getSourceMethod().isConstructor());
-
- JavaClass javaClass = getContainingJavaClass();
- //Set abstract
- if (javaClass.getKind().getValue() == TypeKind.INTERFACE)
- methodTarget.setAbstract(true);
- else
- methodTarget.setAbstract(Flags.isAbstract(getSourceMethod().getFlags()));
- // Set visibility
- if (javaClass.getKind().getValue() == TypeKind.INTERFACE || Flags.isPublic(getSourceMethod().getFlags()))
- methodTarget.setJavaVisibility(JavaVisibilityKind.PUBLIC_LITERAL);
- else if (Flags.isPrivate(getSourceMethod().getFlags()))
- methodTarget.setJavaVisibility(JavaVisibilityKind.PRIVATE_LITERAL);
- else if (Flags.isProtected(getSourceMethod().getFlags()))
- methodTarget.setJavaVisibility(JavaVisibilityKind.PROTECTED_LITERAL);
- else
- //Visibility must be package
- methodTarget.setJavaVisibility(JavaVisibilityKind.PACKAGE_LITERAL);
- } catch (JavaModelException npe) {
- System.out
- .println(ResourceHandler
- .getString(
- "Error_Introspecting_Flags_ERROR_", (new Object[] { ((XMIResource) methodTarget.eResource()).getID(methodTarget), npe.getMessage()}))); //$NON-NLS-1$ = "error introspecting flags on {0}, exception: {1}"
- }
- }
-
- /**
- * setNaming - set the naming values here - qualified name must be set first, that is the path to the real Java class - ID - name-based UUID
- */
- protected void setNaming() {
- //
- // naming is currently a no-op since the name and UUID must be set prior to reflection
- // ...and ID is redundant with UUID.
- // javaFieldTarget.setID(parent.getQualifiedName() + "_" + javaFieldTarget.getName());
- }
-
- /**
- * setType - set our return type here
- */
- protected void setReturnType() {
- String typeName = null;
- try {
- typeName = typeNameFromSignature(getSourceMethod().getReturnType());
- } catch (JavaModelException npe) {
- // name stays null and we carry on
- }
- if (typeName != null) {
- Method javaMethodTarget = (Method) getTarget();
- javaMethodTarget.setEType(createJavaClassRef(typeName));
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (10/3/2001 10:08:34 AM)
- *
- * @param newSourceMethod
- * org.eclipse.jdt.core.IMethod
- */
- public void setSourceMethod(org.eclipse.jdt.core.IMethod newSourceMethod) {
- sourceMethod = newSourceMethod;
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaModelListener.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaModelListener.java
deleted file mode 100644
index 37409f725..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaModelListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JavaModelListener.java,v $
- * $Revision: 1.10 $ $Date: 2006/02/08 14:46:25 $
- */
-
-
-/**
- * Insert the type's description here.
- * Creation date: (10/31/2000 1:13:12 PM)
- * @author: Administrator
- * @deprecated Use {@link org.eclipse.jem.workbench.utility.JavaModelListener} instead.
- */
-public abstract class JavaModelListener extends org.eclipse.jem.workbench.utility.JavaModelListener {
-
- /**
- *
- *
- * @since 1.2.0
- */
- public JavaModelListener() {
- super();
- }
-
- /**
- * @param eventsToListen
- *
- * @since 1.2.0
- */
- public JavaModelListener(int eventsToListen) {
- super(eventsToListen);
- }
-
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaReflectionSynchronizer.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaReflectionSynchronizer.java
deleted file mode 100644
index a7d984656..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/adapters/jdom/JavaReflectionSynchronizer.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.adapters.jdom;
-/*
- * $RCSfile: JavaReflectionSynchronizer.java,v $
- * $Revision: 1.13 $ $Date: 2006/02/08 14:46:25 $
- */
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.jdt.core.*;
-
-import org.eclipse.jem.internal.plugin.JavaPlugin;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.workbench.utility.JavaModelListener;
-
-/**
- * Insert the type's description here.
- * Creation date: (11/1/2000 11:42:05 AM)
- * @author: Administrator
- */
-public class JavaReflectionSynchronizer extends JavaModelListener {
-
- protected JavaJDOMAdapterFactory fAdapterFactory;
-
- protected boolean flushedAll = false;
- protected List flushTypes = new ArrayList();
- protected List flushTypePlusInner = new ArrayList();
- protected List notifications = new ArrayList();
- /**
- * JavaReflectionSynchronizer constructor comment.
- */
- public JavaReflectionSynchronizer(JavaJDOMAdapterFactory synchronizee) {
- super();
- fAdapterFactory = synchronizee;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jem.internal.adapters.jdom.JavaModelListener#getJavaProject()
- */
- protected IJavaProject getJavaProject() {
- return getAdapterFactory().getJavaProject();
- }
- /**
- * Tell the reflection factory to flush the passed IType
- */
- protected Notification doFlush(IType element) {
- return getAdapterFactory().flushReflectionNoNotification(element.getFullyQualifiedName());
- }
-
- /*
- * Flush the compilation unit and any inner classes since we don't if they may or may not of changed.
- */
- protected Notification doFlush(ICompilationUnit element) {
- return getAdapterFactory().flushReflectionPlusInnerNoNotification(getFullNameFromElement(element));
- }
-
- protected void flush(IType element) {
- if (!flushTypes.contains(element))
- flushTypes.add(element);
- }
- /*
- * flush the compilation unit. Since we don't know if inner classes may also
- * of been affected, they to will be flushed.
- */
- protected void flush(ICompilationUnit element) {
- if (!flushTypePlusInner.contains(element))
- flushTypePlusInner.add(element);
- }
- protected void flushPackage(String packageName, boolean noFlushIfSourceFound) {
- notifications.addAll(getAdapterFactory().flushPackageNoNotification(packageName, true));
- }
- protected JavaJDOMAdapterFactory getAdapterFactory() {
- return fAdapterFactory;
- }
-
- /**
- * Handle the change for a single element, children will be handled separately.
- *
- */
- protected void processJavaElementChanged(ICompilationUnit element, IJavaElementDelta delta) {
- switch (delta.getKind()) {
- case IJavaElementDelta.CHANGED : {
- // A file save had occurred. It doesn't matter if currently working copy or not.
- // It means something has changed to the file on disk, but don't know what.
- if ((delta.getFlags() & IJavaElementDelta.F_PRIMARY_RESOURCE) != 0) {
- flush(element); // Flush everything, including inner classes.
- } else if ((delta.getFlags() & IJavaElementDelta.F_CONTENT) == 0 &&
- (delta.getFlags() & IJavaElementDelta.F_CHILDREN) != 0) //A type may have been added or removed.
- processChildren(element, delta);
- break;
- }
- case IJavaElementDelta.REMOVED :
- case IJavaElementDelta.ADDED :
- if (!element.isWorkingCopy())
- disAssociateSourcePlusInner(getFullNameFromElement(element));
- break;
- }
- }
-
- /**
- * Handle the change for a single element, children will be handled separately.
- *
- */
- protected void processJavaElementChanged(IJavaProject element, IJavaElementDelta delta) {
- if (isInClasspath(element)) {
- if (delta.getKind() == IJavaElementDelta.REMOVED) {
- if (element.equals(getAdapterFactory().getJavaProject()))
- stopSynchronizer();
- else
- flushAll(); //another dependent project has changed so flush all to be safe
- return;
- } else if (delta.getKind() == IJavaElementDelta.ADDED || isClasspathResourceChange(delta)) {
- flushAll();
- return;
- }
- processChildren(element, delta);
- }
- }
- /**
- * Handle the change for a single element, children will be handled separately.
- */
- protected void processJavaElementChanged(IClassFile element, IJavaElementDelta delta) {
- int kind = delta.getKind();
- if (kind == IJavaElementDelta.REMOVED || kind == IJavaElementDelta.ADDED) {
- // It doesn't matter if totally removed or just moved somewhere else, we will clear out and remove the
- // adapter because there could be a rename which would be a different class.
- // Currently the element is already deleted and there is no way to find the types in the unit to remove.
- // So instead we ask factory to remove all it any that start with it plus for inner classes.
- disAssociateSourcePlusInner(getFullNameFromElement(element));
- return; // Since the classfile was removed we don't need to process the children (actually the children list will be empty
- }
- IJavaElementDelta[] children = delta.getAffectedChildren();
- for (int ii = 0; ii < children.length; ii++) {
- processDelta(children[ii]);
- }
- }
- /**
- * Handle the change for a single element, children will be handled separately.
- *
- */
- protected void processJavaElementChanged(IPackageFragmentRoot element, IJavaElementDelta delta) {
- if (flushedAll)
- return;
- if (isClassPathChange(delta))
- flushAll();
- else
- super.processJavaElementChanged(element, delta);
- }
-
- /*
- * We will force the flushing of all adaptors for the given package name.
- * This is necessary if a type was reflected prior to the package existing or
- * if the package is deleted.
- * @see org.eclipse.jem.internal.adapters.jdom.JavaModelListener#processJavaElementChanged(org.eclipse.jdt.core.IPackageFragment, org.eclipse.jdt.core.IJavaElementDelta)
- */
- protected void processJavaElementChanged(IPackageFragment element, IJavaElementDelta delta) {
- switch (delta.getKind()) {
- case IJavaElementDelta.ADDED : {
- if (delta.getAffectedChildren().length == 0)
- flushPackage(delta.getElement().getElementName(), true);
- break;
- }
- case IJavaElementDelta.REMOVED :{
- if (delta.getAffectedChildren().length == 0)
- getAdapterFactory().flushPackage(delta.getElement().getElementName(), false);
- break;
- }
- default :
- super.processJavaElementChanged(element, delta);
- }
- }
-
- /**
- * Handle the change for a single element, children will be handled separately.
- *
- */
- protected void processJavaElementChanged(IType element, IJavaElementDelta delta) {
- int kind = delta.getKind();
- if (kind == IJavaElementDelta.REMOVED || kind == IJavaElementDelta.ADDED) {
- disAssociateSourcePlusInner(element.getFullyQualifiedName());
- } else {
- flush(element);
- processChildren(element, delta);
- // Note, if a method element or a field was changed, there may be delta.getAffectedChildren()
- // that will have to be processed if we are to update the JavaMethod/JavaField JDOMAdaptor s.
- }
- }
- /**
- * Given that an IType does not exists anymore, assume
- * that the type's name is package.filename (without the .java)
- * If we are wrong (if, then a rare case), we will flush.
- * Next access will induce a reflection attempt.
- * @deprecated This doesn't look like it is ever called. It someone else calls it, please contact development to see if right method to be called.
- */
- protected void processRemoveOrAdd(ICompilationUnit element) {
- disAssociateSource(getFullNameFromElement(element));
- }
- protected String getFullNameFromElement(IJavaElement element) {
- String name = element.getElementName();
- if (element == null || name.length() <= 5 || !name.substring(name.length() - 5).equals(".java")) { //$NON-NLS-1$
- // Should not be here,
- Logger logger = JavaPlugin.getDefault().getLogger();
- if (logger.isLoggingLevel(Level.FINE))
- logger.log("Invalid .java file: " + name, Level.FINE); //$NON-NLS-1$
- // Make a guess, at worst case, nothing will come out of this.
- int index = name.lastIndexOf("."); //$NON-NLS-1$
- if (index >= 0)
- name = name.substring(0, index) + ".java"; // rename the extension to .java //$NON-NLS-1$
- else
- name = name + ".java"; //$NON-NLS-1$
- }
- if (element.getParent().getElementName() == null || element.getParent().getElementName().length() == 0)
- return name.substring(0, name.length() - 5);
- else
- return element.getParent().getElementName() + "." + name.substring(0, name.length() - 5); //$NON-NLS-1$
- }
- /**
- * Stop the synchronizer from listening to any more changes.
- */
- public void stopSynchronizer() {
- JavaCore.removeElementChangedListener(this);
- }
- /**
- * @see org.eclipse.jem.internal.adapters.jdom.JavaModelListener#elementChanged(ElementChangedEvent)
- */
- public void elementChanged(ElementChangedEvent event) {
- try {
- flushTypes.clear();
- flushTypePlusInner.clear();
- notifications.clear();
- super.elementChanged(event);
- flushTypes();
- processNotifications();
- } finally {
- flushedAll = false;
- flushTypes.clear();
- flushTypePlusInner.clear();
- notifications.clear();
- }
- }
- /**
- *
- */
- private void flushTypes() {
- if (!flushTypes.isEmpty()) {
- IType type = null;
- Notification not;
- for (int i = 0; i < flushTypes.size(); i++) {
- type = (IType) flushTypes.get(i);
- not = doFlush(type);
- if (not != null)
- notifications.add(not);
- }
- }
- if (!flushTypePlusInner.isEmpty()) {
- ICompilationUnit unit = null;
- Notification not;
- for (int i = 0; i < flushTypePlusInner.size(); i++) {
- unit = (ICompilationUnit) flushTypePlusInner.get(i);
- not = doFlush(unit);
- if (not != null)
- notifications.add(not);
- }
- }
- }
- /**
- * @param notifications
- */
- private void processNotifications() {
- Notifier notifier;
- Notification not;
- for (int i = 0; i < notifications.size(); i++) {
- not = (Notification) notifications.get(i);
- notifier = (Notifier) not.getNotifier();
- if (notifier != null)
- try {
- notifier.eNotify(not);
- } catch (Exception e) {
- JavaPlugin.getDefault().getLogger().log(e); //catch exceptions so all notifications are processed
- }
- }
- }
- protected void disAssociateSource(String qualifiedName) {
- Notification not = getAdapterFactory().disAssociateSource(qualifiedName, false);
- if (not != null)
- notifications.add(not);
- }
- protected void disAssociateSourcePlusInner(String qualifiedName) {
- Notification not = getAdapterFactory().disAssociateSourcePlusInner(qualifiedName, false);
- if (not != null)
- notifications.add(not);
- }
- protected void flushAll() {
- notifications.addAll(getAdapterFactory().flushAllNoNotification());
- flushedAll = true;
- }
- /**
- * @see org.eclipse.jem.internal.adapters.jdom.JavaModelListener#processChildren(IJavaElement, IJavaElementDelta)
- */
- protected void processChildren(IJavaElement element, IJavaElementDelta delta) {
- if (!flushedAll)
- super.processChildren(element, delta);
- }
- /**
- * @see org.eclipse.jem.internal.adapters.jdom.JavaModelListener#processDelta(IJavaElementDelta)
- */
- public void processDelta(IJavaElementDelta delta) {
- if (!flushedAll)
- super.processDelta(delta);
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/IJavaProjectInfo.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/IJavaProjectInfo.java
deleted file mode 100644
index 7ca310870..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/IJavaProjectInfo.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.plugin;
-
-/**
- * Insert the type's description here.
- * Creation date: (05/07/01 10:06:28 PM)
- * @author: Administrator
- */
-public interface IJavaProjectInfo {
-public String getSourcePath();
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaEMFNature.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaEMFNature.java
deleted file mode 100644
index 82f9c333d..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaEMFNature.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.plugin;
-/*
- * $RCSfile: JavaEMFNature.java,v $ $Revision: 1.15 $ $Date: 2005/09/14 23:30:27 $
- */
-
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory;
-import org.eclipse.jem.internal.java.adapters.*;
-import org.eclipse.jem.java.adapters.JavaXMIFactory;
-import org.eclipse.jem.util.emf.workbench.EMFWorkbenchContextBase;
-import org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jem.workbench.utility.IJavaEMFNature;
-import org.eclipse.jem.workbench.utility.JemProjectUtilities;
-
-public class JavaEMFNature extends EMFNature implements IJavaEMFNature {
-/**
- * JavaMOFNatureRuntime constructor comment.
- */
-public JavaEMFNature() {
- super();
-}
-/**
- * Get a IJavaMOFNatureRuntime that corresponds to the supplied project.
- * @return IJavaMOFNatureRuntime
- * @param project com.ibm.itp.core.api.resources.IProject
- */
-public static JavaEMFNature createRuntime(IProject project) throws CoreException {
- if(!hasRuntime(project))
- if (JavaCore.create(project).exists())
- addNatureToProject(project, IJavaEMFNature.NATURE_ID);
- else
- return null;
-
- return getRuntime(project);
-}
-
-/**
- * Return the nature's ID.
- */
-public java.lang.String getNatureID() {
- return IJavaEMFNature.NATURE_ID;
-}
-/**
- * Return the ID of the plugin that this nature is contained within.
- */
-protected java.lang.String getPluginID() {
- return JavaPlugin.getDefault().getBundle().getSymbolicName();
-}
-/**
- * Get a IJavaMOFNatureRuntime that corresponds to the supplied project.
- * First check for registered natures.
- * @return IJavaMOFNatureRuntime
- * @param project com.ibm.itp.core.api.resources.IProject
- */
-public static JavaEMFNature getRuntime(IProject project) {
- JavaEMFNature nature = null;
- List runtimes = EMFNature.getRegisteredRuntimes(project);
- for (int i=0; i<runtimes.size(); i++) {
- if (runtimes.get(i) instanceof JavaEMFNature)
- nature = (JavaEMFNature) runtimes.get(i);
- }
- if (nature == null)
- nature = primGetRuntime(project);
- return nature;
-}
-/**
- * Return whether or not the project has a runtime created on it.
- * Check for registered natures first.
- * @return boolean
- * @param project com.ibm.itp.core.api.resources.IProject
- */
-public static boolean hasRuntime(IProject project) {
- JavaEMFNature nature = null;
- List runtimes = EMFNature.getRegisteredRuntimes(project);
- for (int i=0; i<runtimes.size(); i++) {
- if (runtimes.get(i) instanceof JavaEMFNature)
- nature = (JavaEMFNature) runtimes.get(i);
- }
- if (nature == null)
- return primHasRuntime(project);
- else
- return true;
-
-}
-/**
- * Get a IJavaMOFNatureRuntime that corresponds to the supplied project.
- * Do not check for other registered types.
- * @return IJavaMOFNatureRuntime
- * @param project com.ibm.itp.core.api.resources.IProject
- */
-public static JavaEMFNature primGetRuntime(IProject project) {
- try {
- return (JavaEMFNature) project.getNature(IJavaEMFNature.NATURE_ID);
- } catch (CoreException e) {
- return null;
- }
-}
-/**
- * Return whether or not the project has a runtime created on it.
- * Do not check for registered nature ids.
- * @return boolean
- * @param project com.ibm.itp.core.api.resources.IProject
- */
-public static boolean primHasRuntime(IProject project) {
- try {
- return project.hasNature(IJavaEMFNature.NATURE_ID);
- } catch (CoreException e) {
- return false;
- }
-}
-
-/**
- * primary contribute to context
- */
-public void primaryContributeToContext(EMFWorkbenchContextBase aNature) {
- if (emfContext == aNature) return;
- emfContext = aNature;
- ResourceSet set = aNature.getResourceSet();
- set.getResourceFactoryRegistry().getProtocolToFactoryMap().put(JavaXMIFactory.SCHEME, JavaXMIFactory.INSTANCE);
- WorkbenchURIConverter conv = (WorkbenchURIConverter) set.getURIConverter();
- configureURIConverter(conv);
- addAdapterFactories(set);
-}
-
-/**
- * secondary contribute to context
- */
-public void secondaryContributeToContext(EMFWorkbenchContextBase aNature) {
- primaryContributeToContext(aNature);
-}
-
-/**
- * Remove the project as a container from the converter and add
- * the source folder.
- */
-protected void configureURIConverter(WorkbenchURIConverter conv) {
- conv.removeInputContainer(getProject());
- conv.addInputContainer(getEMFRoot());
-}
-
-/**
- * Add Adaptor factories to aContext which is now
- * being used for this nature.
- */
-protected void addAdapterFactories(ResourceSet aSet) {
- addJavaReflectionAdapterFactories(aSet);
-}
-
-protected void addJavaReflectionAdapterFactories(ResourceSet aSet) {
- List factories = aSet.getAdapterFactories();
- // The context may already have a JavaReflection adaptor factory, so remove it
- if (!factories.isEmpty()) {
- AdapterFactory factory = EcoreUtil.getAdapterFactory(factories, ReadAdaptor.TYPE_KEY);
- if (factory != null)
- factories.remove(factory);
- }
- // This should maybe be considered a logic error, but we can recover easily
- factories.add(new JavaJDOMAdapterFactory(JemProjectUtilities.getJavaProject(project)));
-}
-
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaPlugin.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaPlugin.java
deleted file mode 100644
index 93ec1e49e..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaPlugin.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.plugin;
-/*
- * $RCSfile: JavaPlugin.java,v $ $Revision: 1.11 $ $Date: 2006/01/13 23:46:52 $
- */
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-import org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory;
-import org.eclipse.jem.internal.java.adapters.jdk.JavaJDKAdapterFactory;
-import org.eclipse.jem.java.util.JavaContext;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.logger.proxyrender.EclipseLogger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-/**
- * This is a top-level class of the java plugin tool.
- *
- * @see AbstractUIPlugin for additional information on UI plugins
- */
-
-public class JavaPlugin extends Plugin {
-
- private static JavaPlugin INSTANCE;
- private Logger logger;
-
- /**
- * Create the Java plugin and cache its default instance
- */
- public JavaPlugin() {
- INSTANCE = this;
- }
-
- public Logger getLogger() {
- if (logger == null)
- logger = EclipseLogger.getEclipseLogger(this);
- return logger;
- }
-
- /**
- * Get the plugin singleton.
- */
- static public JavaPlugin getDefault() {
- return INSTANCE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- JavaContext.setReflectionAdapterFactoryClass(JavaJDOMAdapterFactory.class);
- JEMUtilPlugin.getPluginResourceSet().getAdapterFactories().add(new JavaJDKAdapterFactory());
- }
-
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaProjectInfo.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaProjectInfo.java
deleted file mode 100644
index d6f3c4f7a..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/internal/plugin/JavaProjectInfo.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.internal.plugin;
-/*
- * $RCSfile: JavaProjectInfo.java,v $
- * $Revision: 1.3 $ $Date: 2005/08/24 21:13:53 $
- */
-/**
- * Insert the type's description here.
- * Creation date: (05/07/01 10:09:26 PM)
- * @author: Administrator
- */
-public class JavaProjectInfo implements IJavaProjectInfo {
-
- public final static String DEFAULT_JAVA_OUTPUT_PATH = "bin";//$NON-NLS-1$
- public final static String DEFAULT_SOURCE_PATH = "source";//$NON-NLS-1$
- protected String sourcePath;
-/**
- * JavaProjectInfo constructor comment.
- */
-public JavaProjectInfo() {
- super();
-}
-/**
- * Subclasses should override as necessary
- */
-protected String getDefaultSourcePath() {
- return DEFAULT_SOURCE_PATH;
-}
-/**
- * Get the class path for the reciever. By default ask the template
- * @return java.lang.String
- */
-public String getSourcePath() {
- if (sourcePath == null)
- sourcePath = getDefaultSourcePath();
- return sourcePath;
-}
-public void setSourcePath(String path) {
- sourcePath = path;
-}
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ASTBoundResolver.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ASTBoundResolver.java
deleted file mode 100644
index 37afec733..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ASTBoundResolver.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: ASTBoundResolver.java,v $
- * $Revision: 1.9 $ $Date: 2005/08/24 21:13:53 $
- */
-package org.eclipse.jem.workbench.utility;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jdt.core.dom.*;
-
-import org.eclipse.jem.internal.instantiation.*;
-import org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.InvalidExpressionException;
-
-/**
- * This works on resolved AST nodes. If the nodes had not been resolved, this will return noting.
- *
- * @since 1.0.0
- */
-public class ASTBoundResolver extends ParseTreeCreationFromAST.Resolver {
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.IResolver#resolveName(org.eclipse.jdt.core.dom.Name)
- */
- public PTExpression resolveName(Name name) {
- IBinding binding = name.resolveBinding();
- if (binding == null)
- return null;
-
- switch (binding.getKind()) {
- case IBinding.TYPE:
- String typename = getTypeName((ITypeBinding) binding);
- PTName ptname = InstantiationFactory.eINSTANCE.createPTName();
- ptname.setName(typename);
- return ptname;
- case IBinding.VARIABLE:
- IVariableBinding variableBinding = (IVariableBinding) binding;
- if (variableBinding.isField()) {
- if (Modifier.isStatic(variableBinding.getModifiers())) {
- PTFieldAccess fa = InstantiationFactory.eINSTANCE.createPTFieldAccess();
- // If just a simple name, then it is like this.field, so no receiver. Not sure how to handle this yet.
- if (name.isQualifiedName()) {
- // There are parts before this one. Get them as an expression (either a name, or another field access)
- fa.setReceiver(resolveName(((QualifiedName) name).getQualifier()));
- }
- fa.setField(variableBinding.getName());
- return fa;
- } else {
- throwInvalidExpressionException(MessageFormat.format(WorkbenchUtilityMessages.ASTBoundResolver_CannotHandleLocalField_EXC_, new Object[]{variableBinding.getName()}));
-// push(new PushFieldVariable(variableId, getTypeSignature(declaringTypeBinding), fCounter));
-// push(new PushThis(getEnclosingLevel(node, declaringTypeBinding)));
-// storeInstruction();
- }
- } else {
- throwInvalidExpressionException(MessageFormat.format(WorkbenchUtilityMessages.ASTBoundResolver_CannotHandleLocalVariable_EXC_, new Object[]{variableBinding.getName()}));
-// push(new PushLocalVariable(variableId));
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.IResolver#resolveType(org.eclipse.jdt.core.dom.Type)
- */
- public String resolveType(Type type) {
- ITypeBinding binding = type.resolveBinding();
- return (binding != null) ? getTypeName(binding) : null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.Resolver#resolveType(org.eclipse.jdt.core.dom.Name)
- */
- public String resolveType(Name name) throws InvalidExpressionException {
- ITypeBinding binding = name.resolveTypeBinding();
- return (binding != null) ? getTypeName(binding) : null;
- }
-
- protected String getTypeName(ITypeBinding typeBinding) {
- StringBuffer name;
- if (typeBinding.isArray()) {
- name= new StringBuffer(getTypeName(typeBinding.getElementType()));
- int dimensions= typeBinding.getDimensions();
- for (int i= 0; i < dimensions; i++) {
- name.append("[]"); //$NON-NLS-1$
- }
- return name.toString();
- }
- name= new StringBuffer(typeBinding.getName());
- IPackageBinding packageBinding= typeBinding.getPackage();
- typeBinding= typeBinding.getDeclaringClass();
- while(typeBinding != null) {
- name.insert(0, '$').insert(0, typeBinding.getName());
- typeBinding= typeBinding.getDeclaringClass();
- }
- if (packageBinding != null && !packageBinding.isUnnamed()) {
- name.insert(0, '.').insert(0, packageBinding.getName());
- }
- return name.toString();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.Resolver#resolveThis()
- */
- public PTExpression resolveThis() throws InvalidExpressionException {
- return InstantiationFactory.eINSTANCE.createPTThisLiteral();
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/IJavaEMFNature.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/IJavaEMFNature.java
deleted file mode 100644
index 542783381..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/IJavaEMFNature.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: IJavaEMFNature.java,v $
- * $Revision: 1.1 $ $Date: 2005/09/14 23:30:27 $
- */
-package org.eclipse.jem.workbench.utility;
-
-/**
- * Interface for Java EMF Nature constants.
- *
- * @since 1.2.0
- */
-public interface IJavaEMFNature {
-
- public static final String NATURE_ID = "org.eclipse.jem.workbench.JavaEMFNature"; //$NON-NLS-1$
-
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JavaModelListener.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JavaModelListener.java
deleted file mode 100644
index d794a3e43..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JavaModelListener.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.eclipse.jem.workbench.utility;
-
-/*
- * $RCSfile: JavaModelListener.java,v $ $Revision: 1.2 $ $Date: 2006/02/06 23:49:37 $
- */
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.*;
-
-/**
- * An element change listener to listen for Java Model changes. It breaks the notification up into individual method calls to make it easier to walk
- * the notification tree.
- *
- * @since 1.2.0
- */
-public abstract class JavaModelListener implements IElementChangedListener {
-
- /**
- * Construct with listening only for {@link ElementChangedEvent#POST_CHANGE} events.
- *
- *
- * @since 1.2.0
- */
- public JavaModelListener() {
- this(ElementChangedEvent.POST_CHANGE);
- }
-
- /**
- * Construct with supplying the type of events to listen for.
- *
- * @param eventsToListen
- * or'd together event listening types. See {@link ElementChangedEvent} for the types.
- *
- * @since 1.2.0
- */
- public JavaModelListener(int eventsToListen) {
- JavaCore.addElementChangedListener(this, eventsToListen);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.IElementChangedListener#elementChanged(org.eclipse.jdt.core.ElementChangedEvent)
- */
- public void elementChanged(ElementChangedEvent event) {
- processDelta((IJavaElementDelta) event.getSource());
- }
-
- /**
- * Generally dispatch the children of the delta. Normally this method should not be overridden.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processChildren(IJavaElement element, IJavaElementDelta delta) {
- IJavaElementDelta[] children = delta.getAffectedChildren();
- for (int i = 0; i < children.length; i++) {
- processDelta(children[i]);
- }
- }
-
- /**
- * Source content has changed. The default is to do nothing. Subclasses may override to perform own functions.
- *
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processContentChanged(IJavaElementDelta delta) {
- }
-
- /**
- * Dispatch the java element delta. This method should normally not be overridden. One
- * usage would be to add delta types that are to be processed and dispatched by the
- * subclasses. For example also dispatch on {@link IJavaElement#IMPORT_CONTAINER}. Subclasses
- * should call <code>super.processDelta(IJavaElementDelta)</code> if it is not one they
- * are interested in.
- *
- * @param delta
- *
- * @since 1.2.0
- */
- public void processDelta(IJavaElementDelta delta) {
- IJavaElement element = delta.getElement();
-
- switch (element.getElementType()) {
- case IJavaElement.JAVA_MODEL:
- processJavaElementChanged((IJavaModel) element, delta);
- break;
- case IJavaElement.JAVA_PROJECT:
- processJavaElementChanged((IJavaProject) element, delta);
- break;
- case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- processJavaElementChanged((IPackageFragmentRoot) element, delta);
- break;
- case IJavaElement.PACKAGE_FRAGMENT:
- processJavaElementChanged((IPackageFragment) element, delta);
- break;
- case IJavaElement.COMPILATION_UNIT:
- processJavaElementChanged((ICompilationUnit) element, delta);
- processContentChanged(delta);
- break;
- case IJavaElement.CLASS_FILE:
- processJavaElementChanged((IClassFile) element, delta);
- break;
- case IJavaElement.TYPE:
- processJavaElementChanged((IType) element, delta);
- break;
- // Note: if we are to update the Method/Field adapters, we should process the
- // IJavaElement.METHOD and IJavaElement.FIELD
- }
- }
-
- /**
- * Process the classfile changed event. The default is to do nothing. It will not walk any children of the delta either. Subclasses may override
- * to perform their own functions.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(IClassFile element, IJavaElementDelta delta) {
- }
-
- /**
- * Process the compilation unit changed event. The default is to process the children of the delta. Subclasses may override to perform their own
- * functions. If they wish to walk the children they should then also call
- * <code>super.processJavaElementChanged(ICompilationUnit, IJavaElementDelta)</code>.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(ICompilationUnit element, IJavaElementDelta delta) {
- processChildren(element, delta);
- }
-
- /**
- * Process the java model changed event. The default is to process the children of the delta. Subclasses may override to perform their own
- * functions. If they wish to walk the children they should then also call
- * <code>super.processJavaElementChanged(IJavaModel, IJavaElementDelta)</code>.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(IJavaModel element, IJavaElementDelta delta) {
- processChildren(element, delta);
- }
-
- /**
- * Process the java project changed event. The default is to process the children of the delta. Subclasses may override to perform their own
- * functions. If they wish to walk the children they should then also call
- * <code>super.processJavaElementChanged(IJavaProject, IJavaElementDelta)</code>.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(IJavaProject element, IJavaElementDelta delta) {
- processChildren(element, delta);
- }
-
- /**
- * Process the package fragment changed event. The default is to process the children of the delta. Subclasses may override to perform their own
- * functions. If they wish to walk the children they should then also call
- * <code>super.processJavaElementChanged(IPackageFragment, IJavaElementDelta)</code>.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(IPackageFragment element, IJavaElementDelta delta) {
- processChildren(element, delta);
- }
-
- /**
- * Process the package fragment root changed event. The default is to process the children of the delta. Subclasses may override to perform their
- * own functions. If they wish to walk the children they should then also call
- * <code>super.processJavaElementChanged(IPackageFragmentRoot, IJavaElementDelta)</code>.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(IPackageFragmentRoot element, IJavaElementDelta delta) {
- processChildren(element, delta);
- }
-
- /**
- * Process the IType changed event. The default is to do nothing. It will not walk any children of the delta either. Subclasses may override to
- * perform their own functions.
- *
- * @param element
- * @param delta
- *
- * @since 1.2.0
- */
- protected void processJavaElementChanged(IType element, IJavaElementDelta delta) {
- }
-
- /**
- * Answers whether this element delta is a classpath change. I.e. something added/removed/moved around for the classpath. This should only be
- * called for a delta that is for an {@link IPackageFragmentRoot}. Should be called from an override of
- * {@link #processJavaElementChanged(IPackageFragmentRoot, IJavaElementDelta)}
- *
- * @param delta
- * @return <code>true</code> if it is classpath change or <code>false</code> if not.
- *
- * @since 1.2.0
- */
- protected boolean isClassPathChange(IJavaElementDelta delta) {
- int flags = delta.getFlags();
- return (delta.getKind() == IJavaElementDelta.CHANGED && ((flags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0)
- || ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) || ((flags & IJavaElementDelta.F_REORDER) != 0));
- }
-
- /**
- * Answer whether the change is this is a raw classpath change, or if a file that is in the root of the project was changed that also can mean a
- * raw classpath change. This must only be called for a delta that is for an {@link IJavaProject}.
- * <p>
- * See {@link IJavaElementDelta.#F_CLASSPATH_CHANGED} and {@link #isAlsoClasspathChange(IPath)} for details.
- *
- * @param delta
- * @return
- *
- * @since 1.2.0
- */
- protected boolean isClasspathResourceChange(IJavaElementDelta delta) {
- if ((delta.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0)
- return true;
- IResourceDelta[] resources = delta.getResourceDeltas();
- if (resources == null)
- return false;
- IPath path = null;
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getKind() == IResourceDelta.CHANGED) {
- path = resources[i].getProjectRelativePath();
- if (isAlsoClasspathChange(path))
- return true;
- }
- }
- return false;
- }
-
- /**
- * Answers whether the file specified by the path is one that when changed can result in a classpath change. This is called from
- * {@link #isClasspathResourceChange(IJavaElementDelta)}. The file must be in the root of the project. The default is <code>false</code>.
- * Subclasses may override.
- *
- * @param path
- * @return <code>true</code> if this file being changed would result in a classpath change, <code>false</code> if not.
- *
- * @since 1.2.0
- */
- protected boolean isAlsoClasspathChange(IPath path) {
- return false;
- }
-
- /**
- * Answers whether the given java project is in the classpath (including recursive). This currently will not walk through containers (such as the
- * PDE container). Only through the direct and recursive project references. The java project is determined by subclasses, see
- * {@link #getJavaProject()}.
- *
- * @param javaProject
- * @return <code>true</code> if project is in classpath or <code>false</code> if not.
- *
- * @since 1.2.0
- */
- protected boolean isInClasspath(IJavaProject javaProject) {
- IJavaProject listenerJavaProject = getJavaProject();
- if (javaProject.equals(listenerJavaProject))
- return true;
- return isInClasspath(javaProject, listenerJavaProject, true, new HashSet());
- }
-
- /**
- * The java project for this listener. Subclasses must provide a java project.
- *
- * @return the java project. <code>null</code> is not valid.
- *
- * @since 1.2.0
- */
- protected abstract IJavaProject getJavaProject();
-
- /*
- * test to see if the testProject is in the classpath (including from any referenced projects) of the target project. Keep track of those already
- * visited so as not to visit again. Too late to make private. But it should not be overridden.
- */
- protected boolean isInClasspath(IJavaProject testProject, IJavaProject targetProject, boolean isFirstLevel, Set visited) {
- if (visited.contains(targetProject))
- return false;
- visited.add(targetProject);
- IClasspathEntry[] entries = null;
- try {
- entries = targetProject.getRawClasspath();
- } catch (JavaModelException e) {
- return false;
- }
- IClasspathEntry entry, resEntry;
- IJavaProject proj = null;
- List projects = null;
- for (int i = 0; i < entries.length; i++) {
- entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- resEntry = JavaCore.getResolvedClasspathEntry(entry);
- proj = getJavaProject(entry);
- if (isFirstLevel || resEntry.isExported()) {
- if (proj.equals(testProject))
- return true;
- else {
- if (projects == null)
- projects = new ArrayList();
- projects.add(proj);
- }
- }
- }
- }
- return isInClasspath(testProject, projects, false, visited);
- }
-
- /*
- * See if the testProject is in the classpath of any of the list of projects or in any project that an entry in the list may of visited. Too late
- * to make private. But it should not be overridden.
- */
- protected boolean isInClasspath(IJavaProject testProject, List someJavaProjects, boolean isFirstLevel, Set visited) {
- if (someJavaProjects == null)
- return false;
- int size = someJavaProjects.size();
- IJavaProject javaProj = null;
- for (int i = 0; i < size; i++) {
- javaProj = (IJavaProject) someJavaProjects.get(i);
- return isInClasspath(testProject, javaProj, isFirstLevel, visited);
- }
- return false;
- }
-
- /**
- * Get the java project that classpath entry is for. This should only be called on classpath entries of type {@link IClasspathEntry#CPE_PROJECT}
- *
- * @param entry
- * classpath entry of type {@link IClasspathEntry#CPE_PROJECT}.
- * @return the java project for this entry. The project might not actually exist. That is not verified.
- *
- * @since 1.2.0
- */
- protected IJavaProject getJavaProject(IClasspathEntry entry) {
- IProject proj = getWorkspaceRoot().getProject(entry.getPath().segment(0));
- if (proj != null)
- return JavaCore.create(proj);
- return null;
- }
-
- /**
- * Get the workspace root. A utility method.
- * @return the workspace root.
- *
- * @since 1.2.0
- */
- protected IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JemProjectUtilities.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JemProjectUtilities.java
deleted file mode 100644
index 4fdb59a2e..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/JemProjectUtilities.java
+++ /dev/null
@@ -1,746 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.eclipse.jem.workbench.utility;
-/*
- * $RCSfile: JemProjectUtilities.java,v $ $Revision: 1.10 $ $Date: 2005/09/14 23:30:27 $
- */
-
-import java.net.URL;
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.core.*;
-
-import org.eclipse.jem.internal.plugin.JavaEMFNature;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaRefFactory;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-/**
- * Project Utilities for JEM and Java.
- *
- * @since 1.1.0
- */
-public class JemProjectUtilities extends ProjectUtilities {
-
- private JemProjectUtilities(){
- }
-
- /**
- * The nature id for JEM Nature.
- *
- * @since 1.1.0
- */
- public static final String JEM_EMF_NatureID = IJavaEMFNature.NATURE_ID;
-
- /**
- * Get the EMF nature for JEM for the project.
- * @param project
- * @param addNature <code>true</code> if add the nature to the project if not set. <code>false</code> if don't add nature if not already on project.
- * @return the EMFNature or <code>null</code> if not found and addNature was <code>false</code> or it was not a java project.
- * @throws CoreException
- *
- * @since 1.1.0
- */
- public static EMFNature getJEM_EMF_Nature(IProject project, boolean addNature) throws CoreException {
- return addNature ? JavaEMFNature.createRuntime(project) : JavaEMFNature.getRuntime(project);
- }
-
- /**
- * Get the JavaClass from an IFile.
- * @param aFile
- * @return
- *
- * @since 1.1.0
- */
- public static JavaClass getJavaClass(IFile aFile) {
- if (aFile == null)
- return null;
- IProject project = aFile.getProject();
- List folders = getSourceContainers(project);
- folders.addAll(getLibraryContainers(project));
- IContainer folder = null;
- IPath folderPath, filePath, javaPath;
- filePath = aFile.getProjectRelativePath();
- if (folders != null) {
- for (int i = 0; i < folders.size(); i++) {
- folder = (IContainer) folders.get(i);
- folderPath = folder.getProjectRelativePath();
- int segments = filePath.matchingFirstSegments(folderPath);
- if (segments > 0) {
- javaPath = filePath.removeFirstSegments(segments);
- javaPath = javaPath.removeFileExtension();
- String qualifiedName = javaPath.toString().replace('/', '.');
- return (JavaClass) JavaRefFactory.eINSTANCE.reflectType(qualifiedName, WorkbenchResourceHelperBase.getResourceSet(project));
- }
- }
- }
- return null;
- }
-
- /**
- * Get source containers for the project.
- *
- * @param p
- * project
- * @return list of source containers.
- *
- * @since 1.0.0
- */
- public static List getSourceContainers(IProject p) {
- try {
- List sourceContainers = new ArrayList();
- List sourcePaths = getSourcePaths(p);
- if (sourcePaths != null && !sourcePaths.isEmpty()) {
- for (int i = 0; i < sourcePaths.size(); i++) {
- IPath path = (IPath) sourcePaths.get(i);
- if (path.isEmpty())
- sourceContainers.add(p);
- else
- sourceContainers.add(p.getFolder(path));
- }
- }
- return sourceContainers;
- } catch (IllegalArgumentException ex) {
- return Collections.EMPTY_LIST;
- }
- }
-
- protected static List getSourcePaths(IProject p) {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- IClasspathEntry[] cp = null;
- try {
- cp = javaProj.getRawClasspath();
- } catch (JavaModelException ex) {
- JEMUtilPlugin.getLogger().logError(ex);
- return null;
- }
- List sourcePaths = new ArrayList();
- for (int i = 0; i < cp.length; i++) {
- if (cp[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- sourcePaths.add(cp[i].getPath().removeFirstSegments(1));
- }
- }
- return sourcePaths;
- }
-
- /**
- * Return list of IContainers that are Libraries in the classpath.
- *
- * @param p
- * project
- * @return list of library IContainers.
- *
- * @since 1.0.0
- */
- public static List getLibraryContainers(IProject p) {
- try {
- List libraryContainers = new ArrayList();
- List libraryPaths = getlibraryPaths(p);
- if (libraryPaths != null && !libraryPaths.isEmpty()) {
- for (int i = 0; i < libraryPaths.size(); i++) {
- IPath path = (IPath) libraryPaths.get(i);
- if (path.isEmpty())
- libraryContainers.add(p);
- else
- libraryContainers.add(p.getFolder(path));
- }
- }
- return libraryContainers;
- } catch (IllegalArgumentException ex) {
- return Collections.EMPTY_LIST;
- }
- }
-
-
- protected static List getlibraryPaths(IProject p) {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- IClasspathEntry[] cp = null;
- try {
- cp = javaProj.getRawClasspath();
- } catch (JavaModelException ex) {
- JEMUtilPlugin.getLogger().logError(ex);
- return null;
- }
- List libraryPaths = new ArrayList();
- for (int i = 0; i < cp.length; i++) {
- if (cp[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- libraryPaths.add(cp[i].getPath().removeFirstSegments(1));
- }
- }
- return libraryPaths;
- }
-
- /**
- * Get the java project nature for the given project.
- *
- * @param p
- * project
- * @return the java project nature for the project or <code>null</code> if not a java project.
- *
- * @since 1.0.0
- */
- public static IJavaProject getJavaProject(IProject p) {
- try {
- return (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- return null;
- }
- }
-
- /**
- * Touch classpath. It simply takes the classpath and sets it back in.
- *
- * @param javaProject
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void updateClasspath(IJavaProject javaProject) throws JavaModelException {
- if (javaProject != null)
- javaProject.setRawClasspath(javaProject.getRawClasspath(), new NullProgressMonitor());
- }
-
- /**
- * Return the location of the binary output files for the JavaProject.
- *
- * @param p
- * project
- * @return path to binary output folder or <code>null</code> if not java project or other problem.
- *
- * @since 1.0.0
- */
- public static IPath getJavaProjectOutputLocation(IProject p) {
- try {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- if (!javaProj.isOpen())
- javaProj.open(null);
- return javaProj.getOutputLocation();
- } catch (JavaModelException e) {
- return null;
- }
- }
-
- /**
- * Get the project's binary output container.
- *
- * @param p
- * project
- * @return project's output container or <code>null</code> if not java project or some other error.
- *
- * @since 1.0.0
- */
- public static IContainer getJavaProjectOutputContainer(IProject p) {
- IPath path = getJavaProjectOutputLocation(p);
- if (path == null)
- return null;
- if (path.segmentCount() == 1)
- return p;
- return p.getFolder(path.removeFirstSegments(1));
- }
-
- /**
- * Get the binary output absolute (local file system) path.
- *
- * @param p
- * project
- * @return project's output path or <code>null</code> if not java project or some other error.
- *
- * @since 1.0.0
- */
- public static IPath getJavaProjectOutputAbsoluteLocation(IProject p) {
- IContainer container = getJavaProjectOutputContainer(p);
- if (container != null)
- return container.getLocation();
- return null;
- }
-
- /**
- * Get the JDT JavaModel.
- *
- * @return JDT's JavaModel
- *
- * @since 1.0.0
- */
- public static IJavaModel getJavaModel() {
- return JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
- }
-
- /**
- * Get all source package fragment roots.
- *
- * @param javaProj
- * @return source package fragment roots
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static List getSourcePackageFragmentRoots(IJavaProject javaProj) throws JavaModelException {
- List result = new ArrayList();
- IPackageFragmentRoot[] roots = javaProj.getPackageFragmentRoots();
- for (int i = 0; i < roots.length; i++) {
- IPackageFragmentRoot root = roots[i];
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
- result.add(result);
- }
- return result;
- }
-
- /**
- * Remove the resource from the classpath
- *
- * @param p
- * project
- * @param res
- * resource
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, IResource res) throws JavaModelException {
- IClasspathEntry entry = JavaCore.newLibraryEntry(res.getFullPath(), null, null);
- removeFromJavaClassPath(p, entry);
- }
-
- /**
- * Remove the path from the classpath
- *
- * @param p
- * project
- * @param path
- * path to remove
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, IPath path) throws JavaModelException {
- org.eclipse.core.resources.IFile f = p.getFile(path);
- removeFromJavaClassPath(p, f);
- }
-
- /**
- * Remove the classpath entry from the project's classpath.
- *
- * @param p
- * @param entry
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, IClasspathEntry entry) throws JavaModelException {
- IJavaProject javaProject = null;
- try {
- javaProject = (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- }
- if (javaProject != null) {
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- javaProject.setRawClasspath(primRemoveFromJavaClassPath(classpath, entry), new NullProgressMonitor());
- }
- }
-
- /**
- * Remove the list of entries from the classpath of the project.
- *
- * @param p
- * project
- * @param entries
- * list of IClassPathEntry's
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, List entries) throws JavaModelException {
- IJavaProject javaProject = null;
- try {
- javaProject = (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- }
- if (javaProject != null) {
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- javaProject.setRawClasspath(primRemoveFromJavaClassPath(classpath, entries), new NullProgressMonitor());
- }
- }
-
- protected static IClasspathEntry[] primRemoveFromJavaClassPath(IClasspathEntry[] classpath, IClasspathEntry entry) throws JavaModelException {
- List result = new ArrayList();
- boolean didRemove = false;
- for (int i = 0; i < classpath.length; i++) {
- IClasspathEntry cpEntry = classpath[i];
- if (!entry.getPath().equals(classpath[i].getPath()))
- result.add(cpEntry);
- else
- didRemove = true;
- }
- if (!didRemove)
- return classpath;
- return (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
- }
-
- protected static IClasspathEntry[] primRemoveFromJavaClassPath(IClasspathEntry[] classpath, List entries) throws JavaModelException {
- List arrayList = Arrays.asList(classpath);
- List removeable = new ArrayList(arrayList);
- IClasspathEntry entry;
- boolean didRemove = false;
- int size = entries.size();
- for (int i = 0; i < size; i++) {
- entry = (IClasspathEntry) entries.get(i);
- for (int j = 0; j < classpath.length; j++) {
- IClasspathEntry cpEntry = classpath[j];
- if (entry.getPath().equals(classpath[j].getPath())) {
- if (removeable.remove(cpEntry))
- didRemove = true;
- }
- }
- }
- if (!didRemove)
- return classpath;
- return (IClasspathEntry[]) removeable.toArray(new IClasspathEntry[removeable.size()]);
- }
-
- /**
- * Get the classpath as an array or URL's.
- *
- * @param javaProject
- * @return array of URL's or <code>null</code> if javaProject was <code>null</code>.
- *
- * @since 1.0.0
- */
- public static URL[] getClasspathAsURLArray(IJavaProject javaProject) {
- if (javaProject == null)
- return null;
- Set visited = new HashSet();
- List urls = new ArrayList(20);
- collectClasspathURLs(javaProject, urls, visited, true);
- URL[] result = new URL[urls.size()];
- urls.toArray(result);
- return result;
- }
-
- private static void collectClasspathURLs(IJavaProject javaProject, List urls, Set visited, boolean isFirstProject) {
- if (visited.contains(javaProject))
- return;
- visited.add(javaProject);
- IPath outPath = getJavaProjectOutputAbsoluteLocation(javaProject.getProject());
- outPath = outPath.addTrailingSeparator();
- URL out = ProjectUtilities.createFileURL(outPath);
- urls.add(out);
- IClasspathEntry[] entries = null;
- try {
- entries = javaProject.getResolvedClasspath(true);
- } catch (JavaModelException e) {
- return;
- }
- IClasspathEntry entry;
- for (int i = 0; i < entries.length; i++) {
- entry = entries[i];
- switch (entry.getEntryKind()) {
- case IClasspathEntry.CPE_LIBRARY:
- case IClasspathEntry.CPE_CONTAINER:
- case IClasspathEntry.CPE_VARIABLE:
- collectClasspathEntryURL(entry, urls);
- break;
- case IClasspathEntry.CPE_PROJECT: {
- if (isFirstProject || entry.isExported())
- collectClasspathURLs(getJavaProject(entry), urls, visited, false);
- break;
- }
- }
- }
- }
-
- private static void collectClasspathEntryURL(IClasspathEntry entry, List urls) {
- IPath path = entry.getPath();
- if (null == path.getDevice()) {
- IFile jarFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (jarFile.exists()) {
- path = jarFile.getLocation();
- }
- }
-
- URL url = ProjectUtilities.createFileURL(path);
- if (url != null)
- urls.add(url);
- }
-
-
- private static IJavaProject getJavaProject(IClasspathEntry entry) {
- IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().segment(0));
- if (proj != null)
- return getJavaProject(proj);
- return null;
- }
-
- /**
- * Is this project a binary project.
- * <p>
- * Typically a Java project is considered binary if it does not have a source entry in the classpath.
- *
- * @param project
- * Project to test
- * @return <code>true</code> if project is a binary project.
- */
- public static boolean isBinaryProject(IProject aProject) {
-
- IJavaProject javaProj = getJavaProject(aProject);
- if (javaProj == null)
- return false;
- IClasspathEntry[] entries = null;
- try {
- entries = javaProj.getRawClasspath();
- } catch (JavaModelException jme) {
- return false;
- }
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
- return false;
- }
- return true;
- }
-
- /**
- * Append to java class path.
- * <p>
- * Append a list of IClasspathEntry's to the build path of the passed project. Updated to remove existing occurrences of the passed entries before
- * appending.
- * </p>
- *
- * @param p
- * project
- * @param appendClasspathEntries
- * list of entries
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void appendJavaClassPath(IProject p, List appendClasspathEntries) throws JavaModelException {
- IJavaProject javaProject = null;
- try {
- javaProject = (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- }
- if (javaProject != null) {
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- List newPathList = new ArrayList(classpath.length);
- for (int i = 0; i < classpath.length; i++) {
- IClasspathEntry entry = classpath[i];
- // Skip entries which are in the append list
- if (appendClasspathEntries.indexOf(entry) < 0)
- newPathList.add(entry);
- }
- newPathList.addAll(appendClasspathEntries);
- IClasspathEntry[] newClasspath = (IClasspathEntry[]) newPathList.toArray(new IClasspathEntry[newPathList.size()]);
- javaProject.setRawClasspath(newClasspath, new NullProgressMonitor());
- }
- }
-
- /**
- * Append classpath entry.
- * <p>
- * Append one IClasspathEntry to the build path of the passed project. If a classpath entry having the same path as the parameter already exists,
- * then does nothing.
- * </p>
- *
- * @param p
- * Project
- * @param newEntry
- * Entry
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void appendJavaClassPath(IProject p, IClasspathEntry newEntry) throws JavaModelException {
- IJavaProject javaProject = getJavaProject(p);
- if (javaProject == null)
- return;
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- List newPathList = new ArrayList(classpath.length);
- for (int i = 0; i < classpath.length; i++) {
- IClasspathEntry entry = classpath[i];
- // fix dup class path entry for .JETEmitter project
- // Skip the entry to be added if it already exists
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- if (!entry.getPath().toString().equalsIgnoreCase(newEntry.getPath().toString()))
- newPathList.add(entry);
- else
- return;
- } else {
- if (!entry.getPath().equals(newEntry.getPath()))
- newPathList.add(entry);
- else
- return;
- }
- }
- newPathList.add(newEntry);
- IClasspathEntry[] newClasspath = (IClasspathEntry[]) newPathList.toArray(new IClasspathEntry[newPathList.size()]);
- javaProject.setRawClasspath(newClasspath, new NullProgressMonitor());
- }
-
- /**
- * Return the source path matching the parameter; if the parameter is null, or if the source folder is not on the classpath, return the first
- * source path on the classpath
- *
- * @param p
- * project
- * @param defaultSourceName
- * source folder to find if on classpath, or if <code>null</code> the first folder
- * @return path searched for or <code>null</code> if not java project or some other problem.
- *
- * @since 1.0.0
- */
- public static IPath getSourcePathOrFirst(IProject p, String defaultSourceName) {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- IClasspathEntry[] cp = null;
- try {
- cp = javaProj.getRawClasspath();
- } catch (JavaModelException ex) {
- JEMUtilPlugin.getLogger().logError(ex);
- return null;
- }
- IClasspathEntry firstSource = null;
- IPath defaultSourcePath = null;
- if (defaultSourceName != null)
- defaultSourcePath = ProjectUtilities.createPath(p, defaultSourceName);
- for (int i = 0; i < cp.length; i++) {
- if (cp[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- if (firstSource == null) {
- firstSource = cp[i];
- if (defaultSourcePath == null)
- break;
- }
- if (cp[i].getPath().equals(defaultSourcePath))
- return defaultSourcePath.removeFirstSegments(1);
- }
- }
- if (firstSource == null)
- return null;
- if (firstSource.getPath().segment(0).equals(p.getName()))
- return firstSource.getPath().removeFirstSegments(1);
- return null;
- }
-
- /**
- * Hack to force a reload of the .classpath file
- *
- * @param project
- * project to reload
- * @since 1.0.0
- */
- public static void forceClasspathReload(IProject project) throws JavaModelException {
- IJavaProject javaProj = getJavaProject(project);
- if (javaProj != null) {
- IClasspathEntry[] entries = javaProj.readRawClasspath();
- if (entries != null) {
- IPath output = javaProj.readOutputLocation();
- if (output != null)
- javaProj.setRawClasspath(entries, output, null);
- }
- }
- }
-
- /**
- * Get the paths of all of the local jars in the classpath for the project. It does not recurse into referenced projects.
- *
- * @param proj
- * project to search (should be a java project).
- * @return A list of IPath, where each entry is a project relative path to a JAR contained in the project.
- */
- public static List getLocalJARPathsFromClasspath(IProject proj) {
- IJavaProject javaProj = getJavaProject(proj);
- if (javaProj == null)
- return null;
- IPath projectPath = proj.getFullPath();
- List result = new ArrayList();
- try {
- IClasspathEntry[] entries = javaProj.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IPath path = entry.getPath();
- int segments = path.matchingFirstSegments(projectPath);
- if (segments > 0)
- result.add(path.removeFirstSegments(segments));
- }
- }
- } catch (JavaModelException e) {
- JEMUtilPlugin.getLogger().logError(e);
- }
- return result;
- }
-
-
- /**
- * Return the source folder matching the parameter; if the parameter is null, or if the source folder is not on the classpath, return the first
- * source folder on the classpath
- *
- * @param p
- * project
- * @param defaultSourceName
- * source folder to find if on classpath, or if <code>null</code> the first folder
- * @return container searched for or <code>null</code> if not java project or some other problem.
- *
- * @since 1.0.0
- */
- public static IContainer getSourceFolderOrFirst(IProject p, String defaultSourceName) {
- try {
- IPath sourcePath = getSourcePathOrFirst(p, defaultSourceName);
- if (sourcePath == null)
- return null;
- else if (sourcePath.isEmpty())
- return p;
- else
- return p.getFolder(sourcePath);
- } catch (IllegalArgumentException ex) {
- return null;
- }
- }
-
- /**
- * Returns a list of IFolder that represents each source folder in a java project
- *
- * @deprecated Use {@link #getSourceContainers(IProject)}because the project itself might be a source container
- *
- * @param p
- * project
- * @return
- *
- * @since 1.0.0
- */
- public static List getSourceFolders(IProject p) {
- try {
- List sourceFolders = new ArrayList();
- List sourcePaths = getSourcePaths(p);
- if (sourcePaths != null && !sourcePaths.isEmpty()) {
- for (int i = 0; i < sourcePaths.size(); i++) {
- IPath path = (IPath) sourcePaths.get(i);
- if (!path.isEmpty())
- sourceFolders.add(p.getFolder(path));
- }
- }
- return sourceFolders;
- } catch (IllegalArgumentException ex) {
- return Collections.EMPTY_LIST;
- }
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/NoASTResolver.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/NoASTResolver.java
deleted file mode 100644
index 5c9e1e9b5..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/NoASTResolver.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: NoASTResolver.java,v $
- * $Revision: 1.4 $ $Date: 2005/08/24 21:13:53 $
- */
-package org.eclipse.jem.workbench.utility;
-
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.Type;
-
-import org.eclipse.jem.internal.instantiation.InstantiationFactory;
-import org.eclipse.jem.internal.instantiation.PTExpression;
-import org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.InvalidExpressionException;
-
-
-/**
- * This is used for AST Resolution, but it simply turns Name into PTName. Useful when
- * just creating a parse tree where we know the names are ok and just types.
- * @since 1.0.0
- */
-public class NoASTResolver extends ASTBoundResolver {
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.Resolver#resolveName(org.eclipse.jdt.core.dom.Name)
- */
- public PTExpression resolveName(Name name) throws InvalidExpressionException {
- return InstantiationFactory.eINSTANCE.createPTName(name.toString());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.Resolver#resolveType(org.eclipse.jdt.core.dom.Type)
- */
- public String resolveType(Type type) {
- return type.toString();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.Resolver#resolveType(org.eclipse.jdt.core.dom.Name)
- */
- public String resolveType(Name name) throws InvalidExpressionException {
- return name.toString();
- }
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ParseTreeCreationFromAST.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ParseTreeCreationFromAST.java
deleted file mode 100644
index 9f7360ed3..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/ParseTreeCreationFromAST.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: ParseTreeCreationFromAST.java,v $
- * $Revision: 1.17 $ $Date: 2005/10/28 22:56:44 $
- */
-package org.eclipse.jem.workbench.utility;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.*;
-import org.eclipse.jdt.core.dom.Expression;
-
-import org.eclipse.jem.internal.instantiation.*;
-
-/**
- * Create a parse tree from an AST node.
- * @since 1.0.0
- */
-public class ParseTreeCreationFromAST extends ASTVisitor {
- protected final Resolver resolver;
- protected PTExpression expression; // Each visit (or endvisit) will put into expression the result of the visit if it produced an expression.
-
- /**
- * This is the abstract base class used by ParseTreeCreationFromAST to resolve the types to the appropriate
- * types (e.g. "String" to "java.lang.String").
- *
- * @see org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST
- * @since 1.0.0
- */
- public static abstract class Resolver {
-
- /**
- * Resolve the Name. It can return either a PTName if it is just a classname,
- * or a PTFieldAccess if it resolves to a PTFieldAccess. The PTFieldAccess should
- * be complete. e.g we have class like:
- * <code>
- * package xyz;
- * public class AClass {
- * public java.awt.Rectangle rect;
- * }
- * </code>
- * Then a Name like <code>AClass.rect.x</code> should resolve to:
- *
- * PTFieldAccess:
- * receiver:
- * PTFieldAccess
- * receiver: xyz.AClass
- * field: "rect"
- * field: "x"
- *
- * Actually it can return any valid expression that has a value (i.e. it cannot be a method invocation with a <code>void</code> return type).
- *
- * @param name
- * @return Either a fully-qualified name (as a PTName) or a PTFieldAccess, any other type of expression.
- *
- * @since 1.0.0
- */
- public abstract PTExpression resolveName(Name name) throws InvalidExpressionException;
-
- /**
- * Resolve the type. If it is an array type return it in format "type[][]".
- *
- * @param type
- * @return The type name, including brackets if array type.
- *
- * @since 1.0.0
- */
- public abstract String resolveType(Type type) throws InvalidExpressionException;
-
- /**
- * This is for resolving "this" literal. It should either return a PTThisLiteral, if it
- * can't do resolve, or some PTExpression that can resolve to "this" for evaluation.
- *
- * @return If resolvable, a PTExpression, else a PTThisLiteral if not resolvable.
- * @throws InvalidExpressionException
- *
- * @since 1.0.0
- */
- public abstract PTExpression resolveThis() throws InvalidExpressionException;
-
- /**
- * Resolve the type specified as a Name. It may be a simple name or it may be
- * a qualified name. This is used when we have Name that we know must be a
- * type. This is so that there is no confusion with it possibly being a field or variable
- * that has the same case and spelling as a type name.
- * @param name
- * @return the type name.
- * @throws InvalidExpressionException
- *
- * @since 1.0.0
- */
- public abstract String resolveType(Name name) throws InvalidExpressionException;
-
- /**
- * This is used by the resolver if it can't resolve for some reason. This will throw
- * an invalid expression exception which will be handled by the ParseTreeCreationFromAST.
- *
- * @param msg Message to be put into the exception.
- * @throws InvalidExpressionException
- *
- * @since 1.0.0
- */
- protected final void throwInvalidExpressionException(String msg) throws InvalidExpressionException {
- throw new InvalidExpressionException(msg);
- }
- }
-
- /*
- * When an invalid expression has been found this exception should be thrown. It will
- * be caught at the top and converted into an InvalidExpression and the rest of the parse tree will be
- * thrown away.
- *
- * The message will be a message as to why it is invalid.
- *
- * @since 1.0.0
- */
- protected static class InvalidExpressionException extends IllegalArgumentException {
-
- /**
- * Comment for <code>serialVersionUID</code>
- *
- * @since 1.1.0
- */
- private static final long serialVersionUID = 2429845631915206678L;
-
- /**
- * @param s The message to be used in the final invalid expression.
- *
- * @since 1.0.0
- */
- public InvalidExpressionException(String s) {
- super(s);
- }
- }
-
- /**
- * Construct with the given resolver.
- *
- * @param resolver
- *
- * @since 1.0.0
- */
- public ParseTreeCreationFromAST(Resolver resolver) {
- this.resolver = resolver;
- }
-
- /**
- * Process the AST Expression and return a PTExpression. If any part was invalid, then
- * only an PTInvalidExpression will be returned.
- *
- * @param astExpression
- * @return The PTExpression.
- *
- * @since 1.0.0
- */
- public final PTExpression createExpression(Expression astExpression) {
- try {
- return perform(astExpression);
- } catch (InvalidExpressionException e) {
- // Create a msg that is formed of the exception message and the full init string.
- String msg = MessageFormat.format(WorkbenchUtilityMessages.ParseTreeCreationFromAST_0, new Object[] {e.getLocalizedMessage(), astExpression.toString()});
- PTInvalidExpression exp = InstantiationFactory.eINSTANCE.createPTInvalidExpression();
- exp.setMessage(msg);
- return exp;
- }
- }
-
- /*
- * Visit the AST expression and get the ParseTree Expression.
- * This is used by the individual visits when parsing a tree.
- * It passes to the top method (createExpression), which can
- * handle the InvalidExpressionException.
- *
- * If any visit doesn't return an expression, then an invalid
- * expression exception will be thrown to indicate this. If the
- * incoming expression is <code>null</code>, then return of <code>null</code> is ok because
- * this would be for an optional expression which didn't exist.
- *
- * @return The new ParseTree Expression or <code>null</code> if incoming expression was null.
- *
- * @see createExpression(org.eclipse.jdt.core.dom.Expression)
- * @exception InvalidExpressionException
- * @since 1.0.0
- */
- protected final PTExpression perform(Expression astExpression) {
- if (astExpression != null) {
- expression = null;
- astExpression.accept(this);
- if (expression == null)
- throw new InvalidExpressionException(MessageFormat.format(WorkbenchUtilityMessages.ParseTreeCreationFromAST_ExpressionTooComplicated_EXC_, new Object[] {astExpression.toString()}));
- return expression;
- } else
- return null; // This is ok. It means an optional expression was being processed and the expression didn't exist.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayAccess)
- */
- public boolean visit(ArrayAccess node) {
- PTArrayAccess aa = InstantiationFactory.eINSTANCE.createPTArrayAccess();
- List indexes = aa.getIndexes();
- Expression arrayExp = node;
- while (arrayExp.getNodeType() == ASTNode.ARRAY_ACCESS) {
- // Visit the index to get the index expression.
- ArrayAccess array = (ArrayAccess) arrayExp;
- indexes.add(0, perform(array.getIndex())); // We're trying to create the final expression from inside out, the indexes are created in reverse order.
- arrayExp = array.getArray();
- }
- aa.setArray(perform(arrayExp)); // Final arrayExp is the true expression.
- expression = aa; // Set the return expression for this visit.
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayCreation)
- */
- public boolean visit(ArrayCreation node) {
- PTArrayCreation ac = InstantiationFactory.eINSTANCE.createPTArrayCreation();
- ac.setType(resolver.resolveType(node.getType()));
- List acDims = ac.getDimensions();
- List nDims = node.dimensions();
- int nsize = nDims.size();
- for (int i = 0; i < nsize; i++) {
- acDims.add(perform((Expression) nDims.get(i)));
- }
- ac.setInitializer((PTArrayInitializer) perform(node.getInitializer()));
- expression = ac;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayInitializer)
- */
- public boolean visit(ArrayInitializer node) {
- PTArrayInitializer ai = InstantiationFactory.eINSTANCE.createPTArrayInitializer();
- List exps = node.expressions();
- List aiexps = ai.getExpressions();
- int nexp = exps.size();
- for (int i = 0; i < nexp; i++) {
- aiexps.add(perform((Expression) exps.get(i)));
- }
- expression = ai;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.Assignment)
- */
- public boolean visit(Assignment node) {
- return false; // We can't handle assignment.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.BooleanLiteral)
- */
- public boolean visit(BooleanLiteral node) {
- PTBooleanLiteral bl = InstantiationFactory.eINSTANCE.createPTBooleanLiteral();
- bl.setBooleanValue(node.booleanValue());
- expression = bl;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CastExpression)
- */
- public boolean visit(CastExpression node) {
- PTCastExpression ct = InstantiationFactory.eINSTANCE.createPTCastExpression();
- ct.setType(resolver.resolveType(node.getType()));
- ct.setExpression(perform(node.getExpression()));
- expression = ct;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CharacterLiteral)
- */
- public boolean visit(CharacterLiteral node) {
- PTCharacterLiteral cl = InstantiationFactory.eINSTANCE.createPTCharacterLiteral();
- cl.setEscapedValue(node.getEscapedValue());
- cl.setCharValue(node.charValue());
- expression = cl;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ClassInstanceCreation)
- */
- public boolean visit(ClassInstanceCreation node) {
- if (node.getAnonymousClassDeclaration() != null) {
- PTAnonymousClassDeclaration adecl = InstantiationFactory.eINSTANCE.createPTAnonymousClassDeclaration();
- adecl.setDeclaration(node.toString());
- expression = adecl;
- } else {
- PTClassInstanceCreation cic = InstantiationFactory.eINSTANCE.createPTClassInstanceCreation();
- // If ast level = 2, then you must use getName, but the name needs to be turned into a type
- // so that it can be resolved. If ast level > 2, then it will return a type to be resolved.
- // Note: can't just use resolve name on the name because if a field and a class were spelled
- // the same then the codegen resolver would return an instance ref to the field instead.
- String type = node.getAST().apiLevel() == AST.JLS2 ? resolver.resolveType(node.getName()) : resolver.resolveType(node.getType());
- if (type == null) {
- type = node.getAST().apiLevel() == AST.JLS2 ? node.getName().getFullyQualifiedName() : node.getType().toString();
- }
- cic.setType(type);
- List args = cic.getArguments();
- List nargs = node.arguments();
- int nsize = nargs.size();
- for (int i = 0; i < nsize; i++) {
- args.add(perform((Expression) nargs.get(i)));
- }
- expression = cic;
- }
- return false;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ConditionalExpression)
- */
- public boolean visit(ConditionalExpression node) {
- PTConditionalExpression ce = InstantiationFactory.eINSTANCE.createPTConditionalExpression();
- ce.setCondition(perform(node.getExpression()));
- ce.setTrue(perform(node.getThenExpression()));
- ce.setFalse(perform(node.getElseExpression()));
- expression = ce;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.FieldAccess)
- */
- public boolean visit(FieldAccess node) {
- PTFieldAccess fa = InstantiationFactory.eINSTANCE.createPTFieldAccess();
- fa.setReceiver(perform(node.getExpression()));
- fa.setField(node.getName().getIdentifier());
- expression = fa;
- return false;
- }
-
- private static HashMap infixOperToParseOper;
- private final PTInfixOperator getParseInfix(InfixExpression.Operator operator) {
- if (prefixOperToParseOper == null) {
- infixOperToParseOper = new HashMap(5);
- infixOperToParseOper.put(InfixExpression.Operator.AND, PTInfixOperator.AND_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.CONDITIONAL_AND, PTInfixOperator.CONDITIONAL_AND_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.CONDITIONAL_OR, PTInfixOperator.CONDITIONAL_OR_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.DIVIDE, PTInfixOperator.DIVIDE_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.EQUALS, PTInfixOperator.EQUALS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.GREATER_EQUALS, PTInfixOperator.GREATER_EQUALS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.GREATER, PTInfixOperator.GREATER_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.LEFT_SHIFT, PTInfixOperator.LEFT_SHIFT_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.LESS_EQUALS, PTInfixOperator.LESS_EQUALS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.LESS, PTInfixOperator.LESS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.MINUS, PTInfixOperator.MINUS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.NOT_EQUALS, PTInfixOperator.NOT_EQUALS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.OR, PTInfixOperator.OR_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.PLUS, PTInfixOperator.PLUS_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.REMAINDER, PTInfixOperator.REMAINDER_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.RIGHT_SHIFT_SIGNED, PTInfixOperator.RIGHT_SHIFT_SIGNED_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED, PTInfixOperator.RIGHT_SHIFT_UNSIGNED_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.TIMES, PTInfixOperator.TIMES_LITERAL);
- infixOperToParseOper.put(InfixExpression.Operator.XOR, PTInfixOperator.XOR_LITERAL);
- }
- return (PTInfixOperator) infixOperToParseOper.get(operator);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.InfixExpression)
- */
- public boolean visit(InfixExpression node) {
- PTInfixExpression inf = InstantiationFactory.eINSTANCE.createPTInfixExpression();
- inf.setLeftOperand(perform(node.getLeftOperand()));
- PTInfixOperator inoper = getParseInfix(node.getOperator());
- if (inoper == null) {
- // It is not one we can handle.
- throw new InvalidExpressionException(
- MessageFormat.format(WorkbenchUtilityMessages.ParseTreeCreationFromAST_OperatorTooComplicatedToHandle_EXC_, new Object[] { node.getOperator().toString() }));
- }
- inf.setOperator(inoper);
- inf.setRightOperand(perform(node.getRightOperand()));
- List eops = inf.getExtendedOperands();
- List neops = node.extendedOperands();
- int nsize = neops.size();
- for (int i = 0; i < nsize; i++) {
- eops.add(perform((Expression) neops.get(i)));
- }
- expression = inf;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.InstanceofExpression)
- */
- public boolean visit(InstanceofExpression node) {
- PTInstanceof inof = InstantiationFactory.eINSTANCE.createPTInstanceof();
- inof.setOperand(perform(node.getLeftOperand()));
- inof.setType(resolver.resolveType(node.getRightOperand()));
- expression = inof;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.PostfixExpression)
- */
- public boolean visit(PostfixExpression node) {
- return false; // We can't handle post fix.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodInvocation)
- */
- public boolean visit(MethodInvocation node) {
- PTMethodInvocation mi = InstantiationFactory.eINSTANCE.createPTMethodInvocation();
- mi.setReceiver(perform(node.getExpression()));
- mi.setName(node.getName().getIdentifier());
- List args = mi.getArguments();
- List nargs = node.arguments();
- int nsize = nargs.size();
- for (int i = 0; i < nsize; i++) {
- args.add(perform((Expression) nargs.get(i)));
- }
- expression = mi;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.NullLiteral)
- */
- public boolean visit(NullLiteral node) {
- expression = InstantiationFactory.eINSTANCE.createPTNullLiteral();
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.NumberLiteral)
- */
- public boolean visit(NumberLiteral node) {
- PTNumberLiteral nl = InstantiationFactory.eINSTANCE.createPTNumberLiteral();
- nl.setToken(node.getToken());
- expression = nl;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ParenthesizedExpression)
- */
- public boolean visit(ParenthesizedExpression node) {
- PTParenthesizedExpression pe = InstantiationFactory.eINSTANCE.createPTParenthesizedExpression();
- pe.setExpression(perform(node.getExpression()));
- expression = pe;
- return false;
- }
-
- private static HashMap prefixOperToParseOper;
- private final PTPrefixOperator getParsePrefix(PrefixExpression.Operator operator) {
- if (prefixOperToParseOper == null) {
- prefixOperToParseOper = new HashMap(5);
- prefixOperToParseOper.put(PrefixExpression.Operator.COMPLEMENT, PTPrefixOperator.COMPLEMENT_LITERAL);
- prefixOperToParseOper.put(PrefixExpression.Operator.MINUS, PTPrefixOperator.MINUS_LITERAL);
- prefixOperToParseOper.put(PrefixExpression.Operator.NOT, PTPrefixOperator.NOT_LITERAL);
- prefixOperToParseOper.put(PrefixExpression.Operator.PLUS, PTPrefixOperator.PLUS_LITERAL);
- }
- return (PTPrefixOperator) prefixOperToParseOper.get(operator);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.PrefixExpression)
- */
- public boolean visit(PrefixExpression node) {
- if (node.getOperand().getNodeType() == ASTNode.NUMBER_LITERAL) {
- // For number literals we see if it is a "+" or "-" prefix, and if it is, we simply
- // create a PTNumberLiteral with the operator already in it. It is a simplification.
- // Any other operator we've left alone since those won't be decoded simply by the
- // Number decoder.
- // If not a number literal, then leave alone since needs to be handled as a prefix
- // operation.
- PrefixExpression.Operator operator = node.getOperator();
- if (operator == PrefixExpression.Operator.PLUS || operator == PrefixExpression.Operator.MINUS) {
- PTNumberLiteral nm = InstantiationFactory.eINSTANCE.createPTNumberLiteral();
- nm.setToken(operator.toString() + ((NumberLiteral) node.getOperand()).getToken());
- expression = nm;
- return false;
- }
- }
-
- PTPrefixExpression pe = InstantiationFactory.eINSTANCE.createPTPrefixExpression();
- PTPrefixOperator ptoper = getParsePrefix(node.getOperator());
- if (ptoper == null) {
- // It is not one we can handle.
- throw new InvalidExpressionException(
- MessageFormat.format(WorkbenchUtilityMessages.ParseTreeCreationFromAST_OperatorTooComplicatedToHandle_EXC_, new Object[] { node.getOperator().toString() }));
- }
- pe.setOperator(ptoper);
- pe.setExpression(perform(node.getOperand()));
- expression = pe;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.QualifiedName)
- */
- public boolean visit(QualifiedName node) {
- expression = resolver.resolveName(node);
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SimpleName)
- */
- public boolean visit(SimpleName node) {
- expression = resolver.resolveName(node);
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.StringLiteral)
- */
- public boolean visit(StringLiteral node) {
- PTStringLiteral sl = InstantiationFactory.eINSTANCE.createPTStringLiteral();
- sl.setEscapedValue(node.getEscapedValue());
- sl.setLiteralValue(node.getLiteralValue());
- expression = sl;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperFieldAccess)
- */
- public boolean visit(SuperFieldAccess node) {
- return false; // We can't handle post fix.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperMethodInvocation)
- */
- public boolean visit(SuperMethodInvocation node) {
- return false; // We can't handle post fix.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ThisExpression)
- */
- public boolean visit(ThisExpression node) {
- expression = resolver.resolveThis();
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeLiteral)
- */
- public boolean visit(TypeLiteral node) {
- PTTypeLiteral ptl = InstantiationFactory.eINSTANCE.createPTTypeLiteral();
- ptl.setType(resolver.resolveType(node.getType()));
- expression = ptl;
- return false;
- }
-
-}
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/WorkbenchUtilityMessages.java b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/WorkbenchUtilityMessages.java
deleted file mode 100644
index 13f09e2a5..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/WorkbenchUtilityMessages.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.eclipse.jem.workbench.utility;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class WorkbenchUtilityMessages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.jem.workbench.utility.messages";//$NON-NLS-1$
-
- private WorkbenchUtilityMessages() {
- // Do not instantiate
- }
-
- public static String ParseTreeCreationFromAST_0;
- public static String ParseTreeCreationFromAST_ExpressionTooComplicated_EXC_;
- public static String ParseTreeCreationFromAST_OperatorTooComplicatedToHandle_EXC_;
- public static String ASTBoundResolver_CannotHandleLocalField_EXC_;
- public static String ASTBoundResolver_CannotHandleLocalVariable_EXC_;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, WorkbenchUtilityMessages.class);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/messages.properties b/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/messages.properties
deleted file mode 100644
index 9917f346f..000000000
--- a/plugins/org.eclipse.jem.workbench/workbench/org/eclipse/jem/workbench/utility/messages.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2005 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
-###############################################################################
-ParseTreeCreationFromAST_0 = {0} - {1}
-ParseTreeCreationFromAST_ExpressionTooComplicated_EXC_ = IWAV0177E Expression "{0}" is too complicated.
-ParseTreeCreationFromAST_OperatorTooComplicatedToHandle_EXC_ = IWAV0179E Operator "{0}" is too complicated to handle.
-ASTBoundResolver_CannotHandleLocalField_EXC_=Cannot handle local field access of "{0}"
-ASTBoundResolver_CannotHandleLocalVariable_EXC_=Cannot handle local variable access of "{0}"

Back to the top