Examples of IScopeContext


Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static boolean isEnableCLIDebug(IProject project) {
    Preferences prefs = getModelPreferences();
    boolean enableCLIDebug = prefs
        .getBoolean(PHPDebugCorePreferenceNames.ENABLE_CLI_DEBUG);
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      enableCLIDebug = projectScope.getNode(getPreferenceNodeQualifier())
          .getBoolean(PHPDebugCorePreferenceNames.ENABLE_CLI_DEBUG,
              enableCLIDebug);
    }
    return enableCLIDebug;
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static String getDefaultBasePath(IProject project) {

    String basePath = null;
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      basePath = projectScope.getNode(getPreferenceNodeQualifier()).get(
          PHPDebugCorePreferenceNames.DEFAULT_BASE_PATH, basePath);
    }
    if (project != null && basePath == null) {
      return "/" + project.getName(); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static void setDefaultBasePath(IProject project, String value) {
    Preferences prefs = getModelPreferences();
    prefs.setValue(PHPDebugCorePreferenceNames.DEFAULT_BASE_PATH, value);
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      projectScope.getNode(getPreferenceNodeQualifier()).put(
          PHPDebugCorePreferenceNames.DEFAULT_BASE_PATH, value);
    }
  }
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static String getDefaultServerName(IProject project) {
    Preferences prefs = getModelPreferences();
    String serverName = prefs
        .getString(ServersManager.DEFAULT_SERVER_PREFERENCES_KEY);
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      serverName = projectScope.getNode(getPreferenceNodeQualifier())
          .get(ServersManager.DEFAULT_SERVER_PREFERENCES_KEY,
              serverName);
    }
    return serverName;
  }
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static String getDefaultDebuggerID(IProject project) {
    Preferences prefs = getModelPreferences();
    String debuggerID = prefs
        .getString(PHPDebugCorePreferenceNames.PHP_DEBUGGER_ID);
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      debuggerID = projectScope.getNode(getPreferenceNodeQualifier())
          .get(PHPDebugCorePreferenceNames.PHP_DEBUGGER_ID,
              debuggerID);
    }
    return debuggerID;
  }
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static String getTransferEncoding(IProject project) {
    Preferences prefs = getModelPreferences();
    String encoding = prefs
        .getString(PHPDebugCorePreferenceNames.TRANSFER_ENCODING);
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      encoding = projectScope.getNode(getPreferenceNodeQualifier()).get(
          PHPDebugCorePreferenceNames.TRANSFER_ENCODING, encoding);
    }
    return encoding;
  }
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

  public static String getOutputEncoding(IProject project) {
    Preferences prefs = getModelPreferences();
    String encoding = prefs
        .getString(PHPDebugCorePreferenceNames.OUTPUT_ENCODING);
    if (project != null && getElementSettingsForProject(project)) {
      IScopeContext projectScope = getProjectScope(project);
      encoding = projectScope.getNode(getPreferenceNodeQualifier()).get(
          PHPDebugCorePreferenceNames.OUTPUT_ENCODING, encoding);
    }
    return encoding;
  }
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

public class ProfileAdapterFactory implements IAdapterFactory {

  public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adaptableObject instanceof IScopeContext) {
      IScopeContext currContext = (IScopeContext) adaptableObject;
      IScopeContext instanceScope = InstanceScope.INSTANCE;
      List<Profile> profiles = null;
      try {
        profiles = ProfileStore.readProfiles(instanceScope);
      } catch (CoreException e) {
        Logger.logException(e);
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

                          .getScriptProject()
                          .getProject()),
                      InstanceScope.INSTANCE,
                      DefaultScope.INSTANCE };
                  for (int i = 0; i < contents.length; i++) {
                    IScopeContext scopeContext = contents[i];
                    IEclipsePreferences node = scopeContext
                        .getNode(PHPCorePlugin.ID);
                    if (node != null) {
                      if (!options
                          .containsKey(PHPCoreConstants.FORMATTER_USE_TABS)) {
                        String useTabs = node
                            .get(PHPCoreConstants.FORMATTER_USE_TABS,
                                null);
                        if (useTabs != null) {
                          options.put(
                              PHPCoreConstants.FORMATTER_USE_TABS,
                              useTabs);
                        }
                      }
                      if (!options
                          .containsKey(PHPCoreConstants.FORMATTER_INDENTATION_SIZE)) {
                        String size = node
                            .get(PHPCoreConstants.FORMATTER_INDENTATION_SIZE,
                                null);
                        if (size != null) {
                          options.put(
                              PHPCoreConstants.FORMATTER_INDENTATION_SIZE,
                              size);
                        }
                      }
                    }
                  }
                  ast.setInsertUseStatement(true);
                  edits = program.rewrite(document, options);
                  edits.apply(document);
                  ast.setInsertUseStatement(false);
                } else if (!useAlias
                    && (usePart == null || !usePartName
                        .equals(usePart
                            .getNamespace()
                            .getFullyQualifiedName()))) {
                  // if the type name already exists, use
                  // fully
                  // qualified name to replace
                  proposal.setReplacementString(NamespaceReference.NAMESPACE_SEPARATOR
                      + fullName);
                }

                // if (useAlias &&
                // needsAliasPrepend(modelElement)) {
                //
                // // update replacement string: add namespace
                // // alias prefix
                // String namespacePrefix = typeName
                // + NamespaceReference.NAMESPACE_SEPARATOR;
                // String replacementString = proposal
                // .getReplacementString();
                //
                // String existingNamespacePrefix =
                // readNamespacePrefix(
                // sourceModule, document, offset,
                // ProjectOptions
                // .getPhpVersion(editorElement));
                //
                // // Add alias to the replacement string:
                // if (!usePartName
                // .equals(existingNamespacePrefix)) {
                // replacementString = namespacePrefix
                // + replacementString;
                // }
                // proposal.setReplacementString(replacementString);
                // }

                if (edits != null) {
                  int replacementOffset = proposal
                      .getReplacementOffset()
                      + edits.getLength();
                  offset += edits.getLength();
                  proposal.setReplacementOffset(replacementOffset);
                }
              }
            }

          }
          return offset;
        }
        return offset;
      }
      // class members should return offset directly
      if (modelElement.getElementType() != IModelElement.TYPE
          && !(modelElement instanceof FakeConstructor)) {
        IModelElement type = modelElement
            .getAncestor(IModelElement.TYPE);
        if (type != null
            && !PHPFlags.isNamespace(((IType) type).getFlags())) {
          return offset;
        }
      }
    } catch (Exception e) {
      Logger.logException(e);
    }

    // add use statement if needed:
    IType namespace = PHPModelUtils.getCurrentNamespace(modelElement);
    if (namespace != null) {

      // find source module of the current editor:
      if (textViewer instanceof PHPStructuredTextViewer) {
        ITextEditor textEditor = ((PHPStructuredTextViewer) textViewer)
            .getTextEditor();
        if (textEditor instanceof PHPStructuredEditor) {
          IModelElement editorElement = ((PHPStructuredEditor) textEditor)
              .getModelElement();
          if (editorElement != null) {
            ISourceModule sourceModule = ((ModelElement) editorElement)
                .getSourceModule();

            try {
              String namespaceName = namespace.getElementName();
              String usePartName = namespaceName;
              boolean useAlias = !Platform
                  .getPreferencesService()
                  .getBoolean(
                      PHPCorePlugin.ID,
                      PHPCoreConstants.CODEASSIST_INSERT_FULL_QUALIFIED_NAME_FOR_NAMESPACE,
                      true, null);
              if (!useAlias) {
                usePartName = usePartName
                    + NamespaceReference.NAMESPACE_SEPARATOR
                    + modelElement.getElementName();
              }
              ModuleDeclaration moduleDeclaration = SourceParserUtil
                  .getModuleDeclaration(sourceModule);
              TextEdit edits = null;

              ASTParser parser = ASTParser
                  .newParser(sourceModule);
              parser.setSource(document.get().toCharArray());
              Program program = parser.createAST(null);

              // don't insert USE statement for current namespace
              if (isSameNamespace(namespaceName, program,
                  sourceModule, offset)) {
                return offset;
              }

              // find existing use statement:
              UsePart usePart = ASTUtils
                  .findUseStatementByNamespace(
                      moduleDeclaration, usePartName,
                      offset);

              List<String> importedTypeName = getImportedTypeName(
                  moduleDeclaration, offset);
              String typeName = ""; //$NON-NLS-1$
              if (!useAlias) {
                typeName = modelElement.getElementName()
                    .toLowerCase();
              } else {
                if (usePart != null
                    && usePart.getAlias() != null
                    && usePart.getAlias().getName() != null) {
                  typeName = usePart.getAlias().getName();
                } else {
                  typeName = PHPModelUtils
                      .extractElementName(namespaceName)
                      .toLowerCase();
                }
              }

              // if the class/namesapce has not been imported
              // add use statement
              if (!importedTypeName.contains(typeName)) {

                program.recordModifications();
                AST ast = program.getAST();
                NamespaceName newNamespaceName = ast
                    .newNamespaceName(
                        createIdentifiers(ast,
                            usePartName), false,
                        false);
                UseStatementPart newUseStatementPart = ast
                    .newUseStatementPart(newNamespaceName,
                        null);
                org.eclipse.php.internal.core.ast.nodes.UseStatement newUseStatement = ast
                    .newUseStatement(Arrays
                        .asList(new UseStatementPart[] { newUseStatementPart }));

                NamespaceDeclaration currentNamespace = getCurrentNamespace(
                    program, sourceModule, offset - 1);
                if (currentNamespace != null) {
                  // insert in the beginning of the
                  // current
                  // namespace:
                  int index = getLastUsestatementIndex(
                      currentNamespace.getBody()
                          .statements(), offset);
                  if (index > 0) {// workaround for bug 393253
                    try {
                      int beginLine = document
                          .getLineOfOffset(currentNamespace
                              .getBody()
                              .statements()
                              .get(index - 1)
                              .getEnd()) + 1;
                      newUseStatement
                          .setSourceRange(
                              document.getLineOffset(beginLine),
                              0);
                    } catch (Exception e) {
                    }
                  }
                  currentNamespace.getBody().statements()
                      .add(index, newUseStatement);
                } else {
                  // insert in the beginning of the
                  // document:
                  int index = getLastUsestatementIndex(
                      program.statements(), offset);
                  if (index > 0) {// workaround for bug 393253
                    try {
                      int beginLine = document
                          .getLineOfOffset(program
                              .statements()
                              .get(index - 1)
                              .getEnd()) + 1;
                      newUseStatement
                          .setSourceRange(
                              document.getLineOffset(beginLine),
                              0);
                    } catch (Exception e) {
                    }
                  }
                  program.statements().add(index,
                      newUseStatement);
                }
                Map options = new HashMap(
                    PHPCorePlugin.getOptions());
                // TODO project may be null
                IScopeContext[] contents = new IScopeContext[] {
                    new ProjectScope(modelElement
                        .getScriptProject()
                        .getProject()),
                    InstanceScope.INSTANCE,
                    DefaultScope.INSTANCE };
                for (int i = 0; i < contents.length; i++) {
                  IScopeContext scopeContext = contents[i];
                  IEclipsePreferences node = scopeContext
                      .getNode(PHPCorePlugin.ID);
                  if (node != null) {
                    if (!options
                        .containsKey(PHPCoreConstants.FORMATTER_USE_TABS)) {
                      String useTabs = node
View Full Code Here

Examples of org.eclipse.core.runtime.preferences.IScopeContext

    }
  }

  public final boolean hasProjectSpecificOptions(IProject project) {
    if (project != null) {
      IScopeContext projectContext = new ProjectScope(project);
      Key[] allKeys = fAllKeys;
      for (int i = 0; i < allKeys.length; i++) {
        if (allKeys[i].getStoredValue(projectContext, fManager) != null) {
          return true;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.