// newState.record(sourceLocator, qualifiedRefs, simpleRefs, mainTypeName, definedTypeNames);
//}
-protected IContainer createFolder(IPath packagePath, IContainer outputFolder) throws CoreException {
- if (packagePath.isEmpty()) return outputFolder;
- IFolder folder = outputFolder.getFolder(packagePath);
- if (!folder.exists()) {
- createFolder(packagePath.removeLastSegments(1), outputFolder);
- folder.create(true, true, null);
- folder.setDerived(true);
- }
- return folder;
-}
+//protected IContainer createFolder(IPath packagePath, IContainer outputFolder) throws CoreException {
+// if (packagePath.isEmpty()) return outputFolder;
+// IFolder folder = outputFolder.getFolder(packagePath);
+// if (!folder.exists()) {
+// createFolder(packagePath.removeLastSegments(1), outputFolder);
+// folder.create(true, true, null);
+// folder.setDerived(true);
+// }
+// return folder;
+//}
protected RuntimeException internalException(CoreException t) {
ImageBuilderInternalException imageBuilderException = new ImageBuilderInternalException(t);
IPath folderPath = resource.getFullPath();
if (isAlsoProject && isExcludedFromProject(folderPath)) return false; // the sourceFolder == project
- createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
+// createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
}
return true;
}
IPath folderPath = resource.getFullPath();
if (isAlsoProject && isExcludedFromProject(folderPath)) return false; // the sourceFolder == project
- createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
+// createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
}
return true;
}
removedPackagePath).exists()) {
// only a package fragment was removed, same as removing
// multiple source files
- createFolder(removedPackagePath, md.binaryFolder); // ensure
+// createFolder(removedPackagePath, md.binaryFolder); // ensure
// package
// exists
// in the
// }
if (PHPBuilder.DEBUG)
System.out.println("Copying changed file " + resourcePath); //$NON-NLS-1$
- createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure
+ // createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure
// package
// exists
// in
PHPEditorPreferencePage.multiLineComment=Multi-line comment
PHPEditorPreferencePage.singleLineComment=Single-line comment
-PHPEditorPreferencePage.tags=PHP tags
+PHPEditorPreferencePage.tags=PHP/Smarty tags
PHPEditorPreferencePage.keywords=Keywords
-PHPEditorPreferencePage.functionNames=Predefined function names
+PHPEditorPreferencePage.functionNames=Predefined function names
PHPEditorPreferencePage.variables=Variables
PHPEditorPreferencePage.constants=Constants
PHPEditorPreferencePage.types=Types
public class JavaTextTools {
private static PHPPartitionScanner HTML_PARTITION_SCANNER = null;
-
private static PHPPartitionScanner PHP_PARTITION_SCANNER = null;
private static PHPPartitionScanner SMARTY_PARTITION_SCANNER = null;
* @see org.phpeclipse.phpdt.ui.PreferenceConstants#getPreferenceStore()
* @since 2.0
*/
- public JavaTextTools(IPreferenceStore store) {
- fPreferenceStore = store;
- fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
-
- fColorManager = new JavaColorManager();
- fCodeScanner = new PHPCodeScanner(fColorManager, store);
- fMultilineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_MULTILINE_COMMENT);
- fSinglelineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_SINGLELINE_COMMENT);
- fStringScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_STRING);
- fPHPDocScanner = new PHPDocCodeScanner(fColorManager, store);
- fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
- fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
- fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
-// fPartitionScanner = new FastJavaPartitionScanner();
- fPartitionScanner = new PHPPartitionScanner();
- }
-
+// public JavaTextTools(IPreferenceStore store) {
+// fPreferenceStore = store;
+// fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
+//
+// fColorManager = new JavaColorManager();
+// fCodeScanner = new PHPCodeScanner(fColorManager, store);
+// fMultilineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_MULTILINE_COMMENT);
+// fSinglelineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_SINGLELINE_COMMENT);
+// fStringScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_STRING);
+// fPHPDocScanner = new PHPDocCodeScanner(fColorManager, store);
+// fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
+// fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
+// fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
+//// fPartitionScanner = new FastJavaPartitionScanner();
+// fPartitionScanner = new PHPPartitionScanner();
+// }
+ /**
+ * Creates a new Java text tools collection.
+ * @param store the preference store to initialize the text tools. The text tool
+ * instance installs a listener on the passed preference store to adapt itself to
+ * changes in the preference store. In general <code>PreferenceConstants.
+ * getPreferenceStore()</code> should be used to initialize the text tools.
+ * @param coreStore optional preference store to initialize the text tools. The text tool
+ * instance installs a listener on the passed preference store to adapt itself to
+ * changes in the preference store.
+ * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore()
+ * @since 2.1
+ */
+ public JavaTextTools(IPreferenceStore store, Preferences coreStore) {
+ this(store, coreStore, true);
+ }
/**
* Creates a new Java text tools collection.
*
fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener);
fColorManager = new JavaColorManager(autoDisposeOnDisplayDispose);
+
fCodeScanner = new PHPCodeScanner(fColorManager, store);
fMultilineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_MULTILINE_COMMENT);
fSinglelineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_SINGLELINE_COMMENT);
fStringScanner.adaptToPreferenceChange(event);
if (fPHPDocScanner.affectsBehavior(event))
fPHPDocScanner.adaptToPreferenceChange(event);
+ if (fHTMLScanner.affectsBehavior(event))
+ fHTMLScanner.adaptToPreferenceChange(event);
+ if (fSmartyScanner.affectsBehavior(event))
+ fSmartyScanner.adaptToPreferenceChange(event);
+ if (fSmartyDocScanner.affectsBehavior(event))
+ fSmartyDocScanner.adaptToPreferenceChange(event);
}
/**
* @since 3.0
*/
public static final String PHP_OPERATOR = "__php_operator"; //$NON-NLS-1$
+
/**
* A named preference that holds the color used to render operators and brackets.
* <p>
return fProblemMarkerManager;
}
+// public synchronized JavaTextTools getJavaTextTools() {
+// if (fJavaTextTools == null)
+// fJavaTextTools = new JavaTextTools(getPreferenceStore());
+// return fJavaTextTools;
+// }
public synchronized JavaTextTools getJavaTextTools() {
- if (fJavaTextTools == null)
- fJavaTextTools = new JavaTextTools(getPreferenceStore());
- return fJavaTextTools;
- }
-
+ if (fJavaTextTools == null)
+ fJavaTextTools= new JavaTextTools(getPreferenceStore(), JavaCore.getPlugin().getPluginPreferences());
+ return fJavaTextTools;
+}
public IFile getLastEditorFile() {
return fLastEditorFile;
}
import java.util.ArrayList;
import java.util.List;
+import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
+import net.sourceforge.phpdt.ui.text.IColorManager;
+import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.phpeditor.util.HTMLWordDetector;
import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WhitespaceRule;
/**
* A HTML code scanner.
*/
-public class HTMLCodeScanner extends RuleBasedScanner {
-
- private static String[] fgKeywords = {
- };
-
- private static String[] fgTypes = {
- };
-
- private IToken keyword;
-
+public class HTMLCodeScanner extends AbstractJavaScanner {
+
+// private static String[] fgKeywords = {
+// };
+//
+// private static String[] fgTypes = {
+// };
+
+// private IToken keyword;
+ private static String[] fgTokenProperties =
+ {
+ IPreferenceConstants.PHP_MULTILINE_COMMENT,
+ IPreferenceConstants.PHP_SINGLELINE_COMMENT,
+ IPreferenceConstants.PHP_TAG,
+ IPreferenceConstants.PHP_KEYWORD,
+ IPreferenceConstants.PHP_FUNCTIONNAME,
+ IPreferenceConstants.PHP_VARIABLE,
+ IPreferenceConstants.PHP_STRING,
+ IPreferenceConstants.PHP_TYPE,
+ IPreferenceConstants.PHP_CONSTANT,
+ IPreferenceConstants.PHP_DEFAULT,
+ IPreferenceConstants.PHP_OPERATOR,
+ IPreferenceConstants.PHP_KEYWORD_RETURN};
+ /*
+ * @see AbstractJavaScanner#getTokenProperties()
+ */
+ protected String[] getTokenProperties() {
+ return fgTokenProperties;
+ }
private class HTMLWordRule extends WordRule {
private StringBuffer fBuffer = new StringBuffer();
scanner.unread();
if (tagBegin) {
- return keyword;
+ return getToken(IPreferenceConstants.PHP_KEYWORD);
}
IToken token = (IToken) fWords.get(fBuffer.toString());
if (token != null)
/**
* Creates a Java code scanner
*/
- public HTMLCodeScanner(JavaColorManager provider, IPreferenceStore store) {
+ public HTMLCodeScanner(IColorManager manager, IPreferenceStore store) {
+ super(manager, store);
+ initialize();
+ }
+
+ /*
+ * @see AbstractJavaScanner#createRules()
+ */
+ protected List createRules() {
+ List rules = new ArrayList();
- keyword = new Token(new TextAttribute(provider.getColor(PHPColorProvider.KEYWORD)));
- IToken type = new Token(new TextAttribute(provider.getColor(PHPColorProvider.FUNCTION_NAME)));
- IToken string = new Token(new TextAttribute(provider.getColor(PHPColorProvider.STRING)));
- IToken comment = new Token(new TextAttribute(provider.getColor(PHPColorProvider.SINGLE_LINE_COMMENT)));
- IToken multi_comment = new Token(new TextAttribute(provider.getColor(PHPColorProvider.MULTI_LINE_COMMENT)));
- IToken other = new Token(new TextAttribute(provider.getColor(PHPColorProvider.DEFAULT)));
+// keyword = new Token(new TextAttribute(provider.getColor(PHPColorProvider.KEYWORD)));
+// IToken type = new Token(new TextAttribute(provider.getColor(PHPColorProvider.FUNCTION_NAME)));
+// IToken string = new Token(new TextAttribute(provider.getColor(PHPColorProvider.STRING)));
+// IToken comment = new Token(new TextAttribute(provider.getColor(PHPColorProvider.SINGLE_LINE_COMMENT)));
+// IToken multi_comment = new Token(new TextAttribute(provider.getColor(PHPColorProvider.MULTI_LINE_COMMENT)));
+// IToken other = new Token(new TextAttribute(provider.getColor(PHPColorProvider.DEFAULT)));
- //variable = new Token(new TextAttribute(provider.getColor(PHPColorProvider.VARIABLE)));
+ //variable = new Token(new TextAttribute(provider.getColor(PHPColorProvider.VARIABLE)));
- List rules = new ArrayList();
- // Add rule for single line comments.
- //rules.add(new EndOfLineRule("//", comment)); //$NON-NLS-1$
- //rules.add(new EndOfLineRule("#", comment));
-
- // Add rule for strings and character constants.
- rules.add(new SingleLineRule("\"", "\"", string)); //$NON-NLS-2$ //$NON-NLS-1$
- // rules.add(new SingleLineRule("'", "'", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-
- // rules.add(new SingleLineRule("//", "//", php_comment));
- // rules.add(new MultiLineRule("/*", "*/", multi_comment));
-
- // Add generic whitespace rule.
- rules.add(new WhitespaceRule(new PHPWhitespaceDetector()));
-
- // Add word rule for keywords, types, and constants.
- HTMLWordRule wordRule = new HTMLWordRule(new HTMLWordDetector(), other);
- for (int i = 0; i < fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], keyword);
- for (int i = 0; i < fgTypes.length; i++)
- wordRule.addWord(fgTypes[i], type);
- // for (int i = 0; i < fgConstants.length; i++)
- // wordRule.addWord(fgConstants[i], type);
- rules.add(wordRule);
-
- IRule[] result = new IRule[rules.size()];
- rules.toArray(result);
- setRules(result);
- }
+ // Add rule for single line comments.
+ //rules.add(new EndOfLineRule("//", comment)); //$NON-NLS-1$
+ //rules.add(new EndOfLineRule("#", comment));
+ // Add rule for strings and character constants.
+ rules.add(new SingleLineRule("\"", "\"", getToken(IPreferenceConstants.PHP_STRING))); //$NON-NLS-2$ //$NON-NLS-1$
+ // rules.add(new SingleLineRule("'", "'", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
+
+ // rules.add(new SingleLineRule("//", "//", php_comment));
+ // rules.add(new MultiLineRule("/*", "*/", multi_comment));
+
+ // Add generic whitespace rule.
+ rules.add(new WhitespaceRule(new PHPWhitespaceDetector()));
+
+ // Add word rule for keywords, types, and constants.
+ HTMLWordRule wordRule = new HTMLWordRule(new HTMLWordDetector(), getToken(IPreferenceConstants.PHP_DEFAULT));
+// for (int i = 0; i < fgKeywords.length; i++)
+// wordRule.addWord(fgKeywords[i], keyword);
+// for (int i = 0; i < fgTypes.length; i++)
+// wordRule.addWord(fgTypes[i], type);
+ rules.add(wordRule);
+
+ setDefaultReturnToken(getToken(IPreferenceConstants.PHP_DEFAULT));
+return rules;
+ }
}
rules.add(wordRule);
+ setDefaultReturnToken(getToken(IPreferenceConstants.PHP_DEFAULT));
return rules;
}
}
{
IPreferenceConstants.PHP_MULTILINE_COMMENT,
IPreferenceConstants.PHP_SINGLELINE_COMMENT,
- IPreferenceConstants.PHP_TAG,
+ IPreferenceConstants.PHP_TAG,
IPreferenceConstants.PHP_KEYWORD,
IPreferenceConstants.PHP_FUNCTIONNAME,
IPreferenceConstants.PHP_VARIABLE,
// wordRule.addWord(elbuffer.getName(), constant);
// }
rules.add(wordRule);
-
+ setDefaultReturnToken(getToken(IPreferenceConstants.PHP_DEFAULT));
return rules;
}
}