naturePHP.name=PHP Project
phpProblemName=PHP Problem
transientPHPProblemName=Transient PHP Problem
-phpTaskName=Java Task
+phpTaskName=PHP Task
viewCategoryName=PHP
phpEditorTextHoversName=PHP Editor Text Hovers
propertyPagePHPProject.name=PHP Project Properties
+todoPageName=PHP Task Tags
+
+todoTaskPrefName=Task Tags
+templatePageName=Templates
+
#
# Extension point names
#
<attribute name="arguments"/>
</extension>
-<!-- Java tasks -->
+<!-- PHP tasks -->
<extension id="task" name="%phpTaskName" point="org.eclipse.core.resources.markers">
<super type="org.eclipse.core.resources.taskmarker"/>
</filter>
</page>
<page
+ objectClass="org.eclipse.core.resources.IProject"
+ name="%todoPageName"
+ class="net.sourceforge.phpdt.internal.ui.preferences.TodoTaskPropertyPage"
+ id="net.sourceforge.phpdt.ui.propertyPages.TodoTaskPropertyPage">
+ <filter
+ name="nature"
+ value="net.sourceforge.phpeclipse.phpnature">
+ </filter>
+ </page>
+ <page
+ objectClass="net.sourceforge.phpdt.core.IJavaProject"
+ name="%todoPageName"
+ class="net.sourceforge.phpdt.internal.ui.preferences.TodoTaskPropertyPage"
+ id="net.sourceforge.phpdt.ui.propertyPages.TodoTaskPropertyPage">
+ <filter
+ name="nature"
+ value="net.sourceforge.phpeclipse.phpnature">
+ </filter>
+ </page>
+ <page
objectClass="org.eclipse.core.resources.IFile"
name="PHP File Settings"
class="net.sourceforge.phpeclipse.preferences.PHPPreviewProjectPreferences"
id="net.sourceforge.phpeclipse.preference.PHPOutlinePreferencePage">
</page>
<page
- name="Templates"
+ name="%todoTaskPrefName"
+ category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"
+ class="net.sourceforge.phpdt.internal.ui.preferences.TodoTaskPreferencePage"
+ id="net.sourceforge.phpeclipse.preference.TodoTaskPreferencePage">
+ </page>
+ <page
+ name="%templatePageName"
category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"
class="net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage"
id="net.sourceforge.phpeclipse.preference.TemplatePreferencePage">
* @see JavaCore#getDefaultOptions
* @since 2.1
*/
-// Map getOptions(boolean inheritJavaCoreOptions);
+ Map getOptions(boolean inheritJavaCoreOptions);
/**
* Returns the default output location for this project as a workspace-
// public static HashSet OptionNames = new HashSet(20);
/**
* The plug-in identifier of the Java core support
- * (value <code>"org.phpeclipse.phpdt.core"</code>).
+ * (value <code>"net.sourceforge.phpeclipse"</code>)
*/
// public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; //$NON-NLS-1$
public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.env.INameEnvironment;
import net.sourceforge.phpdt.internal.compiler.env.ISourceType;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.ITypeRequestor;
import net.sourceforge.phpdt.internal.compiler.lookup.LookupEnvironment;
import net.sourceforge.phpdt.internal.compiler.lookup.PackageBinding;
public class Compiler implements ITypeRequestor, ProblemSeverities {
public UnitParser parser;
public ICompilerRequestor requestor;
- // public CompilerOptions options;
+ public CompilerOptions options;
public ProblemReporter problemReporter;
// management of unit to be processed
//public CompilationUnitResult currentCompilationUnitResult;
// name lookup
public LookupEnvironment lookupEnvironment;
// ONCE STABILIZED, THESE SHOULD RETURN TO A FINAL FIELD
- public static boolean DEBUG = false;
+ public static boolean DEBUG = true;
public int parseThreshold = -1;
// number of initial units parsed at once (-1: none)
/*
* problems, the compiler will gather them all and hand them back
* as part of the compilation unit result.
*/
- public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
- // Map settings,
- final ICompilerRequestor requestor, IProblemFactory problemFactory) {
+ public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
+ Map settings, final ICompilerRequestor requestor,
+ IProblemFactory problemFactory) {
// create a problem handler given a handling policy
- // this.options = new CompilerOptions(settings);
+ this.options = new CompilerOptions(settings);
// wrap requestor in DebugRequestor if one is specified
// if(DebugRequestor == null) {
this.requestor = requestor;
// }
// };
// }
- this.problemReporter = new ProblemReporter(policy, problemFactory);//this.options,
- // problemFactory);
+ this.problemReporter = new ProblemReporter(policy, this.options,
+ problemFactory);
this.lookupEnvironment = new LookupEnvironment(this, problemReporter,
environment); //options, problemReporter, environment);
this.parser = new UnitParser(problemReporter);
* literals or leave them as they are in the source. If you put
* true, "Hello" + " world" will be converted to "Hello world".
*/
- public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
- // Map settings,
- final ICompilerRequestor requestor, IProblemFactory problemFactory,
- boolean parseLiteralExpressionsAsConstants) {
+ public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
+ Map settings, final ICompilerRequestor requestor,
+ IProblemFactory problemFactory, boolean parseLiteralExpressionsAsConstants) {
// create a problem handler given a handling policy
- // this.options = new CompilerOptions(settings);
+ this.options = new CompilerOptions(settings);
// wrap requestor in DebugRequestor if one is specified
// if(DebugRequestor == null) {
this.requestor = requestor;
// }
// };
// }
- this.problemReporter = new ProblemReporter(policy, problemFactory);//,
- // this.options,
- // problemFactory);
+ this.problemReporter = new ProblemReporter(policy, this.options,
+ problemFactory);
this.lookupEnvironment = new LookupEnvironment(this, problemReporter,
environment);//options, problemReporter, environment);
this.parser = new UnitParser(problemReporter);
// Switch the current policy and compilation result for this unit to the
// requested one.
CompilationResult unitResult = new CompilationResult(sourceUnit,
- totalUnits, totalUnits, 10); //this.options.maxProblemsPerUnit);
+ totalUnits, totalUnits, this.options.maxProblemsPerUnit);
try {
// diet parsing for large collection of unit
CompilationUnitDeclaration parsedUnit;
} else {
parsedUnit = parser.dietParse(sourceUnit, unitResult);
}
- // if (options.verbose) {
- // String count = String.valueOf(totalUnits + 1);
- // System.out.println(
- // Util.bind(
- // "compilation.request" , //$NON-NLS-1$
- // new String[] {
- // count,
- // count,
- // new String(sourceUnit.getFileName())}));
- // }
+ if (options.verbose) {
+ String count = String.valueOf(totalUnits + 1);
+ System.out.println(Util.bind("compilation.request", //$NON-NLS-1$
+ new String[]{count, count, new String(sourceUnit.getFileName())}));
+ }
// initial type binding creation
lookupEnvironment.buildTypeBindings(parsedUnit);
this.addCompilationUnit(sourceUnit, parsedUnit);
for (int i = 0; i < maxUnits; i++) {
CompilationUnitDeclaration parsedUnit;
CompilationResult unitResult = new CompilationResult(sourceUnits[i], i,
- maxUnits, 10);//, this.options.maxProblemsPerUnit);
+ maxUnits, this.options.maxProblemsPerUnit);
try {
// diet parsing for large collection of units
if (totalUnits < parseThreshold) {
} else {
parsedUnit = parser.dietParse(sourceUnits[i], unitResult);
}
- // if (options.verbose) {
- // System.out.println(
- // Util.bind(
- // "compilation.request" , //$NON-NLS-1$
- // new String[] {
- // String.valueOf(i + 1),
- // String.valueOf(maxUnits),
- // new String(sourceUnits[i].getFileName())}));
- // }
+ if (options.verbose) {
+ System.out.println(Util.bind("compilation.request", //$NON-NLS-1$
+ new String[]{String.valueOf(i + 1), String.valueOf(maxUnits),
+ new String(sourceUnits[i].getFileName())}));
+ }
// initial type binding creation
-// lookupEnvironment.buildTypeBindings(parsedUnit);
+ // lookupEnvironment.buildTypeBindings(parsedUnit);
this.addCompilationUnit(sourceUnits[i], parsedUnit);
//} catch (AbortCompilationUnit e) {
//requestor.acceptResult(unitResult.tagAsAccepted());
for (; i < totalUnits; i++) {
unit = unitsToProcess[i];
try {
- // if (options.verbose)
- // System.out.println(
- // Util.bind(
- // "compilation.process" , //$NON-NLS-1$
- // new String[] {
- // String.valueOf(i + 1),
- // String.valueOf(totalUnits),
- // new String(unitsToProcess[i].getFileName())}));
+ if (options.verbose)
+ System.out.println(Util.bind("compilation.process", //$NON-NLS-1$
+ new String[]{String.valueOf(i + 1), String.valueOf(totalUnits),
+ new String(unitsToProcess[i].getFileName())}));
process(unit, i);
} finally {
// cleanup compilation unit result
unit.cleanUp();
- // if (options.verbose)
- // System.out.println(Util.bind("compilation.done", //$NON-NLS-1$
- // new String[] {
- // String.valueOf(i + 1),
- // String.valueOf(totalUnits),
- // new String(unitsToProcess[i].getFileName())}));
+ if (options.verbose)
+ System.out.println(Util.bind("compilation.done", //$NON-NLS-1$
+ new String[]{String.valueOf(i + 1), String.valueOf(totalUnits),
+ new String(unitsToProcess[i].getFileName())}));
}
unitsToProcess[i] = null; // release reference to processed unit
- // declaration
+ // declaration
requestor.acceptResult(unit.compilationResult.tagAsAccepted());
}
- } catch (AbortCompilation e) {
+ } catch (AbortCompilation e) {
this.handleInternalException(e, unit);
} catch (Error e) {
this.handleInternalException(e, unit, null);
*/
public void process(CompilationUnitDeclaration unit, int i) {
getMethodBodies(unit, i);
- // fault in fields & methods
- if (unit.scope != null)
+ // fault in fields & methods
+ if (unit.scope != null)
unit.scope.faultInTypes();
// verify inherited methods
-// if (unit.scope != null)
-// unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
+ // if (unit.scope != null)
+ // unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
// type checking
unit.resolve();
// flow analysis
// if (generateCode) unit.generateCode();
}
unitsToProcess[0] = null; // release reference to processed unit
- // declaration
+ // declaration
requestor.acceptResult(unit.compilationResult.tagAsAccepted());
return unit;
} catch (AbortCompilation e) {
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.parser.UnitParser;
import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
public DocumentElementParser(
final IDocumentElementRequestor requestor,
- IProblemFactory problemFactory) {
-// CompilerOptions options) {
+ IProblemFactory problemFactory,
+ CompilerOptions options) {
super(new ProblemReporter(
DefaultErrorHandlingPolicies.exitAfterAllProblems(),
-// options,
+ options,
problemFactory) {
public void record(IProblem problem, CompilationResult unitResult) {
requestor.acceptProblem(problem);
// options.sourceLevel >= CompilerOptions.JDK1_4);
this.requestor = requestor;
intArrayStack = new int[30][];
-// this.options = options;
+ this.options = options;
}
/**
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.env.ISourceType;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
public SourceElementParser(
final ISourceElementRequestor requestor,
- IProblemFactory problemFactory) {
-// CompilerOptions options) {
+ IProblemFactory problemFactory,
+ CompilerOptions options) {
// we want to notify all syntax error with the acceptProblem API
// To do so, we define the record method of the ProblemReporter
super(
new ProblemReporter(
DefaultErrorHandlingPolicies.exitAfterAllProblems(),
-// options,
+ options,
problemFactory) {
public void record(IProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
unitResult.record(problem, referenceContext);
typeNames = new char[4][];
superTypeNames = new char[4][];
nestedTypeIndex = 0;
-// this.options = options;
+ this.options = options;
}
/** @deprecated use SourceElementParser(ISourceElementRequestor, IProblemFactory, CompilerOptions) */
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.compiler.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.phpdt.core.compiler.CharOperation;
+import net.sourceforge.phpdt.internal.compiler.Compiler;
+import net.sourceforge.phpdt.internal.compiler.env.IConstants;
+import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
+import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
+
+public class CompilerOptions implements ProblemReasons, ProblemSeverities, IConstants {
+
+ /**
+ * Option IDs
+ */
+ public static final String OPTION_LocalVariableAttribute = "net.sourceforge.phpeclipse.compiler.debug.localVariable"; //$NON-NLS-1$
+ public static final String OPTION_LineNumberAttribute = "net.sourceforge.phpeclipse.compiler.debug.lineNumber"; //$NON-NLS-1$
+ public static final String OPTION_SourceFileAttribute = "net.sourceforge.phpeclipse.compiler.debug.sourceFile"; //$NON-NLS-1$
+// public static final String OPTION_PreserveUnusedLocal = "net.sourceforge.phpeclipse.compiler.codegen.unusedLocal"; //$NON-NLS-1$
+ public static final String OPTION_ReportMethodWithConstructorName = "net.sourceforge.phpeclipse.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
+ public static final String OPTION_ReportOverridingPackageDefaultMethod = "net.sourceforge.phpeclipse.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
+ public static final String OPTION_ReportDeprecation = "net.sourceforge.phpeclipse.compiler.problem.deprecation"; //$NON-NLS-1$
+ public static final String OPTION_ReportDeprecationInDeprecatedCode = "net.sourceforge.phpeclipse.compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
+ public static final String OPTION_ReportDeprecationWhenOverridingDeprecatedMethod = "net.sourceforge.phpeclipse.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; //$NON-NLS-1$
+ public static final String OPTION_ReportHiddenCatchBlock = "net.sourceforge.phpeclipse.compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedLocal = "net.sourceforge.phpeclipse.compiler.problem.unusedLocal"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedParameter = "net.sourceforge.phpeclipse.compiler.problem.unusedParameter"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "net.sourceforge.phpeclipse.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "net.sourceforge.phpeclipse.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedImport = "net.sourceforge.phpeclipse.compiler.problem.unusedImport"; //$NON-NLS-1$
+ public static final String OPTION_ReportSyntheticAccessEmulation = "net.sourceforge.phpeclipse.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
+ public static final String OPTION_ReportNoEffectAssignment = "net.sourceforge.phpeclipse.compiler.problem.noEffectAssignment"; //$NON-NLS-1$
+ public static final String OPTION_ReportLocalVariableHiding = "net.sourceforge.phpeclipse.compiler.problem.localVariableHiding"; //$NON-NLS-1$
+ public static final String OPTION_ReportSpecialParameterHidingField = "net.sourceforge.phpeclipse.compiler.problem.specialParameterHidingField"; //$NON-NLS-1$
+ public static final String OPTION_ReportFieldHiding = "net.sourceforge.phpeclipse.compiler.problem.fieldHiding"; //$NON-NLS-1$
+ public static final String OPTION_ReportPossibleAccidentalBooleanAssignment = "net.sourceforge.phpeclipse.compiler.problem.possibleAccidentalBooleanAssignment"; //$NON-NLS-1$
+ public static final String OPTION_ReportNonExternalizedStringLiteral = "net.sourceforge.phpeclipse.compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
+ public static final String OPTION_ReportIncompatibleNonInheritedInterfaceMethod = "net.sourceforge.phpeclipse.compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedPrivateMember = "net.sourceforge.phpeclipse.compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
+ public static final String OPTION_ReportNoImplicitStringConversion = "net.sourceforge.phpeclipse.compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
+ public static final String OPTION_ReportAssertIdentifier = "net.sourceforge.phpeclipse.compiler.problem.assertIdentifier"; //$NON-NLS-1$
+ public static final String OPTION_ReportNonStaticAccessToStatic = "net.sourceforge.phpeclipse.compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
+ public static final String OPTION_ReportIndirectStaticAccess = "net.sourceforge.phpeclipse.compiler.problem.indirectStaticAccess"; //$NON-NLS-1$
+ public static final String OPTION_ReportSuperfluousSemicolon = "net.sourceforge.phpeclipse.compiler.problem.superfluousSemicolon"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnnecessaryTypeCheck = "net.sourceforge.phpeclipse.compiler.problem.unnecessaryTypeCheck"; //$NON-NLS-1$
+ public static final String OPTION_ReportUndocumentedEmptyBlock = "net.sourceforge.phpeclipse.compiler.problem.undocumentedEmptyBlock"; //$NON-NLS-1$
+ public static final String OPTION_ReportInvalidJavadoc = "net.sourceforge.phpeclipse.compiler.problem.invalidJavadoc"; //$NON-NLS-1$
+ public static final String OPTION_ReportInvalidJavadocTags = "net.sourceforge.phpeclipse.compiler.problem.invalidJavadocTags"; //$NON-NLS-1$
+ public static final String OPTION_ReportInvalidJavadocTagsVisibility = "net.sourceforge.phpeclipse.compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadocTags = "net.sourceforge.phpeclipse.compiler.problem.missingJavadocTags"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadocTagsVisibility = "net.sourceforge.phpeclipse.compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadocTagsOverriding = "net.sourceforge.phpeclipse.compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadocComments = "net.sourceforge.phpeclipse.compiler.problem.missingJavadocComments"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadocCommentsVisibility = "net.sourceforge.phpeclipse.compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadocCommentsOverriding = "net.sourceforge.phpeclipse.compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$
+ public static final String OPTION_ReportFinallyBlockNotCompletingNormally = "net.sourceforge.phpeclipse.compiler.problem.finallyBlockNotCompletingNormally"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedDeclaredThrownException = "net.sourceforge.phpeclipse.compiler.problem.unusedDeclaredThrownException"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding = "net.sourceforge.phpeclipse.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnqualifiedFieldAccess = "net.sourceforge.phpeclipse.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$
+// public static final String OPTION_Source = "net.sourceforge.phpeclipse.compiler.source"; //$NON-NLS-1$
+// public static final String OPTION_TargetPlatform = "net.sourceforge.phpeclipse.compiler.codegen.targetPlatform"; //$NON-NLS-1$
+// public static final String OPTION_Compliance = "net.sourceforge.phpeclipse.compiler.compliance"; //$NON-NLS-1$
+ public static final String OPTION_Encoding = "net.sourceforge.phpeclipse.encoding"; //$NON-NLS-1$
+ public static final String OPTION_MaxProblemPerUnit = "net.sourceforge.phpeclipse.compiler.maxProblemPerUnit"; //$NON-NLS-1$
+ public static final String OPTION_TaskTags = "net.sourceforge.phpeclipse.compiler.taskTags"; //$NON-NLS-1$
+ public static final String OPTION_TaskPriorities = "net.sourceforge.phpeclipse.compiler.taskPriorities"; //$NON-NLS-1$
+
+ // Backward compatibility
+ public static final String OPTION_ReportInvalidAnnotation = "net.sourceforge.phpeclipse.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingAnnotation = "net.sourceforge.phpeclipse.compiler.problem.missingAnnotation"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingJavadoc = "net.sourceforge.phpeclipse.compiler.problem.missingJavadoc"; //$NON-NLS-1$
+
+ /* should surface ??? */
+// public static final String OPTION_PrivateConstructorAccess = "net.sourceforge.phpeclipse.compiler.codegen.constructorAccessEmulation"; //$NON-NLS-1$
+
+ /**
+ * Possible values for configurable options
+ */
+ public static final String GENERATE = "generate";//$NON-NLS-1$
+ public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
+ public static final String PRESERVE = "preserve"; //$NON-NLS-1$
+// public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
+// public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
+// public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
+// public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
+// public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
+// public static final String VERSION_1_5 = "1.5"; //$NON-NLS-1$
+ public static final String ERROR = "error"; //$NON-NLS-1$
+ public static final String WARNING = "warning"; //$NON-NLS-1$
+ public static final String IGNORE = "ignore"; //$NON-NLS-1$
+ public static final String ENABLED = "enabled"; //$NON-NLS-1$
+ public static final String DISABLED = "disabled"; //$NON-NLS-1$
+ public static final String PUBLIC = "public"; //$NON-NLS-1$
+ public static final String PROTECTED = "protected"; //$NON-NLS-1$
+ public static final String DEFAULT = "default"; //$NON-NLS-1$
+ public static final String PRIVATE = "private"; //$NON-NLS-1$
+
+ /**
+ * Bit mask for configurable problems (error/warning threshold)
+ */
+ // 0x100L unused
+ // 0x200L unused
+ // 0x400L unused
+ // 0x800L unused
+ public static final long MethodWithConstructorName = 0x1000L;
+ public static final long OverriddenPackageDefaultMethod = 0x2000L;
+ public static final long UsingDeprecatedAPI = 0x4000L;
+ public static final long MaskedCatchBlock = 0x8000L;
+ public static final long UnusedLocalVariable = 0x10000L;
+ public static final long UnusedArgument = 0x20000L;
+ public static final long NoImplicitStringConversion = 0x40000L;
+ public static final long AccessEmulation = 0x80000L;
+ public static final long NonExternalizedString = 0x100000L;
+ public static final long AssertUsedAsAnIdentifier = 0x200000L;
+ public static final long UnusedImport = 0x400000L;
+ public static final long NonStaticAccessToStatic = 0x800000L;
+ public static final long Task = 0x1000000L;
+ public static final long NoEffectAssignment = 0x2000000L;
+ public static final long IncompatibleNonInheritedInterfaceMethod = 0x4000000L;
+ public static final long UnusedPrivateMember = 0x8000000L;
+ public static final long LocalVariableHiding = 0x10000000L;
+ public static final long FieldHiding = 0x20000000L;
+ public static final long AccidentalBooleanAssign = 0x40000000L;
+ public static final long SuperfluousSemicolon = 0x80000000L;
+ public static final long IndirectStaticAccess = 0x100000000L;
+ public static final long UndocumentedEmptyBlock = 0x200000000L;
+ public static final long UnnecessaryTypeCheck = 0x400000000L;
+ public static final long InvalidJavadoc = 0x800000000L;
+ public static final long FinallyBlockNotCompleting = 0x1000000000L;
+ public static final long UnusedDeclaredThrownException = 0x2000000000L;
+ public static final long UnqualifiedFieldAccess = 0x4000000000L;
+ public static final long MissingJavadocTags = 0x8000000000L;
+ public static final long MissingJavadocComments = 0x10000000000L;
+
+ // Default severity level for handlers
+ public long errorThreshold = 0;
+
+ public long warningThreshold =
+ MethodWithConstructorName
+ | UsingDeprecatedAPI
+ | MaskedCatchBlock
+ | OverriddenPackageDefaultMethod
+ | UnusedImport
+ | NonStaticAccessToStatic
+ | NoEffectAssignment
+ | IncompatibleNonInheritedInterfaceMethod
+ | NoImplicitStringConversion
+ | FinallyBlockNotCompleting
+ | AssertUsedAsAnIdentifier;
+
+ // Debug attributes
+ public static final int Source = 1; // SourceFileAttribute
+ public static final int Lines = 2; // LineNumberAttribute
+ public static final int Vars = 4; // LocalVariableTableAttribute
+
+ // By default only lines and source attributes are generated.
+ public int produceDebugAttributes = Lines | Source;
+
+// public long complianceLevel = JDK1_4; // by default be compliant with 1.4
+// public long sourceLevel = JDK1_3; //1.3 source behavior by default
+// public long targetJDK = JDK1_2; // default generates for JVM1.2
+
+ // toggle private access emulation for 1.2 (constr. accessor has extra arg on constructor) or 1.3 (make private constructor default access when access needed)
+ public boolean isPrivateConstructorAccessChangingVisibility = false; // by default, follows 1.2
+
+ // source encoding format
+ public String defaultEncoding = null; // will use the platform default encoding
+
+ // print what unit is being processed
+ public boolean verbose = Compiler.DEBUG;
+
+ // indicates if reference info is desired
+ public boolean produceReferenceInfo = false;
+
+ // indicates if unused/optimizable local variables need to be preserved (debugging purpose)
+ public boolean preserveAllLocalVariables = false;
+
+ // indicates whether literal expressions are inlined at parse-time or not
+ public boolean parseLiteralExpressionsAsConstants = true;
+
+ // max problems per compilation unit
+ public int maxProblemsPerUnit = 100; // no more than 100 problems per default
+
+ // tags used to recognize tasks in comments
+ public char[][] taskTags = null;
+
+ // priorities of tasks in comments
+ public char[][] taskPriorites = null;
+
+ // deprecation report
+ public boolean reportDeprecationInsideDeprecatedCode = false;
+ public boolean reportDeprecationWhenOverridingDeprecatedMethod = false;
+
+ // unused parameters report
+ public boolean reportUnusedParameterWhenImplementingAbstract = false;
+ public boolean reportUnusedParameterWhenOverridingConcrete = false;
+
+ // unused declaration of thrown exception
+ public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
+
+ // constructor/setter parameter hiding
+ public boolean reportSpecialParameterHidingField = false;
+
+ // check javadoc comments
+ public int reportInvalidJavadocTagsVisibility = AccPrivate;
+ public boolean reportInvalidJavadocTags = true;
+
+ // check missing javadoc tags
+ public int reportMissingJavadocTagsVisibility = AccPrivate;
+ public boolean reportMissingJavadocTagsOverriding = true;
+
+ // check missing javadoc comments
+ public int reportMissingJavadocCommentsVisibility = AccPublic;
+ public boolean reportMissingJavadocCommentsOverriding = true;
+
+ /**
+ * Initializing the compiler options with defaults
+ */
+ public CompilerOptions(){
+ // use default options
+ }
+
+ /**
+ * Initializing the compiler options with external settings
+ * @param settings
+ */
+ public CompilerOptions(Map settings){
+
+ if (settings == null) return;
+ set(settings);
+ }
+
+ public Map getMap() {
+ Map optionsMap = new HashMap(30);
+ optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & Vars) != 0 ? GENERATE : DO_NOT_GENERATE);
+ optionsMap.put(OPTION_LineNumberAttribute, (this.produceDebugAttributes & Lines) != 0 ? GENERATE : DO_NOT_GENERATE);
+ optionsMap.put(OPTION_SourceFileAttribute, (this.produceDebugAttributes & Source) != 0 ? GENERATE : DO_NOT_GENERATE);
+// optionsMap.put(OPTION_PreserveUnusedLocal, this.preserveAllLocalVariables ? PRESERVE : OPTIMIZE_OUT);
+ optionsMap.put(OPTION_ReportMethodWithConstructorName, getSeverityString(MethodWithConstructorName));
+ optionsMap.put(OPTION_ReportOverridingPackageDefaultMethod, getSeverityString(OverriddenPackageDefaultMethod));
+ optionsMap.put(OPTION_ReportDeprecation, getSeverityString(UsingDeprecatedAPI));
+ optionsMap.put(OPTION_ReportDeprecationInDeprecatedCode, this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportHiddenCatchBlock, getSeverityString(MaskedCatchBlock));
+ optionsMap.put(OPTION_ReportUnusedLocal, getSeverityString(UnusedLocalVariable));
+ optionsMap.put(OPTION_ReportUnusedParameter, getSeverityString(UnusedArgument));
+ optionsMap.put(OPTION_ReportUnusedImport, getSeverityString(UnusedImport));
+ optionsMap.put(OPTION_ReportSyntheticAccessEmulation, getSeverityString(AccessEmulation));
+ optionsMap.put(OPTION_ReportNoEffectAssignment, getSeverityString(NoEffectAssignment));
+ optionsMap.put(OPTION_ReportNonExternalizedStringLiteral, getSeverityString(NonExternalizedString));
+ optionsMap.put(OPTION_ReportNoImplicitStringConversion, getSeverityString(NoImplicitStringConversion));
+ optionsMap.put(OPTION_ReportNonStaticAccessToStatic, getSeverityString(NonStaticAccessToStatic));
+ optionsMap.put(OPTION_ReportIndirectStaticAccess, getSeverityString(IndirectStaticAccess));
+ optionsMap.put(OPTION_ReportIncompatibleNonInheritedInterfaceMethod, getSeverityString(IncompatibleNonInheritedInterfaceMethod));
+ optionsMap.put(OPTION_ReportUnusedPrivateMember, getSeverityString(UnusedPrivateMember));
+ optionsMap.put(OPTION_ReportLocalVariableHiding, getSeverityString(LocalVariableHiding));
+ optionsMap.put(OPTION_ReportFieldHiding, getSeverityString(FieldHiding));
+ optionsMap.put(OPTION_ReportPossibleAccidentalBooleanAssignment, getSeverityString(AccidentalBooleanAssign));
+ optionsMap.put(OPTION_ReportSuperfluousSemicolon, getSeverityString(SuperfluousSemicolon));
+ optionsMap.put(OPTION_ReportAssertIdentifier, getSeverityString(AssertUsedAsAnIdentifier));
+ optionsMap.put(OPTION_ReportUndocumentedEmptyBlock, getSeverityString(UndocumentedEmptyBlock));
+ optionsMap.put(OPTION_ReportUnnecessaryTypeCheck, getSeverityString(UnnecessaryTypeCheck));
+ optionsMap.put(OPTION_ReportInvalidJavadoc, getSeverityString(InvalidJavadoc));
+ optionsMap.put(OPTION_ReportInvalidJavadocTagsVisibility, getVisibilityString(this.reportInvalidJavadocTagsVisibility));
+ optionsMap.put(OPTION_ReportInvalidJavadocTags, this.reportInvalidJavadocTags? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportMissingJavadocTags, getSeverityString(MissingJavadocTags));
+ optionsMap.put(OPTION_ReportMissingJavadocTagsVisibility, getVisibilityString(this.reportMissingJavadocTagsVisibility));
+ optionsMap.put(OPTION_ReportMissingJavadocTagsOverriding, this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportMissingJavadocComments, getSeverityString(MissingJavadocComments));
+ optionsMap.put(OPTION_ReportMissingJavadocCommentsVisibility, getVisibilityString(this.reportMissingJavadocCommentsVisibility));
+ optionsMap.put(OPTION_ReportMissingJavadocCommentsOverriding, this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportFinallyBlockNotCompletingNormally, getSeverityString(FinallyBlockNotCompleting));
+ optionsMap.put(OPTION_ReportUnusedDeclaredThrownException, getSeverityString(UnusedDeclaredThrownException));
+ optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding, this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess));
+// optionsMap.put(OPTION_Compliance, versionFromJdkLevel(this.complianceLevel));
+// optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel));
+// optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK));
+ if (this.defaultEncoding != null) {
+ optionsMap.put(OPTION_Encoding, this.defaultEncoding);
+ }
+ optionsMap.put(OPTION_TaskTags, this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$
+ optionsMap.put(OPTION_TaskPriorities, this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$
+ optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit));
+
+ return optionsMap;
+ }
+
+ public int getSeverity(long irritant) {
+ if((this.warningThreshold & irritant) != 0)
+ return Warning;
+ if((this.errorThreshold & irritant) != 0)
+ return Error;
+ return Ignore;
+ }
+
+ public String getSeverityString(long irritant) {
+ if((this.warningThreshold & irritant) != 0)
+ return WARNING;
+ if((this.errorThreshold & irritant) != 0)
+ return ERROR;
+ return IGNORE;
+ }
+
+ public String getVisibilityString(int level) {
+ switch (level) {
+ case AccPublic:
+ return PUBLIC;
+ case AccProtected:
+ return PROTECTED;
+ case AccPrivate:
+ return PRIVATE;
+ default:
+ return DEFAULT;
+ }
+ }
+
+ public void set(Map optionsMap) {
+
+ Object optionValue;
+ if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) {
+ if (GENERATE.equals(optionValue)) {
+ this.produceDebugAttributes |= Vars;
+ } else if (DO_NOT_GENERATE.equals(optionValue)) {
+ this.produceDebugAttributes &= ~Vars;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_LineNumberAttribute)) != null) {
+ if (GENERATE.equals(optionValue)) {
+ this.produceDebugAttributes |= Lines;
+ } else if (DO_NOT_GENERATE.equals(optionValue)) {
+ this.produceDebugAttributes &= ~Lines;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_SourceFileAttribute)) != null) {
+ if (GENERATE.equals(optionValue)) {
+ this.produceDebugAttributes |= Source;
+ } else if (DO_NOT_GENERATE.equals(optionValue)) {
+ this.produceDebugAttributes &= ~Source;
+ }
+ }
+// if ((optionValue = optionsMap.get(OPTION_PreserveUnusedLocal)) != null) {
+// if (PRESERVE.equals(optionValue)) {
+// this.preserveAllLocalVariables = true;
+// } else if (OPTIMIZE_OUT.equals(optionValue)) {
+// this.preserveAllLocalVariables = false;
+// }
+// }
+ if ((optionValue = optionsMap.get(OPTION_ReportDeprecationInDeprecatedCode)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportDeprecationInsideDeprecatedCode = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportDeprecationInsideDeprecatedCode = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportDeprecationWhenOverridingDeprecatedMethod = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportDeprecationWhenOverridingDeprecatedMethod = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportUnusedDeclaredThrownExceptionWhenOverriding = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportUnusedDeclaredThrownExceptionWhenOverriding = false;
+ }
+ }
+// if ((optionValue = optionsMap.get(OPTION_Compliance)) != null) {
+// long level = versionToJdkLevel(optionValue);
+// if (level != 0) this.complianceLevel = level;
+// }
+// if ((optionValue = optionsMap.get(OPTION_Source)) != null) {
+// long level = versionToJdkLevel(optionValue);
+// if (level != 0) this.sourceLevel = level;
+// }
+// if ((optionValue = optionsMap.get(OPTION_TargetPlatform)) != null) {
+// long level = versionToJdkLevel(optionValue);
+// if (level != 0) this.targetJDK = level;
+// }
+ if ((optionValue = optionsMap.get(OPTION_Encoding)) != null) {
+ if (optionValue instanceof String) {
+ this.defaultEncoding = null;
+ String stringValue = (String) optionValue;
+ if (stringValue.length() > 0){
+ try {
+ new InputStreamReader(new ByteArrayInputStream(new byte[0]), stringValue);
+ this.defaultEncoding = stringValue;
+ } catch(UnsupportedEncodingException e){
+ // ignore unsupported encoding
+ }
+ }
+ }
+ }
+// if ((optionValue = optionsMap.get(OPTION_PrivateConstructorAccess)) != null) {
+// long level = versionToJdkLevel(optionValue);
+// if (level >= JDK1_3) this.isPrivateConstructorAccessChangingVisibility = true;
+// }
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenImplementingAbstract)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportUnusedParameterWhenImplementingAbstract = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportUnusedParameterWhenImplementingAbstract = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenOverridingConcrete)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportUnusedParameterWhenOverridingConcrete = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportUnusedParameterWhenOverridingConcrete = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportSpecialParameterHidingField)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportSpecialParameterHidingField = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportSpecialParameterHidingField = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_MaxProblemPerUnit)) != null) {
+ if (optionValue instanceof String) {
+ String stringValue = (String) optionValue;
+ try {
+ int val = Integer.parseInt(stringValue);
+ if (val >= 0) this.maxProblemsPerUnit = val;
+ } catch(NumberFormatException e){
+ // ignore ill-formatted limit
+ }
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_TaskTags)) != null) {
+ if (optionValue instanceof String) {
+ String stringValue = (String) optionValue;
+ if (stringValue.length() == 0) {
+ this.taskTags = null;
+ } else {
+ this.taskTags = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
+ }
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_TaskPriorities)) != null) {
+ if (optionValue instanceof String) {
+ String stringValue = (String) optionValue;
+ if (stringValue.length() == 0) {
+ this.taskPriorites = null;
+ } else {
+ this.taskPriorites = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
+ }
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMethodWithConstructorName)) != null) updateSeverity(MethodWithConstructorName, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportOverridingPackageDefaultMethod)) != null) updateSeverity(OverriddenPackageDefaultMethod, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportDeprecation)) != null) updateSeverity(UsingDeprecatedAPI, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportHiddenCatchBlock)) != null) updateSeverity(MaskedCatchBlock, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedLocal)) != null) updateSeverity(UnusedLocalVariable, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameter)) != null) updateSeverity(UnusedArgument, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedImport)) != null) updateSeverity(UnusedImport, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedPrivateMember)) != null) updateSeverity(UnusedPrivateMember, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedDeclaredThrownException)) != null) updateSeverity(UnusedDeclaredThrownException, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportNoImplicitStringConversion)) != null) updateSeverity(NoImplicitStringConversion, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportSyntheticAccessEmulation)) != null) updateSeverity(AccessEmulation, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportLocalVariableHiding)) != null) updateSeverity(LocalVariableHiding, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportFieldHiding)) != null) updateSeverity(FieldHiding, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportPossibleAccidentalBooleanAssignment)) != null) updateSeverity(AccidentalBooleanAssign, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportSuperfluousSemicolon)) != null) updateSeverity(SuperfluousSemicolon, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportNonExternalizedStringLiteral)) != null) updateSeverity(NonExternalizedString, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportAssertIdentifier)) != null) updateSeverity(AssertUsedAsAnIdentifier, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportNonStaticAccessToStatic)) != null) updateSeverity(NonStaticAccessToStatic, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportIndirectStaticAccess)) != null) updateSeverity(IndirectStaticAccess, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)) != null) updateSeverity(IncompatibleNonInheritedInterfaceMethod, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUndocumentedEmptyBlock)) != null) updateSeverity(UndocumentedEmptyBlock, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryTypeCheck)) != null) updateSeverity(UnnecessaryTypeCheck, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportFinallyBlockNotCompletingNormally)) != null) updateSeverity(FinallyBlockNotCompleting, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnqualifiedFieldAccess)) != null) updateSeverity(UnqualifiedFieldAccess, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportNoEffectAssignment)) != null) updateSeverity(NoEffectAssignment, optionValue);
+
+ // Javadoc options
+ if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) {
+ updateSeverity(InvalidJavadoc, optionValue);
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsVisibility)) != null) {
+ if (PUBLIC.equals(optionValue)) {
+ this.reportInvalidJavadocTagsVisibility = AccPublic;
+ } else if (PROTECTED.equals(optionValue)) {
+ this.reportInvalidJavadocTagsVisibility = AccProtected;
+// } else if (DEFAULT.equals(optionValue)) {
+// this.reportInvalidJavadocTagsVisibility = AccDefault;
+ } else if (PRIVATE.equals(optionValue)) {
+ this.reportInvalidJavadocTagsVisibility = AccPrivate;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTags)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportInvalidJavadocTags= true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportInvalidJavadocTags = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTags)) != null) {
+ updateSeverity(MissingJavadocTags, optionValue);
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsVisibility)) != null) {
+ if (PUBLIC.equals(optionValue)) {
+ this.reportMissingJavadocTagsVisibility = AccPublic;
+ } else if (PROTECTED.equals(optionValue)) {
+ this.reportMissingJavadocTagsVisibility = AccProtected;
+// } else if (DEFAULT.equals(optionValue)) {
+// this.reportMissingJavadocTagsVisibility = AccDefault;
+ } else if (PRIVATE.equals(optionValue)) {
+ this.reportMissingJavadocTagsVisibility = AccPrivate;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsOverriding)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportMissingJavadocTagsOverriding = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportMissingJavadocTagsOverriding = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocComments)) != null) {
+ updateSeverity(MissingJavadocComments, optionValue);
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsVisibility)) != null) {
+ if (PUBLIC.equals(optionValue)) {
+ this.reportMissingJavadocCommentsVisibility = AccPublic;
+ } else if (PROTECTED.equals(optionValue)) {
+ this.reportMissingJavadocCommentsVisibility = AccProtected;
+// } else if (DEFAULT.equals(optionValue)) {
+// this.reportMissingJavadocCommentsVisibility = AccDefault;
+ } else if (PRIVATE.equals(optionValue)) {
+ this.reportMissingJavadocCommentsVisibility = AccPrivate;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsOverriding)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportMissingJavadocCommentsOverriding = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportMissingJavadocCommentsOverriding = false;
+ }
+ }
+ }
+
+ public void setVerboseMode(boolean flag) {
+ this.verbose = flag;
+ }
+
+ public String toString() {
+
+ StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
+ buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & Vars) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & Lines) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- source debug attributes: ").append((this.produceDebugAttributes & Source) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- preserve all local variables: ").append(this.preserveAllLocalVariables ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- method with constructor name: ").append(getSeverityString(MethodWithConstructorName)); //$NON-NLS-1$
+ buf.append("\n\t- overridden package default method: ").append(getSeverityString(OverriddenPackageDefaultMethod)); //$NON-NLS-1$
+ buf.append("\n\t- deprecation: ").append(getSeverityString(UsingDeprecatedAPI)); //$NON-NLS-1$
+ buf.append("\n\t- masked catch block: ").append(getSeverityString(MaskedCatchBlock)); //$NON-NLS-1$
+ buf.append("\n\t- unused local variable: ").append(getSeverityString(UnusedLocalVariable)); //$NON-NLS-1$
+ buf.append("\n\t- unused parameter: ").append(getSeverityString(UnusedArgument)); //$NON-NLS-1$
+ buf.append("\n\t- unused import: ").append(getSeverityString(UnusedImport)); //$NON-NLS-1$
+ buf.append("\n\t- synthetic access emulation: ").append(getSeverityString(AccessEmulation)); //$NON-NLS-1$
+ buf.append("\n\t- assignment with no effect: ").append(getSeverityString(NoEffectAssignment)); //$NON-NLS-1$
+ buf.append("\n\t- non externalized string: ").append(getSeverityString(NonExternalizedString)); //$NON-NLS-1$
+ buf.append("\n\t- static access receiver: ").append(getSeverityString(NonStaticAccessToStatic)); //$NON-NLS-1$
+ buf.append("\n\t- indirect static access: ").append(getSeverityString(IndirectStaticAccess)); //$NON-NLS-1$
+ buf.append("\n\t- incompatible non inherited interface method: ").append(getSeverityString(IncompatibleNonInheritedInterfaceMethod)); //$NON-NLS-1$
+ buf.append("\n\t- unused private member: ").append(getSeverityString(UnusedPrivateMember)); //$NON-NLS-1$
+ buf.append("\n\t- local variable hiding another variable: ").append(getSeverityString(LocalVariableHiding)); //$NON-NLS-1$
+ buf.append("\n\t- field hiding another variable: ").append(getSeverityString(FieldHiding)); //$NON-NLS-1$
+ buf.append("\n\t- possible accidental boolean assignment: ").append(getSeverityString(AccidentalBooleanAssign)); //$NON-NLS-1$
+ buf.append("\n\t- superfluous semicolon: ").append(getSeverityString(SuperfluousSemicolon)); //$NON-NLS-1$
+ buf.append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); //$NON-NLS-1$
+ buf.append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); //$NON-NLS-1$
+ buf.append("\n\t- invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$
+ buf.append("\n\t- report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$
+ buf.append("\n\t- visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$
+ buf.append("\n\t- missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$
+ buf.append("\n\t- visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); //$NON-NLS-1$
+ buf.append("\n\t- report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
+ buf.append("\n\t- missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$
+ buf.append("\n\t- visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$
+ buf.append("\n\t- report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
+ buf.append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); //$NON-NLS-1$
+ buf.append("\n\t- unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); //$NON-NLS-1$
+ buf.append("\n\t- unused declared thrown exception when overriding ").append(this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
+// buf.append("\n\t- JDK compliance level: "+ versionFromJdkLevel(this.complianceLevel)); //$NON-NLS-1$
+// buf.append("\n\t- JDK source level: "+ versionFromJdkLevel(this.sourceLevel)); //$NON-NLS-1$
+// buf.append("\n\t- JDK target level: "+ versionFromJdkLevel(this.targetJDK)); //$NON-NLS-1$
+ buf.append("\n\t- private constructor access: ").append(this.isPrivateConstructorAccessChangingVisibility ? "extra argument" : "make default access"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- verbose : ").append(this.verbose ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- produce reference info : ").append(this.produceReferenceInfo ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- parse literal expressions as constants : ").append(this.parseLiteralExpressionsAsConstants ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- encoding : ").append(this.defaultEncoding == null ? "<default>" : this.defaultEncoding); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("\n\t- task tags: ").append(this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("\n\t- task priorities : ").append(this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("\n\t- report deprecation inside deprecated code : ").append(this.reportDeprecationInsideDeprecatedCode ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- report deprecation when overriding deprecated method : ").append(this.reportDeprecationWhenOverridingDeprecatedMethod ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return buf.toString();
+ }
+
+ void updateSeverity(long irritant, Object severityString) {
+ if (ERROR.equals(severityString)) {
+ this.errorThreshold |= irritant;
+ this.warningThreshold &= ~irritant;
+ } else if (WARNING.equals(severityString)) {
+ this.errorThreshold &= ~irritant;
+ this.warningThreshold |= irritant;
+ } else if (IGNORE.equals(severityString)) {
+ this.errorThreshold &= ~irritant;
+ this.warningThreshold &= ~irritant;
+ }
+ }
+// public static long versionToJdkLevel(Object versionID) {
+// if (VERSION_1_1.equals(versionID)) {
+// return JDK1_1;
+// } else if (VERSION_1_2.equals(versionID)) {
+// return JDK1_2;
+// } else if (VERSION_1_3.equals(versionID)) {
+// return JDK1_3;
+// } else if (VERSION_1_4.equals(versionID)) {
+// return JDK1_4;
+// } else if (VERSION_1_5.equals(versionID)) {
+// return JDK1_5;
+// }
+// return 0; // unknown
+// }
+
+// public static String versionFromJdkLevel(long jdkLevel) {
+// if (jdkLevel == JDK1_1) {
+// return VERSION_1_1;
+// } else if (jdkLevel == JDK1_2) {
+// return VERSION_1_2;
+// } else if (jdkLevel == JDK1_3) {
+// return VERSION_1_3;
+// } else if (jdkLevel == JDK1_4) {
+// return VERSION_1_4;
+// } else if (jdkLevel == JDK1_5) {
+// return VERSION_1_5;
+// }
+// return ""; // unknown version //$NON-NLS-1$
+// }
+}
**********************************************************************/
package net.sourceforge.phpdt.internal.compiler.parser;
import java.util.ArrayList;
+
import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
import net.sourceforge.phpdt.core.compiler.InvalidInputException;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
import net.sourceforge.phpdt.internal.compiler.lookup.CompilerModifiers;
import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
+import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.SingleTypeReference;
import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
+import net.sourceforge.phpdt.internal.compiler.util.Util;
+
import org.eclipse.core.resources.IFile;
public class Parser //extends PHPParserSuperclass
implements ITerminalSymbols, CompilerModifiers, ParserBasicInformation {
//private boolean phpMode;
protected int modifiers;
protected int modifiersSourceStart;
- protected Parser() {
+ protected Parser(ProblemReporter problemReporter) {
+ this.problemReporter = problemReporter;
+ this.options = problemReporter.options;
this.currentPHPString = 0;
// PHPParserSuperclass.fileToParse = fileToParse;
this.phpList = null;
this.initializeScanner();
}
public void initializeScanner() {
- this.scanner = new Scanner(false, false, false, false);
+ this.scanner = new Scanner(
+ false /*comment*/,
+ false /*whitespace*/,
+ this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore /*nls*/,
+ false,
+ false,
+ this.options.taskTags/*taskTags*/,
+ this.options.taskPriorites/*taskPriorities*/);
}
/**
* Create marker for the parse error
}
throwSyntaxError("End-of-file not reached.");
}
- return;
+ break;
} catch (SyntaxError sytaxErr1) {
// setMarker(sytaxErr1.getMessage(), sytaxErr1.getLine(),
// ERROR);
getNextToken();
}
if (token == TokenNameEOF || token == TokenNameERROR) {
- return;
+ break;
}
} catch (SyntaxError sytaxErr2) {
// setMarker(sytaxErr2.getMessage(), sytaxErr2.getLine(),
// setMarker(sytaxErr2.getMessage(),
// scanner.getCurrentTokenStartPosition(),
// scanner.getCurrentTokenEndPosition(), ERROR);
- return;
+ break;
}
}
} while (true);
+
+ endParse(0);
+ }
+
+ protected CompilationUnitDeclaration endParse(int act) {
+
+ this.lastAct = act;
+
+ if (currentElement != null) {
+ currentElement.topElement().updateParseTree();
+ if (VERBOSE_RECOVERY) {
+ System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$
+ System.out.println("--------------------------"); //$NON-NLS-1$
+ System.out.println(compilationUnit);
+ System.out.println("----------------------------------"); //$NON-NLS-1$
+ }
+ } else {
+ if (diet & VERBOSE_RECOVERY) {
+ System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$
+ System.out.println("--------------------------"); //$NON-NLS-1$
+ System.out.println(compilationUnit);
+ System.out.println("----------------------------------"); //$NON-NLS-1$
+ }
+ }
+ if (scanner.recordLineSeparator) {
+ compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds();
+ }
+ if (scanner.taskTags != null) {
+ for (int i = 0; i < scanner.foundTaskCount; i++) {
+ problemReporter().task(
+ new String(scanner.foundTaskTags[i]),
+ new String(scanner.foundTaskMessages[i]),
+ scanner.foundTaskPriorities[i] == null ? null : new String(scanner.foundTaskPriorities[i]),
+ scanner.foundTaskPositions[i][0],
+ scanner.foundTaskPositions[i][1]);
+ }
+ }
+ return compilationUnit;
}
// public PHPOutlineInfo parseInfo(Object parent, String s) {
// PHPOutlineInfo outlineInfo = new PHPOutlineInfo(parent);
*/
protected ReferenceContext referenceContext;
protected ProblemReporter problemReporter;
+ protected CompilerOptions options;
// protected CompilationResult compilationResult;
/**
* Returns this parser's problem reporter initialized with its reference
public char[][] taskPriorities = null;
public static final boolean DEBUG = false;
public static final boolean TRACE = false;
- public Scanner() {
- this(false, false);
- }
- public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace) {
- this(tokenizeComments, tokenizeWhiteSpace, false);
- }
+
/**
* Determines if the specified character is permissible as the first
* character in a PHP identifier
endPositionForLineComment = currentPosition - 1;
}
recordComment(false);
- if ((currentCharacter == '\r')
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition);
+ if ((currentCharacter == '\r')
|| (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
+ new String(getCurrentTokenSource()); //$NON-NLS-1$
}
}
+
+ public Scanner() {
+ this(false, false);
+ }
+ public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace) {
+ this(tokenizeComments, tokenizeWhiteSpace, false);
+ }
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
boolean checkNonExternalizedStringLiterals) {
this(tokenizeComments, tokenizeWhiteSpace,
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
boolean checkNonExternalizedStringLiterals, boolean assertMode) {
this(tokenizeComments, tokenizeWhiteSpace,
- checkNonExternalizedStringLiterals, assertMode, false);
+ checkNonExternalizedStringLiterals, assertMode, false, null, null);
}
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
boolean checkNonExternalizedStringLiterals, boolean assertMode,
- boolean tokenizeStrings) {
+ boolean tokenizeStrings,
+ char[][] taskTags,
+ char[][] taskPriorities) {
this.eofPosition = Integer.MAX_VALUE;
this.tokenizeComments = tokenizeComments;
this.tokenizeWhiteSpace = tokenizeWhiteSpace;
this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
this.assertMode = assertMode;
this.encapsedStringStack = null;
+ this.taskTags = taskTags;
+ this.taskPriorities = taskPriorities;
}
private void checkNonExternalizeString() throws InvalidInputException {
if (currentLine == null)
package net.sourceforge.phpdt.internal.compiler.parser;
-import java.util.Stack;
import net.sourceforge.phpdt.core.IJavaModelMarker;
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
-import net.sourceforge.phpdt.internal.compiler.util.Util;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
public class UnitParser extends Parser {
public UnitParser(ProblemReporter problemReporter) { //, boolean optimizeStringLiterals, boolean assertMode) {
- super();
+ super(problemReporter);
nestedMethod = new int[30];
- this.problemReporter = problemReporter;
+
// this.optimizeStringLiterals = optimizeStringLiterals;
// this.assertMode = assertMode;
// this.initializeScanner();
}
}
- protected CompilationUnitDeclaration endParse(int act) {
-
- this.lastAct = act;
- if (currentElement != null) {
- currentElement.topElement().updateParseTree();
- if (VERBOSE_RECOVERY) {
- System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$
- System.out.println("--------------------------"); //$NON-NLS-1$
- System.out.println(compilationUnit);
- System.out.println("----------------------------------"); //$NON-NLS-1$
- }
- } else {
- if (diet & VERBOSE_RECOVERY) {
- System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$
- System.out.println("--------------------------"); //$NON-NLS-1$
- System.out.println(compilationUnit);
- System.out.println("----------------------------------"); //$NON-NLS-1$
- }
- }
- if (scanner.recordLineSeparator) {
- compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds();
- }
- if (scanner.taskTags != null) {
- for (int i = 0; i < scanner.foundTaskCount; i++) {
- problemReporter().task(
- new String(scanner.foundTaskTags[i]),
- new String(scanner.foundTaskMessages[i]),
- scanner.foundTaskPriorities[i] == null ? null : new String(scanner.foundTaskPriorities[i]),
- scanner.foundTaskPositions[i][0],
- scanner.foundTaskPositions[i][1]);
- }
- }
- return compilationUnit;
- }
// A P I
import net.sourceforge.phpdt.internal.compiler.CompilationResult;
import net.sourceforge.phpdt.internal.compiler.IErrorHandlingPolicy;
import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
final public IErrorHandlingPolicy policy;
public final IProblemFactory problemFactory;
-// public final CompilerOptions options;
+ public final CompilerOptions options;
/*
* Problem handler can be supplied with a policy to specify
* its behavior in error handling. Also see static methods for
* built-in policies.
*
*/
-public ProblemHandler(IErrorHandlingPolicy policy, IProblemFactory problemFactory) {
-//CompilerOptions options, IProblemFactory problemFactory) {
+public ProblemHandler(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
this.policy = policy;
this.problemFactory = problemFactory;
-// this.options = options;
+ this.options = options;
}
/*
* Given the current configuration, answers which category the problem
import net.sourceforge.phpdt.internal.compiler.CompilationResult;
import net.sourceforge.phpdt.internal.compiler.IErrorHandlingPolicy;
import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.Constant;
import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
-import net.sourceforge.phpdt.internal.compiler.lookup.CompilerModifiers;
import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding;
public class ProblemReporter extends ProblemHandler implements ProblemReasons {
public ReferenceContext referenceContext;
public ProblemReporter(IErrorHandlingPolicy policy,
+ CompilerOptions options,
IProblemFactory problemFactory) {
- //CompilerOptions options, IProblemFactory problemFactory) {
- super(policy, problemFactory);//options, problemFactory);
+
+ // IProblemFactory problemFactory) {
+ super(policy, options, problemFactory); //), problemFactory);
}
public void abortDueToInternalError(String errorMessage) {
String[] arguments = new String[]{errorMessage};
| Abort, start, end);
}
/*
- * Given the current configuration, answers which category the problem falls
- * into: Error | Warning | Ignore
+ * Given the current configuration, answers which category the problem
+ * falls into:
+ * Error | Warning | Ignore
*/
- //public int computeSeverity(int problemId){
- //
- // // severity can have been preset on the problem
- //// if ((problem.severity & Fatal) != 0){
- //// return Error;
- //// }
- //
- // // if not then check whether it is a configurable problem
- // int errorThreshold = options.errorThreshold;
- // int warningThreshold = options.warningThreshold;
- //
- // switch(problemId){
- //
- // case IProblem.UnreachableCatch :
- // case IProblem.CodeCannotBeReached :
- // if ((errorThreshold & CompilerOptions.UnreachableCode) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.UnreachableCode) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.MaskedCatch :
- // if ((errorThreshold & CompilerOptions.MaskedCatchBlock) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.MaskedCatchBlock) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- ///*
- // case Never Used :
- // if ((errorThreshold & ParsingOptionalError) != 0){
- // return Error;
- // }
- // if ((warningThreshold & ParsingOptionalError) != 0){
- // return Warning;
- // }
- // return Ignore;
- //*/
- // case IProblem.ImportNotFound :
- // case IProblem.ImportNotVisible :
- // case IProblem.ImportAmbiguous :
- // case IProblem.ImportInternalNameProvided :
- // case IProblem.ImportInheritedNameHidesEnclosingName :
- // case IProblem.DuplicateImport :
- // case IProblem.ConflictingImport :
- // case IProblem.CannotImportPackage :
- // if ((errorThreshold & CompilerOptions.ImportProblem) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.ImportProblem) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.UnusedImport :
- // // if import problem are disabled, then ignore
- // if ((errorThreshold & CompilerOptions.ImportProblem) == 0
- // && (warningThreshold & CompilerOptions.ImportProblem) == 0){
- // return Ignore;
- // }
- // if ((errorThreshold & CompilerOptions.UnusedImport) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.UnusedImport) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.MethodButWithConstructorName :
- // if ((errorThreshold & CompilerOptions.MethodWithConstructorName) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.MethodWithConstructorName) !=
- // 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.OverridingNonVisibleMethod :
- // if ((errorThreshold & CompilerOptions.OverriddenPackageDefaultMethod) !=
- // 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.OverriddenPackageDefaultMethod)
- // != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
- // case
- // IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod
- // :
- // if ((errorThreshold &
- // CompilerOptions.IncompatibleNonInheritedInterfaceMethod) != 0){
- // return Error;
- // }
- // if ((warningThreshold &
- // CompilerOptions.IncompatibleNonInheritedInterfaceMethod) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.OverridingDeprecatedMethod :
- // case IProblem.UsingDeprecatedType :
- // case IProblem.UsingDeprecatedMethod :
- // case IProblem.UsingDeprecatedConstructor :
- // case IProblem.UsingDeprecatedField :
- // if ((errorThreshold & CompilerOptions.UsingDeprecatedAPI) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.UsingDeprecatedAPI) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.LocalVariableIsNeverUsed :
- // if ((errorThreshold & CompilerOptions.UnusedLocalVariable) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.UnusedLocalVariable) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.ArgumentIsNeverUsed :
- // if ((errorThreshold & CompilerOptions.UnusedArgument) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.UnusedArgument) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.NoImplicitStringConversionForCharArrayExpression :
- // if ((errorThreshold & CompilerOptions.NoImplicitStringConversion) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.NoImplicitStringConversion) !=
- // 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.NeedToEmulateFieldReadAccess :
- // case IProblem.NeedToEmulateFieldWriteAccess :
- // case IProblem.NeedToEmulateMethodAccess :
- // case IProblem.NeedToEmulateConstructorAccess :
- // if ((errorThreshold & CompilerOptions.AccessEmulation) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.AccessEmulation) != 0){
- // return Warning;
- // }
- // return Ignore;
- // case IProblem.NonExternalizedStringLiteral :
- // if ((errorThreshold & CompilerOptions.NonExternalizedString) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.NonExternalizedString) != 0){
- // return Warning;
- // }
- // return Ignore;
- // case IProblem.UseAssertAsAnIdentifier :
- // if ((errorThreshold & CompilerOptions.AssertUsedAsAnIdentifier) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.AssertUsedAsAnIdentifier) != 0){
- // return Warning;
- // }
- // return Ignore;
- // case IProblem.NonStaticAccessToStaticMethod :
- // case IProblem.NonStaticAccessToStaticField :
- // if ((errorThreshold & CompilerOptions.StaticAccessReceiver) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.StaticAccessReceiver) != 0){
- // return Warning;
- // }
- // return Ignore;
- // case IProblem.AssignmentHasNoEffect:
- // if ((errorThreshold & CompilerOptions.NoEffectAssignment) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.NoEffectAssignment) != 0){
- // return Warning;
- // }
- // return Ignore;
- // case IProblem.UnusedPrivateConstructor:
- // case IProblem.UnusedPrivateMethod:
- // case IProblem.UnusedPrivateField:
- // case IProblem.UnusedPrivateType:
- // if ((errorThreshold & CompilerOptions.UnusedPrivateMember) != 0){
- // return Error;
- // }
- // if ((warningThreshold & CompilerOptions.UnusedPrivateMember) != 0){
- // return Warning;
- // }
- // return Ignore;
- //
- // case IProblem.Task :
- // return Warning;
- // default:
- // return Error;
- // }
- //}
+ public int computeSeverity(int problemId){
+
+ // severity can have been preset on the problem
+// if ((problem.severity & Fatal) != 0){
+// return Error;
+// }
+
+ // if not then check whether it is a configurable problem
+ switch(problemId){
+
+ case IProblem.MaskedCatch :
+ return this.options.getSeverity(CompilerOptions.MaskedCatchBlock);
+
+ case IProblem.UnusedImport :
+ return this.options.getSeverity(CompilerOptions.UnusedImport);
+
+ case IProblem.MethodButWithConstructorName :
+ return this.options.getSeverity(CompilerOptions.MethodWithConstructorName);
+
+ case IProblem.OverridingNonVisibleMethod :
+ return this.options.getSeverity(CompilerOptions.OverriddenPackageDefaultMethod);
+
+ case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
+ case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
+ return this.options.getSeverity(CompilerOptions.IncompatibleNonInheritedInterfaceMethod);
+
+ case IProblem.OverridingDeprecatedMethod :
+ case IProblem.UsingDeprecatedType :
+ case IProblem.UsingDeprecatedMethod :
+ case IProblem.UsingDeprecatedConstructor :
+ case IProblem.UsingDeprecatedField :
+ return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI);
+
+ case IProblem.LocalVariableIsNeverUsed :
+ return this.options.getSeverity(CompilerOptions.UnusedLocalVariable);
+
+ case IProblem.ArgumentIsNeverUsed :
+ return this.options.getSeverity(CompilerOptions.UnusedArgument);
+
+ case IProblem.NoImplicitStringConversionForCharArrayExpression :
+ return this.options.getSeverity(CompilerOptions.NoImplicitStringConversion);
+
+ case IProblem.NeedToEmulateFieldReadAccess :
+ case IProblem.NeedToEmulateFieldWriteAccess :
+ case IProblem.NeedToEmulateMethodAccess :
+ case IProblem.NeedToEmulateConstructorAccess :
+ return this.options.getSeverity(CompilerOptions.AccessEmulation);
+
+ case IProblem.NonExternalizedStringLiteral :
+ return this.options.getSeverity(CompilerOptions.NonExternalizedString);
+
+ case IProblem.UseAssertAsAnIdentifier :
+ return this.options.getSeverity(CompilerOptions.AssertUsedAsAnIdentifier);
+
+ case IProblem.NonStaticAccessToStaticMethod :
+ case IProblem.NonStaticAccessToStaticField :
+ return this.options.getSeverity(CompilerOptions.NonStaticAccessToStatic);
+
+// case IProblem.IndirectAccessToStaticMethod :
+// case IProblem.IndirectAccessToStaticField :
+// case IProblem.IndirectAccessToStaticType :
+// return this.options.getSeverity(CompilerOptions.IndirectStaticAccess);
+
+ case IProblem.AssignmentHasNoEffect:
+ return this.options.getSeverity(CompilerOptions.NoEffectAssignment);
+
+ case IProblem.UnusedPrivateConstructor:
+ case IProblem.UnusedPrivateMethod:
+ case IProblem.UnusedPrivateField:
+ case IProblem.UnusedPrivateType:
+ return this.options.getSeverity(CompilerOptions.UnusedPrivateMember);
+
+ case IProblem.Task :
+ return Warning;
+
+// case IProblem.LocalVariableHidingLocalVariable:
+// case IProblem.LocalVariableHidingField:
+// case IProblem.ArgumentHidingLocalVariable:
+// case IProblem.ArgumentHidingField:
+// return this.options.getSeverity(CompilerOptions.LocalVariableHiding);
+
+// case IProblem.FieldHidingLocalVariable:
+// case IProblem.FieldHidingField:
+// return this.options.getSeverity(CompilerOptions.FieldHiding);
+
+// case IProblem.PossibleAccidentalBooleanAssignment:
+// return this.options.getSeverity(CompilerOptions.AccidentalBooleanAssign);
+
+// case IProblem.SuperfluousSemicolon:
+// return this.options.getSeverity(CompilerOptions.SuperfluousSemicolon);
+//
+// case IProblem.UndocumentedEmptyBlock:
+// return this.options.getSeverity(CompilerOptions.UndocumentedEmptyBlock);
+//
+// case IProblem.UnnecessaryCast:
+// case IProblem.UnnecessaryArgumentCast:
+// case IProblem.UnnecessaryInstanceof:
+// return this.options.getSeverity(CompilerOptions.UnnecessaryTypeCheck);
+//
+// case IProblem.FinallyMustCompleteNormally:
+// return this.options.getSeverity(CompilerOptions.FinallyBlockNotCompleting);
+//
+// case IProblem.UnusedMethodDeclaredThrownException:
+// case IProblem.UnusedConstructorDeclaredThrownException:
+// return this.options.getSeverity(CompilerOptions.UnusedDeclaredThrownException);
+//
+// case IProblem.UnqualifiedFieldAccess:
+// return this.options.getSeverity(CompilerOptions.UnqualifiedFieldAccess);
+
+ /*
+ * Javadoc syntax errors
+ */
+ // Javadoc explicit IDs
+// case IProblem.JavadocUnexpectedTag:
+// case IProblem.JavadocDuplicateReturnTag:
+// case IProblem.JavadocInvalidThrowsClass:
+// case IProblem.JavadocInvalidSeeReference:
+// case IProblem.JavadocInvalidSeeHref:
+// case IProblem.JavadocInvalidSeeArgs:
+// case IProblem.JavadocInvalidTag:
+// return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
+
+ /*
+ * Javadoc tags resolved references errors
+ */
+// case IProblem.JavadocInvalidParamName:
+// case IProblem.JavadocDuplicateParamName:
+// case IProblem.JavadocMissingParamName:
+// case IProblem.JavadocInvalidThrowsClassName:
+// case IProblem.JavadocDuplicateThrowsClassName:
+// case IProblem.JavadocMissingThrowsClassName:
+// case IProblem.JavadocMissingSeeReference:
+// case IProblem.JavadocUsingDeprecatedField:
+// case IProblem.JavadocUsingDeprecatedConstructor:
+// case IProblem.JavadocUsingDeprecatedMethod:
+// case IProblem.JavadocUsingDeprecatedType:
+// case IProblem.JavadocUndefinedField:
+// case IProblem.JavadocNotVisibleField:
+// case IProblem.JavadocAmbiguousField:
+// case IProblem.JavadocUndefinedConstructor:
+// case IProblem.JavadocNotVisibleConstructor:
+// case IProblem.JavadocAmbiguousConstructor:
+// case IProblem.JavadocUndefinedMethod:
+// case IProblem.JavadocNotVisibleMethod:
+// case IProblem.JavadocAmbiguousMethod:
+// case IProblem.JavadocParameterMismatch:
+// case IProblem.JavadocUndefinedType:
+// case IProblem.JavadocNotVisibleType:
+// case IProblem.JavadocAmbiguousType:
+// case IProblem.JavadocInternalTypeNameProvided:
+// case IProblem.JavadocNoMessageSendOnArrayType:
+// case IProblem.JavadocNoMessageSendOnBaseType:
+// if (!this.options.reportInvalidJavadocTags)
+// return ProblemSeverities.Ignore;
+// else
+// return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
+
+ /*
+ * Javadoc missing tags errors
+ */
+// case IProblem.JavadocMissingParamTag:
+// case IProblem.JavadocMissingReturnTag:
+// case IProblem.JavadocMissingThrowsTag:
+// return this.options.getSeverity(CompilerOptions.MissingJavadocTags);
+
+ /*
+ * Missing Javadoc errors
+ */
+// case IProblem.JavadocMissing:
+// return this.options.getSeverity(CompilerOptions.MissingJavadocComments);
+
+ // by default problems are errors.
+ default:
+ return Error;
+ }
+ }
//public void conditionalArgumentsIncompatibleTypes(ConditionalExpression
// expression, TypeBinding trueType, TypeBinding falseType) {
// this.handle(
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaModelStatusConstants;
import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.core.IMember;
import net.sourceforge.phpdt.core.IMethod;
+import net.sourceforge.phpdt.core.IOpenable;
import net.sourceforge.phpdt.core.IPackageDeclaration;
import net.sourceforge.phpdt.core.IPackageFragment;
import net.sourceforge.phpdt.core.IPackageFragmentRoot;
+import net.sourceforge.phpdt.core.IParent;
import net.sourceforge.phpdt.core.IProblemRequestor;
+import net.sourceforge.phpdt.core.ISourceManipulation;
import net.sourceforge.phpdt.core.ISourceRange;
+import net.sourceforge.phpdt.core.ISourceReference;
import net.sourceforge.phpdt.core.IType;
+import net.sourceforge.phpdt.core.IWorkingCopy;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.Signature;
import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.core.jdom.IDOMNode;
-import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
import net.sourceforge.phpdt.internal.compiler.SourceElementParser;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.core.resources.IContainer;
// generate structure
CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements);
IProblemFactory factory = new DefaultProblemFactory();
-// SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(getJavaProject().getOptions(true)));
- SourceElementParser parser = new SourceElementParser(requestor, factory);
+ SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(getJavaProject().getOptions(true)));
+// SourceElementParser parser = new SourceElementParser(requestor, factory);
requestor.parser = parser;
parser.parseCompilationUnit(this, false);
if (isWorkingCopy()) {
package net.sourceforge.phpdt.internal.core;
import java.util.Locale;
+import java.util.Map;
import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaProject;
import net.sourceforge.phpdt.core.IPackageFragment;
import net.sourceforge.phpdt.core.IProblemRequestor;
-import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.CompilationResult;
protected CompilationUnitProblemFinder(
INameEnvironment environment,
IErrorHandlingPolicy policy,
-// Map settings,
+ Map settings,
ICompilerRequestor requestor,
IProblemFactory problemFactory) {
- super(environment, policy, requestor, problemFactory, true);//settings, requestor, problemFactory, true);
+ super(environment, policy, settings, requestor, problemFactory, true);
}
/**
new CompilationUnitProblemFinder(
getNameEnvironment(unitElement),
getHandlingPolicy(),
- getRequestor(),
- getProblemFactory(fileName, problemRequestor, monitor));
-// project.getOptions(true),
-// getRequestor(),
-// getProblemFactory(fileName, problemRequestor, monitor));
+ project.getOptions(true),
+ getRequestor(),
+ getProblemFactory(fileName, problemRequestor, monitor));
CompilationUnitDeclaration unit = null;
try {
return new Compiler(
nameEnvironment,
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
-// javaBuilder.javaProject.getOptions(true),
+ javaBuilder.javaProject.getOptions(true),
this,
ProblemFactory.getProblemFactory(Locale.getDefault()));
}
import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.core.jdom.IDOMCompilationUnit;
-import net.sourceforge.phpdt.core.jdom.IDOMField;
-import net.sourceforge.phpdt.core.jdom.IDOMImport;
-import net.sourceforge.phpdt.core.jdom.IDOMInitializer;
-import net.sourceforge.phpdt.core.jdom.IDOMMethod;
+import net.sourceforge.phpdt.core.jdom.IDOMFactory;
import net.sourceforge.phpdt.core.jdom.IDOMNode;
import net.sourceforge.phpdt.core.jdom.IDOMPackage;
-import net.sourceforge.phpdt.core.jdom.IDOMType;
import net.sourceforge.phpdt.internal.compiler.DocumentElementParser;
import net.sourceforge.phpdt.internal.compiler.IDocumentElementRequestor;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
import net.sourceforge.phpdt.internal.core.util.CharArrayOps;
* Creates a new parser.
*/
protected DocumentElementParser getParser(Map settings) {
- return new DocumentElementParser(this, new DefaultProblemFactory());//, new CompilerOptions(settings));
+ return new DocumentElementParser(this, new DefaultProblemFactory(), new CompilerOptions(settings));
}
/**
* Initializes the builder to create a document fragment.
import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.core.jdom.IDOMCompilationUnit;
+import net.sourceforge.phpdt.core.jdom.IDOMFactory;
import net.sourceforge.phpdt.internal.compiler.ISourceElementRequestor;
import net.sourceforge.phpdt.internal.compiler.SourceElementParser;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
import net.sourceforge.phpdt.internal.core.util.CharArrayOps;
* Creates a new parser.
*/
protected SourceElementParser getParser(Map settings) {
- return new SourceElementParser(this, new DefaultProblemFactory());//, new CompilerOptions(settings));
+ return new SourceElementParser(this, new DefaultProblemFactory(), new CompilerOptions(settings));
}
}
package net.sourceforge.phpdt.internal.corext.codemanipulation;
import net.sourceforge.phpdt.core.ICodeFormatter;
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.core.ToolFactory;
import org.eclipse.jface.text.BadLocationException;
// return null;
// }
//
-// public static String getTodoTaskTag(IJavaProject project) {
-// String markers= null;
-// if (project == null) {
-// markers= JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS);
-// } else {
-// markers= project.getOption(JavaCore.COMPILER_TASK_TAGS, true);
-// }
-//
-// if (markers != null && markers.length() > 0) {
-// int idx= markers.indexOf(',');
-// if (idx == -1) {
-// return markers;
-// } else {
-// return markers.substring(0, idx);
-// }
-// }
-// return null;
-// }
+ public static String getTodoTaskTag(IJavaProject project) {
+ String markers= null;
+ if (project == null) {
+ markers= JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS);
+ } else {
+ markers= project.getOption(JavaCore.COMPILER_TASK_TAGS, true);
+ }
+
+ if (markers != null && markers.length() > 0) {
+ int idx= markers.indexOf(',');
+ if (idx == -1) {
+ return markers;
+ } else {
+ return markers.substring(0, idx);
+ }
+ }
+ return null;
+ }
}
, true /* whitespace */
, false /* nls */
, false /* assert */
- , true /* tokenizeStrings */
- ); // regular scanner for forming lines
+ , true, /* tokenizeStrings */
+ null, null); // regular scanner for forming lines
scanner.recordLineSeparator = true;
// to remind of the position of the beginning of the line.
splitScanner = new Scanner(true /* comment */
, true /* whitespace */
, false /* nls */
, false /* assert */
- , true /* tokenizeStrings */
- );
+ , true, /* tokenizeStrings */
+ null, null);
// secondary scanner to split long lines formed by primary scanning
// initialize current line buffer
currentLineBuffer = new StringBuffer();
/**
* Option IDs
*/
- public static final String OPTION_InsertNewlineBeforeOpeningBrace = "net.sourceforge.phpeclipse.core.formatter.newline.openingBrace"; //$NON-NLS-1$
- public static final String OPTION_InsertNewlineInControlStatement = "net.sourceforge.phpeclipse.core.formatter.newline.controlStatement"; //$NON-NLS-1$
- // public static final String OPTION_InsertNewLineBetweenElseAndIf = "net.sourceforge.phpeclipse.core.formatter.newline.elseIf"; //$NON-NLS-1$
- public static final String OPTION_InsertNewLineInEmptyBlock = "net.sourceforge.phpeclipse.core.formatter.newline.emptyBlock"; //$NON-NLS-1$
- public static final String OPTION_ClearAllBlankLines = "net.sourceforge.phpeclipse.core.formatter.newline.clearAll"; //$NON-NLS-1$
- public static final String OPTION_SplitLineExceedingLength = "net.sourceforge.phpeclipse.core.formatter.lineSplit"; //$NON-NLS-1$
- public static final String OPTION_CompactAssignment = "net.sourceforge.phpeclipse.core.formatter.style.assignment"; //$NON-NLS-1$
- public static final String OPTION_TabulationChar = "net.sourceforge.phpeclipse.core.formatter.tabulation.char"; //$NON-NLS-1$
- public static final String OPTION_TabulationSize = "net.sourceforge.phpeclipse.core.formatter.tabulation.size"; //$NON-NLS-1$
- public static final String OPTION_CompactDereferencing = "net.sourceforge.phpeclipse.core.formatter.style.assignment";
+ public static final String OPTION_InsertNewlineBeforeOpeningBrace = "net.sourceforge.phpeclipse.formatter.newline.openingBrace"; //$NON-NLS-1$
+ public static final String OPTION_InsertNewlineInControlStatement = "net.sourceforge.phpeclipse.formatter.newline.controlStatement"; //$NON-NLS-1$
+ // public static final String OPTION_InsertNewLineBetweenElseAndIf = "net.sourceforge.phpeclipse.formatter.newline.elseIf"; //$NON-NLS-1$
+ public static final String OPTION_InsertNewLineInEmptyBlock = "net.sourceforge.phpeclipse.formatter.newline.emptyBlock"; //$NON-NLS-1$
+ public static final String OPTION_ClearAllBlankLines = "net.sourceforge.phpeclipse.formatter.newline.clearAll"; //$NON-NLS-1$
+ public static final String OPTION_SplitLineExceedingLength = "net.sourceforge.phpeclipse.formatter.lineSplit"; //$NON-NLS-1$
+ public static final String OPTION_CompactAssignment = "net.sourceforge.phpeclipse.formatter.style.assignment"; //$NON-NLS-1$
+ public static final String OPTION_TabulationChar = "net.sourceforge.phpeclipse.formatter.tabulation.char"; //$NON-NLS-1$
+ public static final String OPTION_TabulationSize = "net.sourceforge.phpeclipse.formatter.tabulation.size"; //$NON-NLS-1$
+ public static final String OPTION_CompactDereferencing = "net.sourceforge.phpeclipse.formatter.style.assignment";
// TODO: add the checkbox in the preferences panel ; load/save
public static final String INSERT = "insert"; //$NON-NLS-1$
boolean wasJavadoc= false; // true if the previous partition is javadoc
- if (partType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ if (partType == IPHPPartitions.PHP_PHPDOC_COMMENT) {
wasJavadoc= true;
} else { // !wasJavadoc
- if (partType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ if (partType == IPHPPartitions.PHP_PHPDOC_COMMENT) {
// if next is javadoc, end block comment before
edits.add(factory.createEdit(partition.getOffset(), 0, getCommentEnd()));
// } else if (partType == IJavaPartitions.JAVA_MULTI_LINE_COMMENT) {
private boolean isSpecialPartition(String partType) {
return// partType == IPHPPartitions.PHP_CHARACTER
//||
- partType == IPHPPartitions.PHP_STRING;
+ partType == IPHPPartitions.PHP_STRING_DQ;
//|| partType == IPHPPartitions.PHP_SINGLE_LINE_COMMENT;
}
while (partEndOffset < endOffset) {
- if (partition.getType() == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ if (partition.getType() == IPHPPartitions.PHP_PHPDOC_COMMENT) {
edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
}
partEndOffset= partOffset + partition.getLength();
}
- if (partition.getType() == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ if (partition.getType() == IPHPPartitions.PHP_PHPDOC_COMMENT) {
edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
}
private Button fBackgroundCustomRadioButton;
private Button fBackgroundColorButton;
private Button fBoldCheckBox;
- // private Button fAddJavaDocTagsButton;
- // private Button fEscapeStringsButton;
+ private Button fAddJavaDocTagsButton;
+ private Button fEscapeStringsButton;
// private Button fGuessMethodArgumentsButton;
private SourceViewer fPreviewViewer;
private Color fBackgroundColor;
.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
PreferenceConstants.EDITOR_SMART_PASTE));
- // overlayKeys.add(new
- // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- // PreferenceConstants.EDITOR_CLOSE_STRINGS));
- // overlayKeys.add(new
- // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- // PreferenceConstants.EDITOR_CLOSE_BRACKETS));
+ overlayKeys.add(new
+ OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP));
+ overlayKeys.add(new
+ OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
overlayKeys
.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
PreferenceConstants.EDITOR_WRAP_STRINGS));
- // overlayKeys.add(new
- // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- // PreferenceConstants.EDITOR_ESCAPE_STRINGS));
+ overlayKeys.add(new
+ OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_ESCAPE_STRINGS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
PreferenceConstants.EDITOR_SMART_HOME_END));
- // overlayKeys.add(new
- // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
- // overlayKeys.add(new
- // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
+ overlayKeys.add(new
+ OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
+ overlayKeys.add(new
+ OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
// overlayKeys.add(new
// OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
// PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
- // String label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.overwriteMode");
- // //$NON-NLS-1$
- // addCheckBox(composite, label,
- // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
- // addFiller(composite);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd");
- // //$NON-NLS-1$
- // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END,
- // 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation");
- // //$NON-NLS-1$
- // addCheckBox(composite, label,
- // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
- addFiller(composite);
+ String label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.overwriteMode");
+ //$NON-NLS-1$
+ addCheckBox(composite, label,
+ PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
+ addFiller(composite);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd");
+ //$NON-NLS-1$
+ addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END,
+ 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation");
+ //$NON-NLS-1$
+ addCheckBox(composite, label,
+ PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
+ addFiller(composite);
Group group = new Group(composite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
group.setLayout(layout);
group.setText(PreferencesMessages
.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings");
- // //$NON-NLS-1$
- // Button button= addCheckBox(group, label,
- // PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings");
- // //$NON-NLS-1$
- // fEscapeStringsButton= addCheckBox(group, label,
- // PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
- // createDependency(button, fEscapeStringsButton);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
- // //$NON-NLS-1$
- // addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
- // //$NON-NLS-1$
- // addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS,
- // 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings");
- // //$NON-NLS-1$
- // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
- // //$NON-NLS-1$
- // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces");
- // //$NON-NLS-1$
- // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs");
- // //$NON-NLS-1$
- // button= addCheckBox(group, label,
- // PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
- //
- // label=
- // PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags");
- // //$NON-NLS-1$
- // fAddJavaDocTagsButton= addCheckBox(group, label,
- // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
- // createDependency(button, fAddJavaDocTagsButton);
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings");
+ //$NON-NLS-1$
+ Button button= addCheckBox(group, label,
+ PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings");
+ //$NON-NLS-1$
+ fEscapeStringsButton= addCheckBox(group, label,
+ PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
+ createDependency(button, fEscapeStringsButton);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
+ //$NON-NLS-1$
+ addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
+ //$NON-NLS-1$
+ addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS,
+ 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings");
+ //$NON-NLS-1$
+ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP, 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
+ //$NON-NLS-1$
+ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces");
+ //$NON-NLS-1$
+ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs");
+ //$NON-NLS-1$
+ button= addCheckBox(group, label,
+ PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
+
+ label=
+ PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags");
+ //$NON-NLS-1$
+ fAddJavaDocTagsButton= addCheckBox(group, label,
+ PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
+ createDependency(button, fAddJavaDocTagsButton);
return composite;
}
private void addFiller(Composite composite) {
item.setText(PreferencesMessages
.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
item.setControl(createSyntaxPage(folder));
- // item= new TabItem(folder, SWT.NONE);
- // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist"));
- // //$NON-NLS-1$
- // item.setControl(createContentAssistPage(folder));
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist"));
+ //$NON-NLS-1$
+ item.setControl(createContentAssistPage(folder));
item = new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages
.getString("JavaEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$
item.setControl(createAnnotationsPage(folder));
- // item= new TabItem(folder, SWT.NONE);
- // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
- // //$NON-NLS-1$
- // item.setControl(createTypingPage(folder));
- //
- // item= new TabItem(folder, SWT.NONE);
- // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
- // //$NON-NLS-1$
- // fJavaEditorHoverConfigurationBlock= new
- // JavaEditorHoverConfigurationBlock(this, fOverlayStore);
- // item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
- // item= new TabItem(folder, SWT.NONE);
- // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
- // //$NON-NLS-1$
- // item.setControl(createNavigationPage(folder));
- //
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
+ //$NON-NLS-1$
+ item.setControl(createTypingPage(folder));
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
+ //$NON-NLS-1$
+ fJavaEditorHoverConfigurationBlock= new
+ JavaEditorHoverConfigurationBlock(this, fOverlayStore);
+ item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
+ //$NON-NLS-1$
+ item.setControl(createNavigationPage(folder));
+
initialize();
Dialog.applyDialogFont(folder);
return folder;
fBackgroundDefaultRadioButton.setSelection(default_);
fBackgroundCustomRadioButton.setSelection(!default_);
fBackgroundColorButton.setEnabled(!default_);
- // boolean closeJavaDocs=
- // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
- // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
- // fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
+ boolean closeJavaDocs=
+ fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
+ fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
+ fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
// boolean fillMethodArguments=
// fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
// fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ */
+public abstract class OptionsConfigurationBlock {
+
+ protected static class ControlData {
+ private String fKey;
+ private String[] fValues;
+
+ public ControlData(String key, String[] values) {
+ fKey= key;
+ fValues= values;
+ }
+
+ public String getKey() {
+ return fKey;
+ }
+
+ public String getValue(boolean selection) {
+ int index= selection ? 0 : 1;
+ return fValues[index];
+ }
+
+ public String getValue(int index) {
+ return fValues[index];
+ }
+
+ public int getSelection(String value) {
+ for (int i= 0; i < fValues.length; i++) {
+ if (value.equals(fValues[i])) {
+ return i;
+ }
+ }
+ return 0;
+ }
+ }
+
+
+ protected Map fWorkingValues;
+
+ protected ArrayList fCheckBoxes;
+ protected ArrayList fComboBoxes;
+ protected ArrayList fTextBoxes;
+ protected HashMap fLabels;
+
+ private SelectionListener fSelectionListener;
+ private ModifyListener fTextModifyListener;
+
+ protected IStatusChangeListener fContext;
+ protected IJavaProject fProject; // project or null
+
+ private Shell fShell;
+
+ public OptionsConfigurationBlock(IStatusChangeListener context, IJavaProject project) {
+ fContext= context;
+ fProject= project;
+
+ fWorkingValues= getOptions(true);
+
+ fCheckBoxes= new ArrayList();
+ fComboBoxes= new ArrayList();
+ fTextBoxes= new ArrayList(2);
+ fLabels= new HashMap();
+ }
+
+ protected abstract String[] getAllKeys();
+
+ protected Map getOptions(boolean inheritJavaCoreOptions) {
+ if (fProject != null) {
+ return fProject.getOptions(inheritJavaCoreOptions);
+ } else {
+ return JavaCore.getOptions();
+ }
+ }
+
+ protected Map getDefaultOptions() {
+ return JavaCore.getDefaultOptions();
+ }
+
+ public final boolean hasProjectSpecificOptions() {
+ if (fProject != null) {
+ Map settings= fProject.getOptions(false);
+ String[] allKeys= getAllKeys();
+ for (int i= 0; i < allKeys.length; i++) {
+ if (settings.get(allKeys[i]) != null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected void setOptions(Map map) {
+ if (fProject != null) {
+ fProject.setOptions(map);
+ } else {
+ JavaCore.setOptions((Hashtable) map);
+ }
+ }
+
+ protected Shell getShell() {
+ return fShell;
+ }
+
+ protected void setShell(Shell shell) {
+ fShell= shell;
+ }
+
+ protected abstract Control createContents(Composite parent);
+
+ protected Button addCheckBox(Composite parent, String label, String key, String[] values, int indent) {
+ ControlData data= new ControlData(key, values);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 3;
+ gd.horizontalIndent= indent;
+
+ Button checkBox= new Button(parent, SWT.CHECK);
+ checkBox.setText(label);
+ checkBox.setData(data);
+ checkBox.setLayoutData(gd);
+ checkBox.addSelectionListener(getSelectionListener());
+
+ String currValue= (String)fWorkingValues.get(key);
+ checkBox.setSelection(data.getSelection(currValue) == 0);
+
+ fCheckBoxes.add(checkBox);
+
+ return checkBox;
+ }
+
+ protected Combo addComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels, int indent) {
+ ControlData data= new ControlData(key, values);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indent;
+
+ Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP);
+ labelControl.setText(label);
+ labelControl.setLayoutData(gd);
+
+ Combo comboBox= new Combo(parent, SWT.READ_ONLY);
+ comboBox.setItems(valueLabels);
+ comboBox.setData(data);
+ comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ comboBox.addSelectionListener(getSelectionListener());
+
+ fLabels.put(comboBox, labelControl);
+
+ Label placeHolder= new Label(parent, SWT.NONE);
+ placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ String currValue= (String)fWorkingValues.get(key);
+ comboBox.select(data.getSelection(currValue));
+
+ fComboBoxes.add(comboBox);
+ return comboBox;
+ }
+
+ protected void addInversedComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels, int indent) {
+ ControlData data= new ControlData(key, values);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indent;
+ gd.horizontalSpan= 3;
+
+ Composite composite= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(gd);
+
+ Combo comboBox= new Combo(composite, SWT.READ_ONLY);
+ comboBox.setItems(valueLabels);
+ comboBox.setData(data);
+ comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ comboBox.addSelectionListener(getSelectionListener());
+
+ Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
+ labelControl.setText(label);
+ labelControl.setLayoutData(new GridData());
+
+ fLabels.put(comboBox, labelControl);
+
+ String currValue= (String)fWorkingValues.get(key);
+ comboBox.select(data.getSelection(currValue));
+
+ fComboBoxes.add(comboBox);
+ }
+
+ protected Text addTextField(Composite parent, String label, String key, int indent, int widthHint) {
+ Label labelControl= new Label(parent, SWT.NONE);
+ labelControl.setText(label);
+ labelControl.setLayoutData(new GridData());
+
+ Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
+ textBox.setData(key);
+ textBox.setLayoutData(new GridData());
+
+ fLabels.put(textBox, labelControl);
+
+ String currValue= (String) fWorkingValues.get(key);
+ textBox.setText(currValue);
+ textBox.addModifyListener(getTextModifyListener());
+
+ GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ if (widthHint != 0) {
+ data.widthHint= widthHint;
+ }
+ data.horizontalIndent= indent;
+ data.horizontalSpan= 2;
+ textBox.setLayoutData(data);
+
+ fTextBoxes.add(textBox);
+ return textBox;
+ }
+
+ protected SelectionListener getSelectionListener() {
+ if (fSelectionListener == null) {
+ fSelectionListener= new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
+ public void widgetSelected(SelectionEvent e) {
+ controlChanged(e.widget);
+ }
+ };
+ }
+ return fSelectionListener;
+ }
+
+ protected ModifyListener getTextModifyListener() {
+ if (fTextModifyListener == null) {
+ fTextModifyListener= new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ textChanged((Text) e.widget);
+ }
+ };
+ }
+ return fTextModifyListener;
+ }
+
+ protected void controlChanged(Widget widget) {
+ ControlData data= (ControlData) widget.getData();
+ String newValue= null;
+ if (widget instanceof Button) {
+ newValue= data.getValue(((Button)widget).getSelection());
+ } else if (widget instanceof Combo) {
+ newValue= data.getValue(((Combo)widget).getSelectionIndex());
+ } else {
+ return;
+ }
+ fWorkingValues.put(data.getKey(), newValue);
+
+ validateSettings(data.getKey(), newValue);
+ }
+
+ protected void textChanged(Text textControl) {
+ String key= (String) textControl.getData();
+ String number= textControl.getText();
+ fWorkingValues.put(key, number);
+ validateSettings(key, number);
+ }
+
+ protected boolean checkValue(String key, String value) {
+ return value.equals(fWorkingValues.get(key));
+ }
+
+ /* (non-javadoc)
+ * Update fields and validate.
+ * @param changedKey Key that changed, or null, if all changed.
+ */
+ protected abstract void validateSettings(String changedKey, String newValue);
+
+
+ protected String[] getTokens(String text, String separator) {
+ StringTokenizer tok= new StringTokenizer(text, separator); //$NON-NLS-1$
+ int nTokens= tok.countTokens();
+ String[] res= new String[nTokens];
+ for (int i= 0; i < res.length; i++) {
+ res[i]= tok.nextToken().trim();
+ }
+ return res;
+ }
+
+
+ public boolean performOk(boolean enabled) {
+ String[] allKeys= getAllKeys();
+ Map actualOptions= getOptions(false);
+
+ // preserve other options
+ boolean hasChanges= false;
+ for (int i= 0; i < allKeys.length; i++) {
+ String key= allKeys[i];
+ String oldVal= (String) actualOptions.get(key);
+ String val= null;
+ if (enabled) {
+ val= (String) fWorkingValues.get(key);
+ if (!val.equals(oldVal)) {
+ hasChanges= true;
+ actualOptions.put(key, val);
+ }
+ } else {
+ if (oldVal != null) {
+ actualOptions.remove(key);
+ hasChanges= true;
+ }
+ }
+ }
+
+
+ if (hasChanges) {
+ boolean doBuild= false;
+ String[] strings= getFullBuildDialogStrings(fProject == null);
+ if (strings != null) {
+ MessageDialog dialog= new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
+ int res= dialog.open();
+ if (res == 0) {
+ doBuild= true;
+ } else if (res != 1) {
+ return false; // cancel pressed
+ }
+ }
+ setOptions(actualOptions);
+ if (doBuild) {
+ doFullBuild();
+ }
+ }
+ return true;
+ }
+
+ protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings);
+
+ protected void doFullBuild() {
+ ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ monitor.beginTask("", 2); //$NON-NLS-1$
+ try {
+ if (fProject != null) {
+ monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.buildproject.taskname", fProject.getElementName())); //$NON-NLS-1$
+ fProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1));
+ PHPeclipsePlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor,1));
+ } else {
+ monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.buildall.taskname")); //$NON-NLS-1$
+ PHPeclipsePlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor, 2));
+ }
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ // cancelled by user
+ } catch (InvocationTargetException e) {
+ String title= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.title"); //$NON-NLS-1$
+ String message= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.message"); //$NON-NLS-1$
+ ExceptionHandler.handle(e, getShell(), title, message);
+ }
+ }
+
+ public void performDefaults() {
+ fWorkingValues= getDefaultOptions();
+ updateControls();
+ validateSettings(null, null);
+ }
+
+ protected void updateControls() {
+ // update the UI
+ for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
+ Button curr= (Button) fCheckBoxes.get(i);
+ ControlData data= (ControlData) curr.getData();
+
+ String currValue= (String) fWorkingValues.get(data.getKey());
+ curr.setSelection(data.getSelection(currValue) == 0);
+ }
+ for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
+ Combo curr= (Combo) fComboBoxes.get(i);
+ ControlData data= (ControlData) curr.getData();
+
+ String currValue= (String) fWorkingValues.get(data.getKey());
+ curr.select(data.getSelection(currValue));
+ }
+ for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
+ Text curr= (Text) fTextBoxes.get(i);
+ String key= (String) curr.getData();
+
+ String currValue= (String) fWorkingValues.get(key);
+ curr.setText(currValue);
+ }
+ }
+
+ protected Button getCheckBox(String key) {
+ for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
+ Button curr= (Button) fCheckBoxes.get(i);
+ ControlData data= (ControlData) curr.getData();
+ if (key.equals(data.getKey())) {
+ return curr;
+ }
+ }
+ return null;
+ }
+
+ protected Combo getComboBox(String key) {
+ for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
+ Combo curr= (Combo) fComboBoxes.get(i);
+ ControlData data= (ControlData) curr.getData();
+ if (key.equals(data.getKey())) {
+ return curr;
+ }
+ }
+ return null;
+ }
+
+ protected void setComboEnabled(String key, boolean enabled) {
+ Combo combo= getComboBox(key);
+ Label label= (Label) fLabels.get(combo);
+ combo.setEnabled(enabled);
+ label.setEnabled(enabled);
+ }
+
+
+
+}
PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML, 1);
return composite;
}
+
private static void indent(Control control) {
GridData gridData = new GridData();
gridData.horizontalIndent = 20;
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
+ initializeDefaultColors();
fOverlayStore.load();
fOverlayStore.start();
TabFolder folder = new TabFolder(parent, SWT.NONE);
item.setText(PHPUIMessages
.getString("PHPEditorPreferencePage.behaviourTab.title")); //$NON-NLS-1$
item.setControl(createBehaviourPage(folder));
- // item= new TabItem(folder, SWT.NONE);
- // item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title"));
- // //$NON-NLS-1$
- // fJavaEditorHoverConfigurationBlock= new
- // JavaEditorHoverConfigurationBlock(fOverlayStore);
- // item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title"));
+ //$NON-NLS-1$
+// fJavaEditorHoverConfigurationBlock= new
+// JavaEditorHoverConfigurationBlock(fOverlayStore);
+// item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
initialize();
return folder;
}
updateAutoactivationControls();
// fJavaEditorHoverConfigurationBlock.initializeFields();
}
+
+ private void initializeDefaultColors() {
+ if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
+ RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
+ PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
+ PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
+ }
+ if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
+ RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
+ PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
+ PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
+ }
+ }
+
private void updateAutoactivationControls() {
boolean autoactivation = fOverlayStore
.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.core.JavaCore;
+
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
+import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.DialogField;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.IListAdapter;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+/**
+ */
+public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
+
+ private static final String PREF_COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS;
+ private static final String PREF_COMPILER_TASK_PRIORITIES= JavaCore.COMPILER_TASK_PRIORITIES;
+
+ private static final String PRIORITY_HIGH= JavaCore.COMPILER_TASK_PRIORITY_HIGH;
+ private static final String PRIORITY_NORMAL= JavaCore.COMPILER_TASK_PRIORITY_NORMAL;
+ private static final String PRIORITY_LOW= JavaCore.COMPILER_TASK_PRIORITY_LOW;
+
+ public static class TodoTask {
+ public String name;
+ public String priority;
+ }
+
+ private static class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object element) {
+ return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ TodoTask task= (TodoTask) element;
+ if (columnIndex == 0) {
+ return task.name;
+ } else {
+ if (PRIORITY_HIGH.equals(task.priority)) {
+ return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.high.priority"); //$NON-NLS-1$
+ } else if (PRIORITY_NORMAL.equals(task.priority)) {
+ return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.normal.priority"); //$NON-NLS-1$
+ } else if (PRIORITY_LOW.equals(task.priority)) {
+ return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.low.priority"); //$NON-NLS-1$
+ }
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ }
+
+ private static final int IDX_ADD= 0;
+ private static final int IDX_EDIT= 1;
+ private static final int IDX_REMOVE= 2;
+
+ private IStatus fTaskTagsStatus;
+ private ListDialogField fTodoTasksList;
+
+ public TodoTaskConfigurationBlock(IStatusChangeListener context, IJavaProject project) {
+ super(context, project);
+
+ TaskTagAdapter adapter= new TaskTagAdapter();
+ String[] buttons= new String[] {
+ /* 0 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.add.button"), //$NON-NLS-1$
+ /* 1 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.edit.button"), //$NON-NLS-1$
+ /* 2 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.remove.button"), //$NON-NLS-1$
+
+ };
+ fTodoTasksList= new ListDialogField(adapter, buttons, new TodoTaskLabelProvider());
+ fTodoTasksList.setDialogFieldListener(adapter);
+ fTodoTasksList.setLabelText(PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.label")); //$NON-NLS-1$
+ fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
+
+ String[] columnsHeaders= new String[] {
+ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.name.column"), //$NON-NLS-1$
+ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.priority.column"), //$NON-NLS-1$
+ };
+
+ fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
+ unpackTodoTasks();
+ if (fTodoTasksList.getSize() > 0) {
+ fTodoTasksList.selectFirstElement();
+ } else {
+ fTodoTasksList.enableButton(IDX_EDIT, false);
+ }
+
+ fTaskTagsStatus= new StatusInfo();
+ }
+
+ protected final String[] getAllKeys() {
+ return new String[] {
+ PREF_COMPILER_TASK_TAGS, PREF_COMPILER_TASK_PRIORITIES
+ };
+ }
+
+ public class TaskTagAdapter implements IListAdapter, IDialogFieldListener {
+
+ private boolean canEdit(ListDialogField field) {
+ return field.getSelectedElements().size() == 1;
+ }
+
+ public void customButtonPressed(ListDialogField field, int index) {
+ doTodoButtonPressed(index);
+ }
+
+ public void selectionChanged(ListDialogField field) {
+ field.enableButton(IDX_EDIT, canEdit(field));
+ }
+
+ public void doubleClicked(ListDialogField field) {
+ if (canEdit(field)) {
+ doTodoButtonPressed(IDX_EDIT);
+ }
+ }
+
+ public void dialogFieldChanged(DialogField field) {
+ validateSettings(PREF_COMPILER_TASK_TAGS, null);
+ }
+
+ }
+
+ protected Control createContents(Composite parent) {
+ setShell(parent.getShell());
+
+ Composite markersComposite= createMarkersTabContent(parent);
+
+ validateSettings(null, null);
+
+ return markersComposite;
+ }
+
+ private Composite createMarkersTabContent(Composite folder) {
+
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+
+ Composite markersComposite= new Composite(folder, SWT.NULL);
+ markersComposite.setLayout(layout);
+
+ fTodoTasksList.doFillIntoGrid(markersComposite, 3);
+ LayoutUtil.setHorizontalSpan(fTodoTasksList.getLabelControl(null), 2);
+
+ GridData data= (GridData)fTodoTasksList.getListControl(null).getLayoutData();
+ data.grabExcessHorizontalSpace= true;
+ data.grabExcessVerticalSpace= true;
+ data.verticalAlignment= GridData.FILL;
+ //data.heightHint= SWTUtil.getTableHeightHint(table, 6);
+
+ return markersComposite;
+ }
+
+ protected void validateSettings(String changedKey, String newValue) {
+ if (changedKey != null) {
+ if (PREF_COMPILER_TASK_TAGS.equals(changedKey)) {
+ fTaskTagsStatus= validateTaskTags();
+ } else {
+ return;
+ }
+ } else {
+ fTaskTagsStatus= validateTaskTags();
+ }
+ IStatus status= fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus });
+ fContext.statusChanged(status);
+ }
+
+ private IStatus validateTaskTags() {
+ return new StatusInfo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performOk(boolean)
+ */
+ public boolean performOk(boolean enabled) {
+ packTodoTasks();
+ return super.performOk(enabled);
+ }
+
+
+ protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
+ String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
+ String message;
+ if (fProject == null) {
+ message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
+ } else {
+ message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
+ }
+ return new String[] { title, message };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
+ */
+ protected void updateControls() {
+ unpackTodoTasks();
+ }
+
+ private void unpackTodoTasks() {
+ String currTags= (String) fWorkingValues.get(PREF_COMPILER_TASK_TAGS);
+ String currPrios= (String) fWorkingValues.get(PREF_COMPILER_TASK_PRIORITIES);
+ String[] tags= getTokens(currTags, ","); //$NON-NLS-1$
+ String[] prios= getTokens(currPrios, ","); //$NON-NLS-1$
+ ArrayList elements= new ArrayList(tags.length);
+ for (int i= 0; i < tags.length; i++) {
+ TodoTask task= new TodoTask();
+ task.name= tags[i].trim();
+ task.priority= (i < prios.length) ? prios[i] : PRIORITY_NORMAL;
+ elements.add(task);
+ }
+ fTodoTasksList.setElements(elements);
+ }
+
+ private void packTodoTasks() {
+ StringBuffer tags= new StringBuffer();
+ StringBuffer prios= new StringBuffer();
+ List list= fTodoTasksList.getElements();
+ for (int i= 0; i < list.size(); i++) {
+ if (i > 0) {
+ tags.append(',');
+ prios.append(',');
+ }
+ TodoTask elem= (TodoTask) list.get(i);
+ tags.append(elem.name);
+ prios.append(elem.priority);
+ }
+ fWorkingValues.put(PREF_COMPILER_TASK_TAGS, tags.toString());
+ fWorkingValues.put(PREF_COMPILER_TASK_PRIORITIES, prios.toString());
+ }
+
+ private void doTodoButtonPressed(int index) {
+ TodoTask edited= null;
+ if (index != IDX_ADD) {
+ edited= (TodoTask) fTodoTasksList.getSelectedElements().get(0);
+ }
+
+ TodoTaskInputDialog dialog= new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
+ if (dialog.open() == Window.OK) {
+ if (edited != null) {
+ fTodoTasksList.replaceElement(edited, dialog.getResult());
+ } else {
+ fTodoTasksList.addElement(dialog.getResult());
+ }
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.ui.help.WorkbenchHelp;
+
+import net.sourceforge.phpdt.core.JavaCore;
+
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusDialog;
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
+import net.sourceforge.phpdt.internal.ui.preferences.TodoTaskConfigurationBlock.TodoTask;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.ComboDialogField;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.DialogField;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringDialogField;
+
+/**
+ * Dialog to enter a na new task tag
+ */
+public class TodoTaskInputDialog extends StatusDialog {
+
+ private class CompilerTodoTaskInputAdapter implements IDialogFieldListener {
+ public void dialogFieldChanged(DialogField field) {
+ doValidation();
+ }
+ }
+
+ private StringDialogField fNameDialogField;
+ private ComboDialogField fPriorityDialogField;
+
+ private List fExistingNames;
+
+ public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) {
+ super(parent);
+
+ fExistingNames= new ArrayList(existingEntries.size());
+ for (int i= 0; i < existingEntries.size(); i++) {
+ TodoTask curr= (TodoTask) existingEntries.get(i);
+ if (!curr.equals(task)) {
+ fExistingNames.add(curr.name);
+ }
+ }
+
+ if (task == null) {
+ setTitle(PreferencesMessages.getString("TodoTaskInputDialog.new.title")); //$NON-NLS-1$
+ } else {
+ setTitle(PreferencesMessages.getString("TodoTaskInputDialog.edit.title")); //$NON-NLS-1$
+ }
+
+ CompilerTodoTaskInputAdapter adapter= new CompilerTodoTaskInputAdapter();
+
+ fNameDialogField= new StringDialogField();
+ fNameDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.name.label")); //$NON-NLS-1$
+ fNameDialogField.setDialogFieldListener(adapter);
+
+ fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
+
+ String[] items= new String[] {
+ PreferencesMessages.getString("TodoTaskInputDialog.priority.high"), //$NON-NLS-1$
+ PreferencesMessages.getString("TodoTaskInputDialog.priority.normal"), //$NON-NLS-1$
+ PreferencesMessages.getString("TodoTaskInputDialog.priority.low") //$NON-NLS-1$
+ };
+
+ fPriorityDialogField= new ComboDialogField(SWT.READ_ONLY);
+ fPriorityDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.priority.label")); //$NON-NLS-1$
+ fPriorityDialogField.setItems(items);
+ if (task != null) {
+ if (JavaCore.COMPILER_TASK_PRIORITY_HIGH.equals(task.priority)) {
+ fPriorityDialogField.selectItem(0);
+ } else if (JavaCore.COMPILER_TASK_PRIORITY_NORMAL.equals(task.priority)) {
+ fPriorityDialogField.selectItem(1);
+ } else {
+ fPriorityDialogField.selectItem(2);
+ }
+ } else {
+ fPriorityDialogField.selectItem(1);
+ }
+ }
+
+ public TodoTask getResult() {
+ TodoTask task= new TodoTask();
+ task.name= fNameDialogField.getText().trim();
+ switch (fPriorityDialogField.getSelectionIndex()) {
+ case 0 :
+ task.priority= JavaCore.COMPILER_TASK_PRIORITY_HIGH;
+ break;
+ case 1 :
+ task.priority= JavaCore.COMPILER_TASK_PRIORITY_NORMAL;
+ break;
+ default :
+ task.priority= JavaCore.COMPILER_TASK_PRIORITY_LOW;
+ break;
+ }
+ return task;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite= (Composite) super.createDialogArea(parent);
+
+ Composite inner= new Composite(composite, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ inner.setLayout(layout);
+
+ fNameDialogField.doFillIntoGrid(inner, 2);
+ fPriorityDialogField.doFillIntoGrid(inner, 2);
+
+ LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
+ LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
+
+ fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
+
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ private void doValidation() {
+ StatusInfo status= new StatusInfo();
+ String newText= fNameDialogField.getText();
+ if (newText.length() == 0) {
+ status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.enterName")); //$NON-NLS-1$
+ } else {
+ if (newText.indexOf(',') != -1) {
+ status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.comma")); //$NON-NLS-1$
+ } else if (fExistingNames.contains(newText)) {
+ status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.entryExists")); //$NON-NLS-1$
+ } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
+ status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.noSpace")); //$NON-NLS-1$
+ }
+ }
+ updateStatus(status);
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.TODO_TASK_INPUT_DIALOG);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
+import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/*
+ * The page to configure the compiler options.
+ */
+public class TodoTaskPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IStatusChangeListener {
+
+ public static final String ID= "org.eclipse.jdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$
+
+ private TodoTaskConfigurationBlock fConfigurationBlock;
+
+ public TodoTaskPreferencePage() {
+ setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
+ //setDescription(PreferencesMessages.getString("TodoTaskPreferencePage.description")); //$NON-NLS-1$
+
+ // only used when page is shown programatically
+ setTitle(PreferencesMessages.getString("TodoTaskPreferencePage.title")); //$NON-NLS-1$
+
+ fConfigurationBlock= new TodoTaskConfigurationBlock(this, null);
+ }
+
+ /*
+ * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /*
+ * @see PreferencePage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ // added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages
+ super.createControl(parent);
+ WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PREFERENCE_PAGE);
+ }
+
+ /*
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Control result= fConfigurationBlock.createContents(parent);
+ Dialog.applyDialogFont(result);
+ return result;
+ }
+
+ /*
+ * @see IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+ if (!fConfigurationBlock.performOk(true)) {
+ return false;
+ }
+ return super.performOk();
+ }
+
+ /*
+ * @see PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ fConfigurationBlock.performDefaults();
+ super.performDefaults();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+ */
+ public void statusChanged(IStatus status) {
+ setValid(!status.matches(IStatus.ERROR));
+ StatusUtil.applyToStatusLine(this, status);
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.jface.dialogs.ControlEnableState;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.IPreferenceNode;
+import org.eclipse.jface.preference.IPreferencePage;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.PreferenceNode;
+import org.eclipse.jface.window.Window;
+
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.IJavaProject;
+
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
+import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.DialogField;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+
+/**
+ * Property page used to configure project specific task tags settings
+ */
+public class TodoTaskPropertyPage extends PropertyPage {
+
+ private TodoTaskConfigurationBlock fConfigurationBlock;
+ private Control fConfigurationBlockControl;
+ private ControlEnableState fBlockEnableState;
+ private SelectionButtonDialogField fUseWorkspaceSettings;
+ private SelectionButtonDialogField fChangeWorkspaceSettings;
+ private SelectionButtonDialogField fUseProjectSettings;
+ private IStatus fBlockStatus;
+
+
+ public TodoTaskPropertyPage() {
+ fBlockStatus= new StatusInfo();
+ fBlockEnableState= null;
+
+ IDialogFieldListener listener= new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ doDialogFieldChanged(field);
+ }
+ };
+
+ fUseWorkspaceSettings= new SelectionButtonDialogField(SWT.RADIO);
+ fUseWorkspaceSettings.setDialogFieldListener(listener);
+ fUseWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.label")); //$NON-NLS-1$
+
+ fChangeWorkspaceSettings= new SelectionButtonDialogField(SWT.PUSH);
+ fChangeWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.change")); //$NON-NLS-1$
+ fChangeWorkspaceSettings.setDialogFieldListener(listener);
+
+ fUseWorkspaceSettings.attachDialogField(fChangeWorkspaceSettings);
+
+ fUseProjectSettings= new SelectionButtonDialogField(SWT.RADIO);
+ fUseProjectSettings.setDialogFieldListener(listener);
+ fUseProjectSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useprojectsettings.label")); //$NON-NLS-1$
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.TODOTASK_PROPERTY_PAGE);
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+ IStatusChangeListener listener= new IStatusChangeListener() {
+ public void statusChanged(IStatus status) {
+ fBlockStatus= status;
+ doStatusChanged();
+ }
+ };
+ fConfigurationBlock= new TodoTaskConfigurationBlock(listener, getProject());
+
+ Composite composite= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 1;
+ composite.setLayout(layout);
+
+ fUseWorkspaceSettings.doFillIntoGrid(composite, 1);
+ LayoutUtil.setHorizontalGrabbing(fUseWorkspaceSettings.getSelectionButton(null));
+
+ fChangeWorkspaceSettings.doFillIntoGrid(composite, 1);
+ GridData data= (GridData) fChangeWorkspaceSettings.getSelectionButton(null).getLayoutData();
+ data.horizontalIndent= convertWidthInCharsToPixels(3);
+ data.horizontalAlignment= GridData.BEGINNING;
+
+ fUseProjectSettings.doFillIntoGrid(composite, 1);
+
+ data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL );
+ data.horizontalSpan= 1;
+ data.horizontalIndent= convertWidthInCharsToPixels(2);
+
+ fConfigurationBlockControl= fConfigurationBlock.createContents(composite);
+ fConfigurationBlockControl.setLayoutData(data);
+
+ boolean useProjectSettings= fConfigurationBlock.hasProjectSpecificOptions();
+
+ fUseProjectSettings.setSelection(useProjectSettings);
+ fUseWorkspaceSettings.setSelection(!useProjectSettings);
+
+ updateEnableState();
+ Dialog.applyDialogFont(composite);
+ return composite;
+ }
+
+ private boolean useProjectSettings() {
+ return fUseProjectSettings.isSelected();
+ }
+
+ private void doDialogFieldChanged(DialogField field) {
+ if (field == fChangeWorkspaceSettings) {
+ TodoTaskPreferencePage page= new TodoTaskPreferencePage();
+ showPreferencePage(TodoTaskPreferencePage.ID, page);
+ } else {
+ updateEnableState();
+ doStatusChanged();
+ }
+ }
+ /**
+ * Method statusChanged.
+ */
+ private void doStatusChanged() {
+ updateStatus(useProjectSettings() ? fBlockStatus : new StatusInfo());
+ }
+
+ /**
+ * Method getProject.
+ */
+ private IJavaProject getProject() {
+ return (IJavaProject) getElement().getAdapter(IJavaElement.class);
+ }
+
+ private void updateEnableState() {
+ if (useProjectSettings()) {
+ if (fBlockEnableState != null) {
+ fBlockEnableState.restore();
+ fBlockEnableState= null;
+ }
+ } else {
+ if (fBlockEnableState == null) {
+ fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
+ }
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ if (useProjectSettings()) {
+ fUseProjectSettings.setSelection(false);
+ fUseWorkspaceSettings.setSelection(true);
+ fConfigurationBlock.performDefaults();
+ }
+ super.performDefaults();
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+ return fConfigurationBlock.performOk(useProjectSettings());
+ }
+
+ private void updateStatus(IStatus status) {
+ setValid(!status.matches(IStatus.ERROR));
+ StatusUtil.applyToStatusLine(this, status);
+ }
+
+ private boolean showPreferencePage(String id, IPreferencePage page) {
+ final IPreferenceNode targetNode = new PreferenceNode(id, page);
+
+ PreferenceManager manager = new PreferenceManager();
+ manager.addToRoot(targetNode);
+ final PreferenceDialog dialog = new PreferenceDialog(getShell(), manager);
+ final boolean [] result = new boolean[] { false };
+ BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+ public void run() {
+ dialog.create();
+ dialog.setMessage(targetNode.getLabelText());
+ result[0]= (dialog.open() == Window.OK);
+ }
+ });
+ return result[0];
+ }
+
+}
}
private static PHPDocCompletionProcessor getJavaDocProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitions.PHP_MULTILINE_COMMENT);
+ IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitions.PHP_PHPDOC_COMMENT);
if (p instanceof PHPDocCompletionProcessor)
return (PHPDocCompletionProcessor) p;
return null;
*/
public class FastJavaPartitionScanner implements IPartitionTokenScanner {
- private final static String SKIP= "__skip"; //$NON-NLS-1$
- public final static String JAVA_STRING= "__php_string"; //$NON-NLS-1$
- public final static String JAVA_SINGLE_LINE_COMMENT= "__php_singleline_comment"; //$NON-NLS-1$
- public final static String JAVA_MULTI_LINE_COMMENT= "__php_multiline_comment"; //$NON-NLS-1$
- public final static String JAVA_DOC= "__php_phpdoc"; //$NON-NLS-1$
+// private final static String SKIP= "__skip"; //$NON-NLS-1$
+// public final static String JAVA_STRING= "__php_string"; //$NON-NLS-1$
+// public final static String JAVA_SINGLE_LINE_COMMENT= "__php_singleline_comment"; //$NON-NLS-1$
+// public final static String JAVA_MULTI_LINE_COMMENT= "__php_multiline_comment"; //$NON-NLS-1$
+// public final static String JAVA_DOC= "__php_phpdoc"; //$NON-NLS-1$
// states
- private static final int JAVA= 0;
- private static final int SINGLE_LINE_COMMENT= 1;
+ private static final int HTML= 0;
+ private static final int SINGLE_LINE_COMMENT= 1;
private static final int MULTI_LINE_COMMENT= 2;
- private static final int JAVADOC= 3;
- private static final int CHARACTER= 4;
- private static final int STRING= 5;
+ private static final int PHPDOC= 3;
+// private static final int CHARACTER= 4;
+ private static final int STRING_SQ= 4; // single quote string
+ private static final int STRING_DQ= 5; // double quote string
+ private static final int PHP= 6; // double quote string
// beginning of prefixes and postfixes
private static final int NONE= 0;
/** The amount of characters already read on first call to nextToken(). */
private int fPrefixLength;
- // emulate JavaPartitionScanner
- private static final boolean fgEmulate= false;
+ // emulate JavaPartitionScanner
+// private static final boolean fgEmulate= false;
private int fJavaOffset;
private int fJavaLength;
private final IToken[] fTokens= new IToken[] {
new Token(null),
- new Token(JAVA_SINGLE_LINE_COMMENT),
- new Token(JAVA_MULTI_LINE_COMMENT),
- new Token(JAVA_DOC),
- new Token(SKIP),
- new Token(JAVA_STRING)
+ new Token(IPHPPartitions.PHP_SINGLELINE_COMMENT),
+ new Token(IPHPPartitions.PHP_MULTILINE_COMMENT),
+ new Token(IPHPPartitions.PHP_PHPDOC_COMMENT),
+ new Token(IPHPPartitions.PHP_STRING_SQ),
+ new Token(IPHPPartitions.PHP_STRING_DQ),
+ new Token(IPHPPartitions.PHP_PARTITIONING),
};
/*
* @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
*/
public IToken nextToken() {
-
- // emulate JavaPartitionScanner
- if (fgEmulate) {
- if (fJavaOffset != -1 && fTokenOffset + fTokenLength != fJavaOffset + fJavaLength) {
- fTokenOffset += fTokenLength;
- return fTokens[JAVA];
- } else {
- fJavaOffset= -1;
- fJavaLength= 0;
- }
- }
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
case ICharacterScanner.EOF:
if (fTokenLength > 0) {
fLast= NONE; // ignore last
- return preFix(fState, JAVA, NONE, 0);
+ return preFix(fState, HTML, NONE, 0);
} else {
fLast= NONE;
}
case '\r':
- // emulate JavaPartitionScanner
- if (!fgEmulate && fLast != CARRIAGE_RETURN) {
+ if ( fLast != CARRIAGE_RETURN) {
fLast= CARRIAGE_RETURN;
fTokenLength++;
continue;
switch (fState) {
case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
+// case CHARACTER:
+ case STRING_SQ:
+ case STRING_DQ:
if (fTokenLength > 0) {
IToken token= fTokens[fState];
// emulate JavaPartitionScanner
- if (fgEmulate) {
- fTokenLength++;
- fLast= NONE;
- fPrefixLength= 0;
- } else {
+// if (fgEmulate) {
+// fTokenLength++;
+// fLast= NONE;
+// fPrefixLength= 0;
+// } else {
fLast= CARRIAGE_RETURN;
fPrefixLength= 1;
- }
+// }
- fState= JAVA;
+ fState= HTML;
return token;
} else {
case '\n':
switch (fState) {
case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
+// case CHARACTER:
+ case STRING_SQ:
+ case STRING_DQ:
// assert(fTokenLength > 0);
return postFix(fState);
}
default:
- if (!fgEmulate && fLast == CARRIAGE_RETURN) {
+ if ( fLast == CARRIAGE_RETURN) {
switch (fState) {
case SINGLE_LINE_COMMENT:
- case CHARACTER:
- case STRING:
+// case CHARACTER:
+ case STRING_SQ:
+ case STRING_DQ:
int last;
int newState;
switch (ch) {
case '/':
last= SLASH;
- newState= JAVA;
+ newState= HTML;
break;
case '*':
last= STAR;
- newState= JAVA;
+ newState= HTML;
break;
case '\'':
last= NONE;
- newState= CHARACTER;
+ // newState= CHARACTER;
+ newState= STRING_SQ;
break;
case '"':
last= NONE;
- newState= STRING;
+ newState= STRING_DQ;
break;
case '\r':
last= CARRIAGE_RETURN;
- newState= JAVA;
+ newState= HTML;
break;
case '\\':
last= BACKSLASH;
- newState= JAVA;
+ newState= HTML;
break;
default:
last= NONE;
- newState= JAVA;
+ newState= HTML;
break;
}
// states
switch (fState) {
- case JAVA:
+ case PHP:
switch (ch) {
case '/':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
- return preFix(JAVA, SINGLE_LINE_COMMENT, NONE, 2);
+ return preFix(PHP, SINGLE_LINE_COMMENT, NONE, 2);
} else {
- preFix(JAVA, SINGLE_LINE_COMMENT, NONE, 2);
+ preFix(PHP, SINGLE_LINE_COMMENT, NONE, 2);
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
break;
case '*':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0)
- return preFix(JAVA, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+ return preFix(PHP, MULTI_LINE_COMMENT, SLASH_STAR, 2);
else {
- preFix(JAVA, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+ preFix(PHP, MULTI_LINE_COMMENT, SLASH_STAR, 2);
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
break;
case '\'':
fLast= NONE; // ignore fLast
if (fTokenLength > 0)
- return preFix(JAVA, CHARACTER, NONE, 1);
+ return preFix(PHP, STRING_SQ, NONE, 1);
else {
- preFix(JAVA, CHARACTER, NONE, 1);
+ preFix(PHP, STRING_SQ, NONE, 1);
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
break;
case '"':
fLast= NONE; // ignore fLast
if (fTokenLength > 0)
- return preFix(JAVA, STRING, NONE, 1);
+ return preFix(PHP, STRING_DQ, NONE, 1);
else {
- preFix(JAVA, STRING, NONE, 1);
+ preFix(PHP, STRING_DQ, NONE, 1);
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
break;
consume();
break;
- case JAVADOC:
+ case PHPDOC:
switch (ch) {
case '/':
switch (fLast) {
return postFix(MULTI_LINE_COMMENT);
case STAR:
- return postFix(JAVADOC);
+ return postFix(PHPDOC);
default:
consume();
if (fLast == SLASH_STAR) {
fLast= SLASH_STAR_STAR;
fTokenLength++;
- fState= JAVADOC;
+ fState= PHPDOC;
} else {
fTokenLength++;
fLast= STAR;
}
break;
- case STRING:
+ case STRING_DQ:
switch (ch) {
case '\\':
fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
case '\"':
if (fLast != BACKSLASH) {
- return postFix(STRING);
+ return postFix(STRING_DQ);
} else {
consume();
}
break;
- case CHARACTER:
+ case STRING_SQ:
switch (ch) {
case '\\':
fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
case '\'':
if (fLast != BACKSLASH) {
- return postFix(CHARACTER);
+ return postFix(STRING_SQ);
} else {
consume();
private final IToken postFix(int state) {
fTokenLength++;
fLast= NONE;
- fState= JAVA;
+ fState= HTML;
fPrefixLength= 0;
return fTokens[state];
}
private final IToken preFix(int state, int newState, int last, int prefixLength) {
// emulate JavaPartitionScanner
- if (fgEmulate && state == JAVA && (fTokenLength - getLastLength(fLast) > 0)) {
- fTokenLength -= getLastLength(fLast);
- fJavaOffset= fTokenOffset;
- fJavaLength= fTokenLength;
- fTokenLength= 1;
- fState= newState;
- fPrefixLength= prefixLength;
- fLast= last;
- return fTokens[state];
-
- } else {
+// if (fgEmulate && state == JAVA && (fTokenLength - getLastLength(fLast) > 0)) {
+// fTokenLength -= getLastLength(fLast);
+// fJavaOffset= fTokenOffset;
+// fJavaLength= fTokenLength;
+// fTokenLength= 1;
+// fState= newState;
+// fPrefixLength= prefixLength;
+// fLast= last;
+// return fTokens[state];
+//
+// } else {
fTokenLength -= getLastLength(fLast);
fLast= last;
fPrefixLength= prefixLength;
IToken token= fTokens[state];
fState= newState;
return token;
- }
+// }
}
private static int getState(String contentType) {
if (contentType == null)
- return JAVA;
-
- else if (contentType.equals(JAVA_SINGLE_LINE_COMMENT))
+ return HTML;
+
+ else if (contentType.equals(IPHPPartitions.PHP_PARTITIONING))
+ return PHP;
+
+ else if (contentType.equals(IPHPPartitions.PHP_SINGLELINE_COMMENT))
return SINGLE_LINE_COMMENT;
- else if (contentType.equals(JAVA_MULTI_LINE_COMMENT))
+ else if (contentType.equals(IPHPPartitions.PHP_MULTILINE_COMMENT))
return MULTI_LINE_COMMENT;
- else if (contentType.equals(JAVA_DOC))
- return JAVADOC;
-
- else if (contentType.equals(JAVA_STRING))
- return STRING;
+ else if (contentType.equals(IPHPPartitions.PHP_PHPDOC_COMMENT))
+ return PHPDOC;
- else if (contentType.equals(SKIP))
- return CHARACTER;
+ else if (contentType.equals(IPHPPartitions.PHP_STRING_DQ))
+ return STRING_DQ;
+
+ else if (contentType.equals(IPHPPartitions.PHP_STRING_SQ))
+ return STRING_SQ;
+
+// else if (contentType.equals(SKIP))
+// return CHARACTER;
else
- return JAVA;
+ return HTML;
}
/*
if (offset == partitionOffset) {
// restart at beginning of partition
- fState= JAVA;
+ fState= HTML;
} else {
fState= getState(contentType);
}
// emulate JavaPartitionScanner
- if (fgEmulate) {
- fJavaOffset= -1;
- fJavaLength= 0;
- }
+// if (fgEmulate) {
+// fJavaOffset= -1;
+// fJavaLength= 0;
+// }
}
/*
fTokenLength= 0;
fPrefixLength= 0;
fLast= NONE;
- fState= JAVA;
+ fState= HTML;
// emulate JavaPartitionScanner
- if (fgEmulate) {
- fJavaOffset= -1;
- fJavaLength= 0;
- }
+// if (fgEmulate) {
+// fJavaOffset= -1;
+// fJavaLength= 0;
+// }
}
/*
public interface IPHPPartitions
{
public final static String PHP_PARTITIONING = "__php"; //$NON-NLS-1$
+ public final static String PHP_PHPDOC_COMMENT = "__php_phpdoc_comment"; //$NON-NLS-1$
+ public final static String PHP_SINGLELINE_COMMENT = "__php_singleline_comment"; //$NON-NLS-1$
public final static String PHP_MULTILINE_COMMENT = "__php_multiline_comment"; //$NON-NLS-1$
- public final static String PHP_STRING = "__php_string"; //$NON-NLS-1$
+ public final static String PHP_STRING_DQ = "__php_string"; //$NON-NLS-1$
+ public final static String PHP_STRING_SQ = "__php_string_sq"; //$NON-NLS-1$
public final static String JAVASCRIPT = "__javascript"; //$NON-NLS-1$
public final static String JS_MULTILINE_COMMENT = "__js_multiline_comment"; //$NON-NLS-1$
public final static String CSS = "__css"; //$NON-NLS-1$
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.java;
+
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.texteditor.ITextEditorExtension3;
+
+
+/**
+ * Auto indent strategy for java strings
+ */
+public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
+
+ private String fPartitioning;
+
+ /**
+ * The input string doesn't contain any line delimiter.
+ *
+ * @param inputString the given input string
+ * @return the displayable string.
+ */
+ private String displayString(String inputString, String indentation, String delimiter) {
+
+ int length = inputString.length();
+ StringBuffer buffer = new StringBuffer(length);
+ java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); //$NON-NLS-1$
+ while (tokenizer.hasMoreTokens()){
+
+ String token = tokenizer.nextToken();
+ if (token.equals("\r")) { //$NON-NLS-1$
+ buffer.append("\\r"); //$NON-NLS-1$
+ if (tokenizer.hasMoreTokens()) {
+ token = tokenizer.nextToken();
+ if (token.equals("\n")) { //$NON-NLS-1$
+ buffer.append("\\n"); //$NON-NLS-1$
+ buffer.append("\" + " + delimiter); //$NON-NLS-1$
+ buffer.append(indentation);
+ buffer.append("\""); //$NON-NLS-1$
+ continue;
+ } else {
+ buffer.append("\" + " + delimiter); //$NON-NLS-1$
+ buffer.append(indentation);
+ buffer.append("\""); //$NON-NLS-1$
+ }
+ } else {
+ continue;
+ }
+ } else if (token.equals("\n")) { //$NON-NLS-1$
+ buffer.append("\\n"); //$NON-NLS-1$
+ buffer.append("\" + " + delimiter); //$NON-NLS-1$
+ buffer.append(indentation);
+ buffer.append("\""); //$NON-NLS-1$
+ continue;
+ }
+
+ StringBuffer tokenBuffer = new StringBuffer();
+ for (int i = 0; i < token.length(); i++){
+ char c = token.charAt(i);
+ switch (c) {
+ case '\r' :
+ tokenBuffer.append("\\r"); //$NON-NLS-1$
+ break;
+ case '\n' :
+ tokenBuffer.append("\\n"); //$NON-NLS-1$
+ break;
+ case '\b' :
+ tokenBuffer.append("\\b"); //$NON-NLS-1$
+ break;
+ case '\t' :
+ // keep tabs verbatim
+ tokenBuffer.append("\t"); //$NON-NLS-1$
+ break;
+ case '\f' :
+ tokenBuffer.append("\\f"); //$NON-NLS-1$
+ break;
+ case '\"' :
+ tokenBuffer.append("\\\""); //$NON-NLS-1$
+ break;
+ case '\'' :
+ tokenBuffer.append("\\'"); //$NON-NLS-1$
+ break;
+ case '\\' :
+ tokenBuffer.append("\\\\"); //$NON-NLS-1$
+ break;
+ default :
+ tokenBuffer.append(c);
+ }
+ }
+ buffer.append(tokenBuffer);
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Creates a new Java string auto indent strategy for the given document partitioning.
+ *
+ * @param partitioning the document partitioning
+ */
+ public JavaStringAutoIndentStrategy(String partitioning) {
+ super();
+ fPartitioning= partitioning;
+ }
+
+ private boolean isLineDelimiter(IDocument document, String text) {
+ String[] delimiters= document.getLegalLineDelimiters();
+ if (delimiters != null)
+ return TextUtilities.equals(delimiters, text) > -1;
+ return false;
+ }
+
+ private String getLineIndentation(IDocument document, int offset) throws BadLocationException {
+
+ // find start of line
+ int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset);
+ IRegion line= document.getLineInformationOfOffset(adjustedOffset);
+ int start= line.getOffset();
+
+ // find white spaces
+ int end= findEndOfWhiteSpace(document, start, offset);
+
+ return document.get(start, end - start);
+ }
+
+ private String getModifiedText(String string, String indentation, String delimiter) throws BadLocationException {
+ return displayString(string, indentation, delimiter);
+ }
+
+ private void javaStringIndentAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException {
+
+ ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset);
+ int offset= partition.getOffset();
+ int length= partition.getLength();
+
+ if (command.offset == offset) {
+ // we are really just before the string partition -> feet the event through the java indenter
+ // new JavaAutoIndentStrategy(fPartitioning).customizeDocumentCommand(document, command);
+ return;
+ }
+
+ if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
+ return;
+
+ String indentation= getLineIndentation(document, command.offset);
+ String delimiter= TextUtilities.getDefaultLineDelimiter(document);
+
+ IRegion line= document.getLineInformationOfOffset(offset);
+ String string= document.get(line.getOffset(), offset - line.getOffset());
+ if (string.trim().length() != 0)
+ indentation += String.valueOf("\t\t"); //$NON-NLS-1$
+
+ IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
+ if (isLineDelimiter(document, command.text))
+ command.text= "\" +" + command.text + indentation + "\""; //$NON-NLS-1$//$NON-NLS-2$
+ else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
+ command.text= getModifiedText(command.text, indentation, delimiter);
+ }
+
+ private boolean isSmartMode() {
+ IWorkbenchPage page= PHPeclipsePlugin.getActivePage();
+ if (page != null) {
+ IEditorPart part= page.getActiveEditor();
+ if (part instanceof ITextEditorExtension3) {
+ ITextEditorExtension3 extension= (ITextEditorExtension3) part;
+ return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
+ */
+ public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+ try {
+ if (command.length != 0 || command.text == null)
+ return;
+
+ IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
+
+ if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isSmartMode())
+ javaStringIndentAfterNewLine(document, command);
+
+ } catch (BadLocationException e) {
+ }
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.wizards;
+
+import org.eclipse.core.runtime.IStatus;
+
+public interface IStatusChangeListener {
+
+ /**
+ * Notifies this listener that the given status has changed.
+ *
+ * @param status the new status
+ */
+ void statusChanged(IStatus status);
+}
public final static String EDITOR_CLOSE_STRINGS_PHP = "closeStringsPHP"; //$NON-NLS-1$
/**
- * A named preference that controls whether the 'wrap strings' feature is
- * enabled.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- * @since 2.1
- */
- public final static String EDITOR_WRAP_STRINGS = "wrapStrings"; //$NON-NLS-1$
-
- /**
* A named preference that controls whether the 'close brackets' feature is
* enabled in PHP mode
* <p>
*/
public final static String EDITOR_CLOSE_BRACKETS_PHP = "closeBracketsPHP"; //$NON-NLS-1$
+ /**
+ * A named preference that controls whether the 'wrap strings' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'escape strings' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 3.0
+ */
+ public final static String EDITOR_ESCAPE_STRINGS= "escapeStrings"; //$NON-NLS-1$
+
/**
* A named preference that controls whether the 'close braces' feature is
* enabled.
* @since 2.1
*/
public final static String EDITOR_SMART_HOME_END = AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END;
-
+
+ /**
+ * A named preference that controls whether the 'sub-word navigation' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SUB_WORD_NAVIGATION= "subWordNavigation"; //$NON-NLS-1$
/**
* A named preference that controls if temporary problems are evaluated and shown in the UI.
* <p>
store.setDefault(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, true);
store.setDefault(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, false);
store.setDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true);
-
+
store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true);
+ store.setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true);
store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_JAVADOCS, true);
store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true);
+ store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS, false);
store.setDefault(PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, true);
store.setDefault(PreferenceConstants.EDITOR_FORMAT_JAVADOCS, true);
+ store.setDefault(PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, false);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML, true);
private final static String[] TYPES =
new String[] {
IPHPPartitions.PHP_PARTITIONING,
- IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.PHP_PHPDOC_COMMENT,
IPHPPartitions.HTML,
IPHPPartitions.HTML_MULTILINE_COMMENT,
IPHPPartitions.JAVASCRIPT,
/** The SmartyDoc scanner */
private SmartyDocCodeScanner fSmartyDocScanner;
/** The Java partitions scanner */
- private FastJavaPartitionScanner fPartitionScanner;
+ private PHPPartitionScanner fPartitionScanner;
/** The preference store */
private IPreferenceStore fPreferenceStore;
fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
- fPartitionScanner = new FastJavaPartitionScanner();
+// fPartitionScanner = new FastJavaPartitionScanner();
+ fPartitionScanner = new PHPPartitionScanner();
}
/**
fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
- fPartitionScanner = new FastJavaPartitionScanner();
+ // fPartitionScanner = new FastJavaPartitionScanner();
+ fPartitionScanner = new PHPPartitionScanner();
}
/**
private Scanner fScanner;
private int fToken;
public LineCreator() {
- fScanner = new Scanner(true, false, false, false, true);
+ fScanner = new Scanner(true, false, false, false, true, null, null);
}
/**
* Add the information of the current identifier to the line
List segmentation = new ArrayList();
for (int i = 0; i < linePartitioning.length; i++) {
- if (IPHPPartitions.PHP_STRING.equals(linePartitioning[i].getType()))
+ if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i].getType()))
segmentation.add(linePartitioning[i]);
}
import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
+import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
-import org.eclipse.core.resources.IFile;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.DefaultAutoIndentStrategy;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
/**
* Configuration for an <code>SourceViewer</code> which shows PHP code.
*/
*/
public IAutoIndentStrategy getAutoIndentStrategy(
ISourceViewer sourceViewer, String contentType) {
+ if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
+ return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
+
return (IPHPPartitions.PHP_PARTITIONING.equals(contentType)
? new PHPAutoIndentStrategy()
: new DefaultAutoIndentStrategy());
return new String[]{IPHPPartitions.HTML,
IPHPPartitions.HTML_MULTILINE_COMMENT,
IPHPPartitions.PHP_PARTITIONING,
- IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.PHP_PHPDOC_COMMENT,
IPHPPartitions.CSS,
IPHPPartitions.CSS_MULTILINE_COMMENT,
IPHPPartitions.JAVASCRIPT,
assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
IPHPPartitions.PHP_PARTITIONING);
assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
- IPHPPartitions.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_PHPDOC_COMMENT);
// assistant.enableAutoActivation(true);
// assistant.setAutoActivationDelay(500);
// assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
reconciler.setRepairer(dr, IPHPPartitions.PHP_PARTITIONING);
dr = new DefaultDamagerRepairer(getPHPDocScanner());
reconciler.setDamager(dr,
- IPHPPartitions.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_PHPDOC_COMMENT);
reconciler.setRepairer(dr,
- IPHPPartitions.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_PHPDOC_COMMENT);
return reconciler;
}
/*
presenter.setInformationProvider(provider,
IPHPPartitions.PHP_PARTITIONING);
presenter.setInformationProvider(provider,
- IPHPPartitions.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_PHPDOC_COMMENT);
presenter.setInformationProvider(provider,
IPHPPartitions.SMARTY_MULTILINE_COMMENT);
presenter.setInformationProvider(provider,
/**
* @author slanger
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class PHPPartition extends Partition
{
*/
protected boolean allowedPartition(String type)
{
- if(type.equals(IPHPPartitions.PHP_MULTILINE_COMMENT))
+ if(type.equals(IPHPPartitions.PHP_PHPDOC_COMMENT))
return true;
return false;
* Created on 05.03.2003
*
* @author Stefan Langer (musk)
- * @version $Revision: 1.23 $
+ * @version $Revision: 1.24 $
*/
package net.sourceforge.phpeclipse.phpeditor.php;
public PHPPartitionScanner(int fileType) {
this.tokens.put(IPHPPartitions.PHP_PARTITIONING, new Token(IPHPPartitions.PHP_PARTITIONING));
+ this.tokens.put(IPHPPartitions.PHP_STRING_DQ, new Token(IPHPPartitions.PHP_STRING_DQ));
this.tokens.put(
- IPHPPartitions.PHP_MULTILINE_COMMENT,
- new Token(IPHPPartitions.PHP_MULTILINE_COMMENT));
+ IPHPPartitions.PHP_PHPDOC_COMMENT,
+ new Token(IPHPPartitions.PHP_PHPDOC_COMMENT));
this.tokens.put(IPHPPartitions.HTML, new Token(IPHPPartitions.HTML));
this.tokens.put(
IPHPPartitions.HTML_MULTILINE_COMMENT,
switch (c) {
case '<' :
if (!isInString(IPHPPartitions.PHP_PARTITIONING)
- && fContentType != IPHPPartitions.PHP_MULTILINE_COMMENT
+ && fContentType != IPHPPartitions.PHP_PHPDOC_COMMENT
&& checkPattern(new char[] { '?', 'p', 'h', 'p' }, true)) {
if (fContentType != IPHPPartitions.PHP_PARTITIONING && fCurrentLength > 5) {
unread(5);
fCurrentLength = 5;
} else if (
!isInString(IPHPPartitions.PHP_PARTITIONING)
- && fContentType != IPHPPartitions.PHP_MULTILINE_COMMENT
+ && fContentType != IPHPPartitions.PHP_PHPDOC_COMMENT
&& checkPattern(new char[] { '?' }, false)) {
if (fContentType != IPHPPartitions.PHP_PARTITIONING && fCurrentLength > 2) {
unread(2);
} else if (
!isInString(IPHPPartitions.PHP_PARTITIONING)
&& (fContentType != IPHPPartitions.PHP_PARTITIONING) // BUG #769044
- && (fContentType != IPHPPartitions.PHP_MULTILINE_COMMENT) // BUG #769044
+ && (fContentType != IPHPPartitions.PHP_PHPDOC_COMMENT) // BUG #769044
&& checkPattern(new char[] { '!', '-', '-' })) { // return previouse partition
if (fContentType != IPHPPartitions.HTML_MULTILINE_COMMENT && fCurrentLength > 4) {
unread(4);
if (fContentType == IPHPPartitions.PHP_PARTITIONING && fCurrentLength > 2) {
unread(2);
IToken token = getToken(fContentType);
- fContentType = IPHPPartitions.PHP_MULTILINE_COMMENT;
+ fContentType = IPHPPartitions.PHP_PHPDOC_COMMENT;
return token;
- } else if (fContentType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ } else if (fContentType == IPHPPartitions.PHP_PHPDOC_COMMENT) {
fTokenOffset = fOffset - 2;
fCurrentLength = 2;
}
break;
case '*' :
if (!isInString(IPHPPartitions.PHP_PARTITIONING) && (c = read()) == '/') {
- if (fContentType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ if (fContentType == IPHPPartitions.PHP_PHPDOC_COMMENT) {
fContentType = IPHPPartitions.PHP_PARTITIONING;
partitionBorder = true;
- return getToken(IPHPPartitions.PHP_MULTILINE_COMMENT);
+ return getToken(IPHPPartitions.PHP_PHPDOC_COMMENT);
} else if (fContentType == IPHPPartitions.CSS_MULTILINE_COMMENT) {
} else if (fContentType == IPHPPartitions.JS_MULTILINE_COMMENT) {
}